summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2023-09-17 22:19:05 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2023-09-18 15:31:20 +0200
commite0b73760a29ea80d242958942b153769a59bf0f9 (patch)
tree1456ef9b0ee89e5b154974bbb93f85c6a9a0505e
parent301e522e7ee440b9c026042dd94815134c88adf2 (diff)
use more concrete UNO types in sw
Change-Id: I446cf00ac7e320586da2dd0837cf873ca9ab0ca6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157013 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r--sw/inc/fmtftn.hxx3
-rw-r--r--sw/inc/formatlinebreak.hxx3
-rw-r--r--sw/qa/core/unocore/unocore.cxx2
-rw-r--r--sw/source/core/doc/doc.cxx5
-rw-r--r--sw/source/core/text/inftxt.cxx12
-rw-r--r--sw/source/core/text/txtftn.cxx9
-rw-r--r--sw/source/core/txtnode/atrftn.cxx6
-rw-r--r--sw/source/core/txtnode/attrlinebreak.cxx8
-rw-r--r--sw/source/ui/vba/vbaformfield.cxx2
-rw-r--r--sw/source/uibase/dialog/SwSpellDialogChildWindow.cxx2
-rw-r--r--sw/source/uibase/docvw/edtwin2.cxx16
-rw-r--r--sw/source/uibase/sidebar/WriterInspectorTextPanel.cxx21
12 files changed, 44 insertions, 45 deletions
diff --git a/sw/inc/fmtftn.hxx b/sw/inc/fmtftn.hxx
index 009b75c3f98f..96742789d89a 100644
--- a/sw/inc/fmtftn.hxx
+++ b/sw/inc/fmtftn.hxx
@@ -36,6 +36,7 @@ class SwDoc;
class SwTextFootnote;
class SwRootFrame;
class SwXFootnote;
+class SwXTextRange;
// ATT_FTN
@@ -93,7 +94,7 @@ public:
OUString GetViewNumStr(const SwDoc& rDoc, SwRootFrame const* pLayout,
bool bInclStrings = false) const;
- css::uno::Reference<css::text::XTextRange> getAnchor(SwDoc& rDoc) const;
+ rtl::Reference<SwXTextRange> getAnchor(SwDoc& rDoc) const;
unotools::WeakReference<SwXFootnote> const& GetXFootnote() const
{ return m_wXFootnote; }
diff --git a/sw/inc/formatlinebreak.hxx b/sw/inc/formatlinebreak.hxx
index 1bc05f092903..a5b7ba9f4a5e 100644
--- a/sw/inc/formatlinebreak.hxx
+++ b/sw/inc/formatlinebreak.hxx
@@ -30,6 +30,7 @@
class SwDoc;
class SwTextLineBreak;
class SwXLineBreak;
+class SwXTextRange;
/// Defines the location of a line break text wrapping restart.
enum class SwLineBreakClear
@@ -69,7 +70,7 @@ public:
sal_uInt16 GetValueCount() const override;
- css::uno::Reference<css::text::XTextRange> GetAnchor() const;
+ rtl::Reference<SwXTextRange> GetAnchor() const;
void SetTextLineBreak(SwTextLineBreak* pTextAttr) { m_pTextAttr = pTextAttr; }
diff --git a/sw/qa/core/unocore/unocore.cxx b/sw/qa/core/unocore/unocore.cxx
index cb6f52d0fdbb..8715a4868f30 100644
--- a/sw/qa/core/unocore/unocore.cxx
+++ b/sw/qa/core/unocore/unocore.cxx
@@ -64,7 +64,7 @@ CPPUNIT_TEST_FIXTURE(SwCoreUnocoreTest, testTdf119081)
SwDoc* pDoc = pDocShell->GetDoc();
SwPaM& rCursor = pWrtShell->GetCurrentShellCursor();
- uno::Reference<text::XTextRange> xInsertPosition
+ rtl::Reference<SwXTextRange> xInsertPosition
= SwXTextRange::CreateXTextRange(*pDoc, *rCursor.GetPoint(), nullptr);
uno::Reference<text::XTextAppend> xTextAppend(xInsertPosition->getText(), uno::UNO_QUERY);
// Without the accompanying fix in place, this test would have failed with:
diff --git a/sw/source/core/doc/doc.cxx b/sw/source/core/doc/doc.cxx
index 82b3b0da827c..da14a84674e3 100644
--- a/sw/source/core/doc/doc.cxx
+++ b/sw/source/core/doc/doc.cxx
@@ -1878,10 +1878,9 @@ void SwDoc::SetLanguage(const LanguageType eLang, const sal_uInt16 nId)
bool SwDoc::HasParagraphDirectFormatting(const SwPosition& rPos)
{
- uno::Reference<text::XTextRange> xRange(SwXTextRange::CreateXTextRange(rPos.GetDoc(), rPos,
+ rtl::Reference<SwXTextRange> xRange(SwXTextRange::CreateXTextRange(rPos.GetDoc(), rPos,
&rPos));
- uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xRange, uno::UNO_QUERY_THROW);
- uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration();
+ uno::Reference<container::XEnumeration> xParaEnum = xRange->createEnumeration();
uno::Reference<text::XTextRange> xThisParagraphRange(xParaEnum->nextElement(), uno::UNO_QUERY);
if (xThisParagraphRange.is())
{
diff --git a/sw/source/core/text/inftxt.cxx b/sw/source/core/text/inftxt.cxx
index 7544868bc2ee..82bbf9d879bf 100644
--- a/sw/source/core/text/inftxt.cxx
+++ b/sw/source/core/text/inftxt.cxx
@@ -1358,12 +1358,11 @@ void SwTextPaintInfo::DrawCSDFHighlighting(const SwLinePortion &rPor) const
SwPosition aPosition(pFrame->MapViewToModelPos(GetIdx()));
SwPosition aMarkPosition(pFrame->MapViewToModelPos(GetIdx() + GetLen()));
- uno::Reference<text::XTextRange> xRange(
+ rtl::Reference<SwXTextRange> xRange(
SwXTextRange::CreateXTextRange(pFrame->GetDoc(), aPosition, &aMarkPosition));
- uno::Reference<beans::XPropertySet> xPropertiesSet(xRange, uno::UNO_QUERY_THROW);
OUString sCurrentCharStyle;
- xPropertiesSet->getPropertyValue("CharStyleName") >>= sCurrentCharStyle;
+ xRange->getPropertyValue("CharStyleName") >>= sCurrentCharStyle;
std::optional<OUString> sCSNumberOrDF; // CS number or "df" or not used
std::optional<Color> aFillColor;
@@ -1408,9 +1407,8 @@ void SwTextPaintInfo::DrawCSDFHighlighting(const SwLinePortion &rPor) const
SfxItemPropertyMap const& rMap(rPropSet.getPropertyMap());
- uno::Reference<beans::XPropertyState> xPropertiesState(xRange, uno::UNO_QUERY_THROW);
const uno::Sequence<beans::Property> aProperties
- = xPropertiesSet->getPropertySetInfo()->getProperties();
+ = xRange->getPropertySetInfo()->getProperties();
for (const beans::Property& rProperty : aProperties)
{
@@ -1423,9 +1421,9 @@ void SwTextPaintInfo::DrawCSDFHighlighting(const SwLinePortion &rPor) const
!= aHiddenProperties.end())
continue;
- if (xPropertiesState->getPropertyState(rPropName) == beans::PropertyState_DIRECT_VALUE)
+ if (xRange->getPropertyState(rPropName) == beans::PropertyState_DIRECT_VALUE)
{
- const uno::Any aAny = xPropertiesSet->getPropertyValue(rPropName);
+ const uno::Any aAny = xRange->getPropertyValue(rPropName);
if (HasValidPropertyValue(aAny))
{
sCSNumberOrDF = SwResId(STR_CHARACTER_DIRECT_FORMATTING_TAG);
diff --git a/sw/source/core/text/txtftn.cxx b/sw/source/core/text/txtftn.cxx
index 035158e2bd25..c1fa749c93f5 100644
--- a/sw/source/core/text/txtftn.cxx
+++ b/sw/source/core/text/txtftn.cxx
@@ -972,16 +972,15 @@ SwNumberPortion *SwTextFormatter::NewFootnoteNumPortion( SwTextFormatInfo const
pNumFnt->SetWeight( WEIGHT_NORMAL, SwFontScript::CJK );
pNumFnt->SetWeight( WEIGHT_NORMAL, SwFontScript::CTL );
- const auto xAnchor = rFootnote.getAnchor(*pDoc);
- uno::Reference<beans::XPropertySet> xAnchorProps(xAnchor, uno::UNO_QUERY);
- if (xAnchorProps.is())
+ const rtl::Reference<SwXTextRange> xAnchor = rFootnote.getAnchor(*pDoc);
+ if (xAnchor.is())
{
- auto aAny = xAnchorProps->getPropertyValue("CharFontCharSet");
+ auto aAny = xAnchor->getPropertyValue("CharFontCharSet");
sal_Int16 eCharSet;
if ((aAny >>= eCharSet) && eCharSet == awt::CharSet::SYMBOL)
{
OUString aFontName;
- aAny = xAnchorProps->getPropertyValue("CharFontName");
+ aAny = xAnchor->getPropertyValue("CharFontName");
if (aAny >>= aFontName)
{
pNumFnt->SetName(aFontName, SwFontScript::Latin);
diff --git a/sw/source/core/txtnode/atrftn.cxx b/sw/source/core/txtnode/atrftn.cxx
index 59eb9b12f8f5..58f6a5001690 100644
--- a/sw/source/core/txtnode/atrftn.cxx
+++ b/sw/source/core/txtnode/atrftn.cxx
@@ -266,15 +266,15 @@ OUString SwFormatFootnote::GetViewNumStr(const SwDoc& rDoc,
return sRet;
}
-uno::Reference<text::XTextRange> SwFormatFootnote::getAnchor(SwDoc& rDoc) const
+rtl::Reference<SwXTextRange> SwFormatFootnote::getAnchor(SwDoc& rDoc) const
{
SolarMutexGuard aGuard;
if (!m_pTextAttr)
- return uno::Reference<text::XTextRange>();
+ return {};
SwPaM aPam(m_pTextAttr->GetTextNode(), m_pTextAttr->GetStart());
aPam.SetMark();
aPam.GetMark()->AdjustContent(+1);
- const rtl::Reference<SwXTextRange> xRet =
+ rtl::Reference<SwXTextRange> xRet =
SwXTextRange::CreateXTextRange(rDoc, *aPam.Start(), aPam.End());
return xRet;
}
diff --git a/sw/source/core/txtnode/attrlinebreak.cxx b/sw/source/core/txtnode/attrlinebreak.cxx
index 1c5c7882ee31..5ce9301820a5 100644
--- a/sw/source/core/txtnode/attrlinebreak.cxx
+++ b/sw/source/core/txtnode/attrlinebreak.cxx
@@ -74,19 +74,17 @@ sal_uInt16 SwFormatLineBreak::GetValueCount() const
return static_cast<sal_uInt16>(SwLineBreakClear::LAST) + 1;
}
-uno::Reference<text::XTextRange> SwFormatLineBreak::GetAnchor() const
+rtl::Reference<SwXTextRange> SwFormatLineBreak::GetAnchor() const
{
SolarMutexGuard aGuard;
if (!m_pTextAttr)
- {
- return uno::Reference<text::XTextRange>();
- }
+ return {};
SwPaM aPam(m_pTextAttr->GetTextNode(), m_pTextAttr->GetStart());
aPam.SetMark();
aPam.GetMark()->AdjustContent(+1);
- uno::Reference<text::XTextRange> xRet
+ rtl::Reference<SwXTextRange> xRet
= SwXTextRange::CreateXTextRange(aPam.GetDoc(), *aPam.Start(), aPam.End());
return xRet;
}
diff --git a/sw/source/ui/vba/vbaformfield.cxx b/sw/source/ui/vba/vbaformfield.cxx
index 4669fdc5d4bd..cb1351fa74b9 100644
--- a/sw/source/ui/vba/vbaformfield.cxx
+++ b/sw/source/ui/vba/vbaformfield.cxx
@@ -123,7 +123,7 @@ uno::Reference<word::XRange> SwVbaFormField::Range()
SwDoc* pDoc = word::getDocShell(m_xTextDocument)->GetDoc();
if (pDoc)
{
- uno::Reference<text::XTextRange> xText(SwXTextRange::CreateXTextRange(
+ rtl::Reference<SwXTextRange> xText(SwXTextRange::CreateXTextRange(
*pDoc, m_rFormField.GetMarkStart(), &m_rFormField.GetMarkEnd()));
if (xText.is())
xRet = new SwVbaRange(mxParent, mxContext, m_xTextDocument, xText->getStart(),
diff --git a/sw/source/uibase/dialog/SwSpellDialogChildWindow.cxx b/sw/source/uibase/dialog/SwSpellDialogChildWindow.cxx
index da1fd5377054..5af09a6adf52 100644
--- a/sw/source/uibase/dialog/SwSpellDialogChildWindow.cxx
+++ b/sw/source/uibase/dialog/SwSpellDialogChildWindow.cxx
@@ -68,7 +68,7 @@ struct SpellState
std::unique_ptr<SwPaM>
pOtherCursor; // position where the spelling inside the _other_ area started
bool m_bDrawingsSpelled; // all drawings spelled
- Reference<XTextRange> m_xStartRange; // text range that marks the start of spelling
+ rtl::Reference<SwXTextRange> m_xStartRange; // text range that marks the start of spelling
const SdrObject* m_pStartDrawing; // draw text object spelling started in
ESelection m_aStartDrawingSelection; // draw text start selection
bool m_bRestartDrawing; // the first selected drawing object is found again
diff --git a/sw/source/uibase/docvw/edtwin2.cxx b/sw/source/uibase/docvw/edtwin2.cxx
index 6e09ffd19b45..c3bea9094135 100644
--- a/sw/source/uibase/docvw/edtwin2.cxx
+++ b/sw/source/uibase/docvw/edtwin2.cxx
@@ -112,10 +112,11 @@ bool PSCSDFPropsQuickHelp(const HelpEvent &rEvt, SwWrtShell& rSh)
if (!aPos.GetContentNode()->IsTextNode())
return false;
- uno::Reference<text::XTextRange> xRange(
+ rtl::Reference<SwXTextRange> xRange(
SwXTextRange::CreateXTextRange(*(rView.GetDocShell()->GetDoc()),
aPos, &aPos));
- uno::Reference<beans::XPropertySet> xPropertySet(xRange, uno::UNO_QUERY_THROW);
+ if (!xRange)
+ throw uno::RuntimeException();
SwContentFrame* pContentFrame = aPos.GetContentNode()->GetTextNode()->getLayoutFrame(
rSh.GetLayout());
@@ -139,7 +140,7 @@ bool PSCSDFPropsQuickHelp(const HelpEvent &rEvt, SwWrtShell& rSh)
{
// check if in CS formatting highlighted area
OUString sCharStyle;
- xPropertySet->getPropertyValue("CharStyleName") >>= sCharStyle;
+ xRange->getPropertyValue("CharStyleName") >>= sCharStyle;
if (!sCharStyle.isEmpty())
sText = SwStyleNameMapper::GetUIName(sCharStyle, SwGetPoolIdFromName::ChrFmt);
}
@@ -166,9 +167,8 @@ bool PSCSDFPropsQuickHelp(const HelpEvent &rEvt, SwWrtShell& rSh)
*aSwMapProvider.GetPropertySet(PROPERTY_MAP_CHAR_AUTO_STYLE));
SfxItemPropertyMap const& rMap(rPropSet.getPropertyMap());
- uno::Reference<beans::XPropertyState> xPropertiesState(xRange, uno::UNO_QUERY_THROW);
const uno::Sequence<beans::Property> aProperties
- = xPropertySet->getPropertySetInfo()->getProperties();
+ = xRange->getPropertySetInfo()->getProperties();
for (const beans::Property& rProperty : aProperties)
{
@@ -181,10 +181,10 @@ bool PSCSDFPropsQuickHelp(const HelpEvent &rEvt, SwWrtShell& rSh)
!= aHiddenProperties.end())
continue;
- if (xPropertiesState->getPropertyState(rPropName)
+ if (xRange->getPropertyState(rPropName)
== beans::PropertyState_DIRECT_VALUE)
{
- const uno::Any aAny = xPropertySet->getPropertyValue(rPropName);
+ const uno::Any aAny = xRange->getPropertyValue(rPropName);
if (HasValidPropertyValue(aAny))
{
sText = SwResId(STR_CHARACTER_DIRECT_FORMATTING);
@@ -215,7 +215,7 @@ bool PSCSDFPropsQuickHelp(const HelpEvent &rEvt, SwWrtShell& rSh)
if (aFrameAreaRect.Contains(aPt))
{
OUString sParaStyle;
- xPropertySet->getPropertyValue("ParaStyleName") >>= sParaStyle;
+ xRange->getPropertyValue("ParaStyleName") >>= sParaStyle;
sText = SwStyleNameMapper::GetUIName(sParaStyle, SwGetPoolIdFromName::TxtColl);
// check for paragraph direct formatting
if (SwDoc::HasParagraphDirectFormatting(aPos))
diff --git a/sw/source/uibase/sidebar/WriterInspectorTextPanel.cxx b/sw/source/uibase/sidebar/WriterInspectorTextPanel.cxx
index 63b952f0fa86..49086fa9a04f 100644
--- a/sw/source/uibase/sidebar/WriterInspectorTextPanel.cxx
+++ b/sw/source/uibase/sidebar/WriterInspectorTextPanel.cxx
@@ -560,9 +560,10 @@ static void UpdateTree(SwDocShell& rDocSh, SwEditShell& rEditSh,
aFieldsNode.NodeType = svx::sidebar::TreeNode::Category;
aTextSectionsNode.NodeType = svx::sidebar::TreeNode::Category;
- uno::Reference<text::XTextRange> xRange(
+ rtl::Reference<SwXTextRange> xRange(
SwXTextRange::CreateXTextRange(*pDoc, *pCursor->GetPoint(), nullptr));
- uno::Reference<beans::XPropertySet> xPropertiesSet(xRange, uno::UNO_QUERY_THROW);
+ if (!xRange)
+ throw uno::RuntimeException();
std::unordered_map<OUString, bool> aIsDefined;
const std::vector<OUString> aHiddenProperties{ UNO_NAME_RSID,
@@ -583,7 +584,8 @@ static void UpdateTree(SwDocShell& rDocSh, SwEditShell& rEditSh,
const std::vector<OUString> aHiddenCharacterProperties{ UNO_NAME_CHAR_COLOR_THEME,
UNO_NAME_CHAR_COLOR_TINT_OR_SHADE };
- InsertValues(xRange, aIsDefined, aCharDFNode, false, aHiddenProperties, aFieldsNode);
+ InsertValues(static_cast<cppu::OWeakObject*>(xRange.get()), aIsDefined, aCharDFNode, false,
+ aHiddenProperties, aFieldsNode);
uno::Reference<style::XStyleFamiliesSupplier> xStyleFamiliesSupplier(rDocSh.GetBaseModel(),
uno::UNO_QUERY);
@@ -593,12 +595,13 @@ static void UpdateTree(SwDocShell& rDocSh, SwEditShell& rEditSh,
uno::Reference<container::XNameAccess> xStyleFamily(
xStyleFamilies->getByName("CharacterStyles"), uno::UNO_QUERY_THROW);
- xPropertiesSet->getPropertyValue("CharStyleName") >>= sCurrentCharStyle;
- xPropertiesSet->getPropertyValue("ParaStyleName") >>= sCurrentParaStyle;
+ xRange->getPropertyValue("CharStyleName") >>= sCurrentCharStyle;
+ xRange->getPropertyValue("ParaStyleName") >>= sCurrentParaStyle;
if (!sCurrentCharStyle.isEmpty())
{
- xPropertiesSet.set(xStyleFamily->getByName(sCurrentCharStyle), css::uno::UNO_QUERY_THROW);
+ uno::Reference<beans::XPropertySet> xPropertiesSet(
+ xStyleFamily->getByName(sCurrentCharStyle), css::uno::UNO_QUERY_THROW);
xPropertiesSet->getPropertyValue("DisplayName") >>= sDisplayName;
svx::sidebar::TreeNode aCurrentChild;
aCurrentChild.sNodeName = sDisplayName;
@@ -611,8 +614,7 @@ static void UpdateTree(SwDocShell& rDocSh, SwEditShell& rEditSh,
}
// Collect paragraph direct formatting
- uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xRange, uno::UNO_QUERY_THROW);
- uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration();
+ uno::Reference<container::XEnumeration> xParaEnum = xRange->createEnumeration();
uno::Reference<text::XTextRange> xThisParagraphRange(xParaEnum->nextElement(), uno::UNO_QUERY);
if (xThisParagraphRange.is())
{
@@ -628,7 +630,8 @@ static void UpdateTree(SwDocShell& rDocSh, SwEditShell& rEditSh,
{
uno::Reference<style::XStyle> xPropertiesStyle(xStyleFamily->getByName(sCurrentParaStyle),
uno::UNO_QUERY_THROW);
- xPropertiesSet.set(xPropertiesStyle, css::uno::UNO_QUERY_THROW);
+ uno::Reference<beans::XPropertySet> xPropertiesSet(xPropertiesStyle,
+ css::uno::UNO_QUERY_THROW);
xPropertiesSet->getPropertyValue("DisplayName") >>= sDisplayName;
OUString aParentParaStyle = xPropertiesStyle->getParentStyle();
svx::sidebar::TreeNode aCurrentChild;