27 #include <osl/mutex.hxx>
34 #include <unoprnms.hxx>
47 uno::Sequence< OUString >
48 GetSupportedServiceNamesImpl(
49 size_t const nServices,
char const*
const pServices[])
51 uno::Sequence< OUString > ret(static_cast<sal_Int32>(nServices));
53 std::transform(pServices, pServices + nServices, ret.begin(),
54 [](
const char* pService) -> OUString {
return OUString::createFromAscii(pService); });
70 uno::WeakReference<uno::XInterface>
m_wThis;
79 const bool bIsEndnote)
81 , m_bIsEndnote(bIsEndnote)
82 , m_EventListeners(m_Mutex)
83 , m_bIsDescriptor(nullptr == pFootnote)
84 , m_pFormatFootnote(pFootnote)
90 return m_rThis.
GetDoc() ? m_pFormatFootnote :
nullptr;
96 throw uno::RuntimeException(
"SwXFootnote: disposed or invalid",
nullptr);
112 uno::Reference<uno::XInterface>
const xThis(
m_wThis);
117 lang::EventObject
const ev(xThis);
123 if(rHint.
GetId() == SfxHintId::Dying)
143 uno::Reference<text::XFootnote>
145 bool const isEndnote)
148 uno::Reference<text::XFootnote> xNote;
164 pNote->
m_pImpl->m_wThis = xNote;
171 class theSwXFootnoteUnoTunnelId :
public rtl::Static< UnoTunnelIdInit, theSwXFootnoteUnoTunnelId > {};
182 const sal_Int64 nRet( ::sw::UnoTunnelImpl<SwXFootnote>(rId,
this) );
189 return "SwXFootnote";
194 "com.sun.star.text.TextContent",
195 "com.sun.star.text.Footnote",
196 "com.sun.star.text.Text",
197 "com.sun.star.text.Endnote",
209 uno::Sequence< OUString > SAL_CALL
213 return GetSupportedServiceNamesImpl(
218 uno::Sequence< uno::Type > SAL_CALL
221 const uno::Sequence< uno::Type >
aTypes = SwXFootnote_Base::getTypes();
223 return ::comphelper::concatSequences(aTypes, aTextTypes);
226 uno::Sequence< sal_Int8 > SAL_CALL
229 return css::uno::Sequence<sal_Int8>();
235 const uno::Any ret = SwXFootnote_Base::queryInterface(rType);
251 else if (
m_pImpl->m_bIsDescriptor)
257 throw uno::RuntimeException();
266 OUString newLabel(aLabel);
268 if(newLabel.indexOf(
'\n') >=0 )
270 newLabel = newLabel.replace(
'\n',
' ');
276 OSL_ENSURE(pTextFootnote,
"No TextNode?");
282 else if (
m_pImpl->m_bIsDescriptor)
288 throw uno::RuntimeException();
299 throw uno::RuntimeException();
301 const uno::Reference<lang::XUnoTunnel> xRangeTunnel(
302 xTextRange, uno::UNO_QUERY);
304 ::sw::UnoTunnelGetImplementation<SwXTextRange>(xRangeTunnel);
306 ::sw::UnoTunnelGetImplementation<OTextCursorHelper>(xRangeTunnel);
307 SwDoc *
const pNewDoc =
308 pRange ? &pRange->
GetDoc() : (pCursor ? pCursor->GetDoc() :
nullptr);
311 throw lang::IllegalArgumentException();
319 pNewDoc->getIDocumentContentOperations().DeleteAndJoin(aPam);
322 if (!
m_pImpl->m_sLabel.isEmpty())
328 dynamic_cast<SwXTextCursor*>(pCursor));
329 const bool bForceExpandHints( pTextCursor && pTextCursor->
IsAtEndOfMeta() );
334 pNewDoc->getIDocumentContentOperations().InsertPoolItem(aPam, aFootNote, nInsertFlags);
344 m_pImpl->m_pFormatFootnote = pFootnote;
347 if (pNewDoc->IsInReading())
349 pTextAttr->
SetSeqNo(pNewDoc->GetFootnoteIdxs().size());
356 m_pImpl->m_bIsDescriptor =
false;
360 uno::Reference< text::XTextRange > SAL_CALL
364 return m_pImpl->GetFootnoteFormatOrThrow().getAnchor(*
GetDoc());
373 SwTextFootnote const*
const pTextFootnote = rFormat.GetTextFootnote();
374 OSL_ENSURE(pTextFootnote,
"no TextNode?");
376 const sal_Int32
nPos = pTextFootnote->GetStart();
377 SwPaM aPam(rTextNode, nPos, rTextNode, nPos+1);
383 const uno::Reference< lang::XEventListener > & xListener)
386 m_pImpl->m_EventListeners.addInterface(xListener);
391 const uno::Reference< lang::XEventListener > & xListener)
394 m_pImpl->m_EventListeners.removeInterface(xListener);
411 uno::Reference< text::XTextCursor >
417 uno::Reference< text::XTextCursor > SAL_CALL
424 SwTextFootnote const*
const pTextFootnote = rFormat.GetTextFootnote();
425 SwPosition aPos( *pTextFootnote->GetStartNode() );
428 auto& rUnoCursor(pXCursor->GetCursor());
430 return static_cast<text::XWordCursor*
>(pXCursor.get());
433 uno::Reference< text::XTextCursor > SAL_CALL
435 const uno::Reference< text::XTextRange > & xTextPosition)
444 throw uno::RuntimeException();
447 SwTextFootnote const*
const pTextFootnote = rFormat.GetTextFootnote();
451 if (pStart != pFootnoteStartNode)
453 throw uno::RuntimeException();
456 const uno::Reference< text::XTextCursor > xRet =
457 static_cast<text::XWordCursor*
>(
459 *aPam.GetPoint(), aPam.GetMark()));
463 uno::Reference< container::XEnumeration > SAL_CALL
470 SwTextFootnote const*
const pTextFootnote = rFormat.GetTextFootnote();
471 SwPosition aPos( *pTextFootnote->GetStartNode() );
472 auto pUnoCursor(
GetDoc()->CreateUnoCursor(aPos));
487 uno::Reference< beans::XPropertySetInfo > SAL_CALL
491 static uno::Reference< beans::XPropertySetInfo > xRet =
501 throw lang::IllegalArgumentException();
527 OSL_ENSURE(pTextFootnote,
"no TextNode?");
528 aRet <<= static_cast<sal_Int16>(pTextFootnote->
GetSeqRefNo());
533 beans::UnknownPropertyException aExcept;
534 aExcept.Message = rPropertyName;
544 const uno::Reference< beans::XPropertyChangeListener >& )
546 OSL_FAIL(
"SwXFootnote::addPropertyChangeListener(): not implemented");
552 const uno::Reference< beans::XPropertyChangeListener >& )
554 OSL_FAIL(
"SwXFootnote::removePropertyChangeListener(): not implemented");
560 const uno::Reference< beans::XVetoableChangeListener >& )
562 OSL_FAIL(
"SwXFootnote::addVetoableChangeListener(): not implemented");
568 const uno::Reference< beans::XVetoableChangeListener >& )
570 OSL_FAIL(
"SwXFootnote::removeVetoableChangeListener(): not implemented");
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)
Starts a section of nodes in the document model.
void SetDoc(SwDoc *const pDoc)
SwNode & GetNode(bool bPoint=true) const
Marks a position in the document model.
#define UNO_NAME_END_REDLINE
const SfxItemPropertySet * GetPropertySet(sal_uInt16 PropertyId)
void disposeAndClear(const css::lang::EventObject &rEvt)
bool IsAtEndOfMeta() const
static SwXParagraphEnumeration * Create(css::uno::Reference< css::text::XText > const &xParent, const std::shared_ptr< SwUnoCursor > &pCursor, const CursorType eType, SwTableBox const *const pTableBox=nullptr)
virtual bool DeleteAndJoin(SwPaM &, const bool bForceJoinNext=false)=0
complete delete of a given PaM
const size_t g_nServicesEndnote(SAL_N_ELEMENTS(g_ServicesFootnote))
IDocumentContentOperations const & getIDocumentContentOperations() const
css::uno::Reference< css::beans::XPropertySetInfo > const & getPropertySetInfo() const
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override
SwTextAttr * GetTextAttrForCharAt(const sal_Int32 nIndex, const sal_uInt16 nWhich=RES_TXTATR_END) const
get the text attribute at position nIndex which owns the dummy character CH_TXTATR_* at that position...
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
sal_Int32 GetStart() const
constexpr TypedWhichId< SwFormatFootnote > RES_TXTATR_FTN(58)
#define SAL_N_ELEMENTS(arr)
bool SetCurFootnote(const SwPaM &rPam, const OUString &rNumStr, bool bIsEndNote)
change footnotes in range
PaM is Point and Mark: a selection of the document model.
bool GetDefaultTextContentValue(css::uno::Any &rAny, std::u16string_view rPropertyName, sal_uInt16 nWID=0)
bool GoInNode(SwPaM &rPam, SwMoveFnCollection const &fnMove)
const SwPosition * GetPoint() const
virtual sal_Int64 SAL_CALL getSomething(const css::uno::Sequence< sal_Int8 > &rIdentifier) override
const size_t g_nServicesFootnote(g_nServicesEndnote-1)
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &rType) override
Force hint expand (only matters for hints with CH_TXTATR).
char const *const g_ServicesFootnote[]
css::uno::Type const & get()
bool StartListening(SvtBroadcaster &rBroadcaster)
SwStartNode * GetStartNode()
const SwFormatFootnote & GetFootnote() const
bool XTextRangeToSwPaM(SwUnoInternalPaM &rToFill, const uno::Reference< text::XTextRange > &xTextRange,::sw::TextRangeMode const eMode)
SvtBroadcaster & GetNotifier()
#define PROPERTY_MAP_FOOTNOTE
SwTextNode is a paragraph in the document model.
const SwDoc * GetDoc() const
SwMoveFnCollection const & fnMoveForward
SwPam::Move()/Find() default argument.
sal_Int32 GetIndex() const
SwUnoPropertyMapProvider aSwMapProvider
#define UNO_NAME_START_REDLINE
virtual css::uno::Any SAL_CALL getPropertyValue(const OUString &rPropertyName) override
#define UNO_NAME_REFERENCE_ID
const SwStartNode * FindFootnoteStartNode() const
SwTextNode * GetTextNode()
Inline methods from Node.hxx.
Base class of the Writer document model elements.