summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noelgrandin@gmail.com>2023-11-25 11:14:44 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2023-11-25 15:22:28 +0100
commitd54ae809aa29fa7a9894c0a1236374fa96e01a43 (patch)
treef228151ef41de727eeb6a1d798b3560bc64a9484
parentb5743ae5f576e45576426593da58fa74bb88c01b (diff)
loplugin:fieldcast in SwOneExampleFrame
Change-Id: Ic00ad388b2c18d90075db8e8d0d6b114ed13841a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159948 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r--compilerplugins/clang/fieldcast.results3
-rw-r--r--sw/source/ui/misc/glossary.cxx5
-rw-r--r--sw/source/uibase/inc/unotools.hxx6
-rw-r--r--sw/source/uibase/utlui/unotools.cxx54
4 files changed, 29 insertions, 39 deletions
diff --git a/compilerplugins/clang/fieldcast.results b/compilerplugins/clang/fieldcast.results
index 6fa27d645135..c1ede6ef7ae5 100644
--- a/compilerplugins/clang/fieldcast.results
+++ b/compilerplugins/clang/fieldcast.results
@@ -547,9 +547,6 @@ sw/source/uibase/inc/fldmgr.hxx:103
sw/source/uibase/inc/swuiccoll.hxx:35
SwCondCollPage m_pFormat SwFormat *
SwConditionTextFormatColl
-sw/source/uibase/inc/unotools.hxx:48
- SwOneExampleFrame m_xCursor css::uno::Reference<css::text::XTextCursor>
- OTextCursorHelper
unoidl/source/unoidl-read.cxx:151
(anonymous namespace)::Entity entity const rtl::Reference<unoidl::Entity>
unoidl::PublishableEntity
diff --git a/sw/source/ui/misc/glossary.cxx b/sw/source/ui/misc/glossary.cxx
index c7183d5126e1..8b2860c20c29 100644
--- a/sw/source/ui/misc/glossary.cxx
+++ b/sw/source/ui/misc/glossary.cxx
@@ -54,6 +54,7 @@
#include <macassgn.hxx>
#include <docsh.hxx>
#include <shellio.hxx>
+#include <unotextcursor.hxx>
#include <cmdid.h>
#include <sfx2/filedlghelper.hxx>
@@ -1042,7 +1043,7 @@ void SwGlossaryDlg::ResumeShowAutoText()
m_xAutoText = text::AutoTextContainer::create( comphelper::getProcessComponentContext() );
}
- uno::Reference< XTextCursor > & xCursor = m_xExampleFrame->GetTextCursor();
+ rtl::Reference< SwXTextCursor > & xCursor = m_xExampleFrame->GetTextCursor();
if(xCursor.is())
{
if (!sShortName.isEmpty())
@@ -1054,7 +1055,7 @@ void SwGlossaryDlg::ResumeShowAutoText()
uno::Any aEntry(xGroup->getByName(sShortName));
uno::Reference< XAutoTextEntry > xEntry;
aEntry >>= xEntry;
- xEntry->applyTo(xCursor);
+ xEntry->applyTo(static_cast<XSentenceCursor*>(xCursor.get()));
}
}
}
diff --git a/sw/source/uibase/inc/unotools.hxx b/sw/source/uibase/inc/unotools.hxx
index cda9ec73fcd5..e472a2f92706 100644
--- a/sw/source/uibase/inc/unotools.hxx
+++ b/sw/source/uibase/inc/unotools.hxx
@@ -29,6 +29,7 @@
#include <com/sun/star/frame/XController.hpp>
#include <com/sun/star/text/XTextCursor.hpp>
#include <swdllapi.h>
+#include <rtl/ref.hxx>
#define EX_SHOW_ONLINE_LAYOUT 0x01
// hard zoom value
@@ -39,13 +40,14 @@
#define EX_LOCALIZE_TOC_STRINGS 0x08
class SwView;
+class SwXTextCursor;
class SW_DLLPUBLIC SwOneExampleFrame final : public weld::CustomWidgetController
{
ScopedVclPtr<VirtualDevice> m_xVirDev;
css::uno::Reference< css::frame::XModel > m_xModel;
css::uno::Reference< css::frame::XController > m_xController;
- css::uno::Reference< css::text::XTextCursor > m_xCursor;
+ rtl::Reference< SwXTextCursor > m_xCursor;
Idle m_aLoadedIdle;
Link<SwOneExampleFrame&,void> m_aInitializedLink;
@@ -74,7 +76,7 @@ public:
virtual ~SwOneExampleFrame() override;
css::uno::Reference< css::frame::XModel > & GetModel() {return m_xModel;}
- css::uno::Reference< css::text::XTextCursor > & GetTextCursor() {return m_xCursor;}
+ rtl::Reference< SwXTextCursor > & GetTextCursor() {return m_xCursor;}
void ClearDocument();
diff --git a/sw/source/uibase/utlui/unotools.cxx b/sw/source/uibase/utlui/unotools.cxx
index 7e72566685e2..93edfaad30a7 100644
--- a/sw/source/uibase/utlui/unotools.cxx
+++ b/sw/source/uibase/utlui/unotools.cxx
@@ -26,6 +26,7 @@
#include <strings.hrc>
#include <unotools.hxx>
#include <unoprnms.hxx>
+#include <unotextcursor.hxx>
#include <i18nutil/unicode.hxx>
#include <o3tl/string_view.hxx>
#include <rtl/string.h>
@@ -143,8 +144,7 @@ void SwOneExampleFrame::Paint(vcl::RenderContext& rRenderContext, const tools::R
Color aBgColor = SW_MOD()->GetColorConfig().GetColorValue(::svtools::DOCCOLOR).nColor;
m_xVirDev->DrawWallpaper(tools::Rectangle(Point(), aSize), aBgColor);
- auto pCursor = dynamic_cast<OTextCursorHelper*>(m_xCursor.get());
- if (pCursor)
+ if (m_xCursor)
{
uno::Reference<view::XViewSettingsSupplier> xSettings(m_xController, uno::UNO_QUERY);
uno::Reference<beans::XPropertySet> xViewProps = xSettings->getViewSettings();
@@ -156,7 +156,7 @@ void SwOneExampleFrame::Paint(vcl::RenderContext& rRenderContext, const tools::R
m_xVirDev->Push(vcl::PushFlags::ALL);
m_xVirDev->SetMapMode(MapMode(MapUnit::MapTwip));
- SwDoc *pDoc = pCursor->GetDoc();
+ SwDoc *pDoc = m_xCursor->GetDoc();
SwDocShell* pShell = pDoc->GetDocShell();
tools::Rectangle aRect(Point(), m_xVirDev->PixelToLogic(aSize));
pShell->SetVisArea(tools::Rectangle(Point(), Size(aRect.GetWidth() * fZoom,
@@ -285,14 +285,14 @@ IMPL_LINK( SwOneExampleFrame, TimeoutHdl, Timer*, pTimer, void )
uno::Reference< text::XTextDocument > xDoc(m_xModel, uno::UNO_QUERY);
uno::Reference< text::XText > xText = xDoc->getText();
- m_xCursor = xText->createTextCursor();
+ uno::Reference< text::XTextCursor > xTextCursor = xText->createTextCursor();
+ m_xCursor = dynamic_cast<SwXTextCursor*>(xTextCursor.get());
+ assert(bool(xTextCursor) == bool(m_xCursor) && "expect to get SwXTextCursor type here");
//From here, a cursor is defined, which goes through the template,
//and overwrites the template words where it is necessary.
- auto pCursor = dynamic_cast<OTextCursorHelper*>(m_xCursor.get());
-
- SwDoc *pDoc = pCursor ? pCursor->GetDoc() : nullptr;
+ SwDoc *pDoc = m_xCursor ? m_xCursor->GetDoc() : nullptr;
if (pDoc && (m_nStyleFlags & EX_LOCALIZE_TOC_STRINGS))
{
SwEditShell* pSh = pDoc->GetEditShell();
@@ -362,8 +362,7 @@ IMPL_LINK( SwOneExampleFrame, TimeoutHdl, Timer*, pTimer, void )
}
}
- uno::Reference< beans::XPropertySet > xCursorProp(m_xCursor, uno::UNO_QUERY);
- uno::Any aPageStyle = xCursorProp->getPropertyValue(UNO_NAME_PAGE_STYLE_NAME);
+ uno::Any aPageStyle = m_xCursor->getPropertyValue(UNO_NAME_PAGE_STYLE_NAME);
OUString sPageStyle;
aPageStyle >>= sPageStyle;
@@ -428,31 +427,22 @@ void SwOneExampleFrame::ClearDocument()
{
if( !m_xCursor )
return;
- OTextCursorHelper* pCursor = dynamic_cast<OTextCursorHelper*>(m_xCursor.get());
- if( pCursor )
- {
- SwDoc* pDoc = pCursor->GetDoc();
- SwEditShell* pSh = pDoc->GetEditShell();
- pSh->LockPaint(LockPaintReason::ExampleFrame);
- pSh->StartAllAction();
- pSh->KillPams();
- pSh->ClearMark();
- pDoc->ClearDoc();
- pSh->ClearUpCursors();
-
- if( m_aLoadedIdle.IsActive())
- {
- pSh->EndAllAction();
- pSh->UnlockPaint();
- }
- m_aLoadedIdle.Start();
- }
- else
+
+ SwDoc* pDoc = m_xCursor->GetDoc();
+ SwEditShell* pSh = pDoc->GetEditShell();
+ pSh->LockPaint(LockPaintReason::ExampleFrame);
+ pSh->StartAllAction();
+ pSh->KillPams();
+ pSh->ClearMark();
+ pDoc->ClearDoc();
+ pSh->ClearUpCursors();
+
+ if( m_aLoadedIdle.IsActive())
{
- m_xCursor->gotoStart(false);
- m_xCursor->gotoEnd(true);
- m_xCursor->setString(OUString());
+ pSh->EndAllAction();
+ pSh->UnlockPaint();
}
+ m_aLoadedIdle.Start();
}
bool SwOneExampleFrame::CreatePopup(const Point& rPt)