summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--compilerplugins/clang/referencecasting.cxx385
-rw-r--r--compilerplugins/clang/store/referencecasting.cxx195
-rw-r--r--compilerplugins/clang/store/referencecasting.hxx33
-rw-r--r--compilerplugins/clang/test/referencecasting.cxx150
-rw-r--r--solenv/CompilerTest_compilerplugins_clang.mk1
-rw-r--r--sw/qa/extras/accessibility/accessible_relation_set.cxx2
-rw-r--r--sw/qa/extras/globalfilter/globalfilter.cxx8
-rw-r--r--sw/qa/extras/mailmerge/mailmerge.cxx8
-rw-r--r--sw/qa/extras/odfexport/odfexport.cxx22
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport10.cxx45
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport11.cxx6
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport12.cxx40
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport9.cxx14
-rw-r--r--sw/qa/extras/ooxmlimport/ooxmlimport.cxx18
-rw-r--r--sw/qa/extras/ooxmlimport/ooxmlimport2.cxx5
-rw-r--r--sw/qa/extras/rtfimport/rtfimport.cxx61
-rw-r--r--sw/qa/extras/uiwriter/uiwriter.cxx51
-rw-r--r--sw/qa/extras/uiwriter/uiwriter2.cxx8
-rw-r--r--sw/qa/extras/unowriter/unowriter.cxx14
-rw-r--r--sw/qa/extras/ww8export/ww8export.cxx48
-rw-r--r--sw/qa/extras/ww8export/ww8export2.cxx88
-rw-r--r--sw/qa/extras/ww8export/ww8export3.cxx2
22 files changed, 744 insertions, 460 deletions
diff --git a/compilerplugins/clang/referencecasting.cxx b/compilerplugins/clang/referencecasting.cxx
new file mode 100644
index 000000000000..e60177f4effb
--- /dev/null
+++ b/compilerplugins/clang/referencecasting.cxx
@@ -0,0 +1,385 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * Based on LLVM/Clang.
+ *
+ * This file is distributed under the University of Illinois Open Source
+ * License. See LICENSE.TXT for details.
+ *
+ */
+
+#include "plugin.hxx"
+#include "check.hxx"
+#include <iostream>
+
+/*
+This is a compile-time checker.
+
+Check for cases where we have
+ - two IDL interfaces A and B,
+ - B extends A
+ - we are converting a Reference<B> to a Reference<A> using UNO_QUERY
+
+This makes the code simpler and cheaper, because UNO_QUERY can be surprisingly expensive if used a lot.
+
+*/
+
+class ReferenceCasting : public loplugin::FilteringPlugin<ReferenceCasting>
+{
+public:
+ explicit ReferenceCasting(loplugin::InstantiationData const& data)
+ : FilteringPlugin(data)
+ {
+ }
+ void run() override
+ {
+ std::string fn(handler.getMainFileName());
+ loplugin::normalizeDotDotInFilePath(fn);
+ // macros
+ if (fn == SRCDIR "/dbaccess/source/ui/browser/formadapter.cxx")
+ return;
+ TraverseDecl(compiler.getASTContext().getTranslationUnitDecl());
+ }
+ bool VisitCXXConstructExpr(const CXXConstructExpr* cce);
+ bool VisitCXXMemberCallExpr(const CXXMemberCallExpr* mce);
+
+private:
+ bool CheckForUnnecessaryGet(const Expr*);
+};
+
+static const RecordType* extractTemplateType(const clang::Type*);
+static bool isDerivedFrom(const CXXRecordDecl* subtypeRecord, const CXXRecordDecl* baseRecord);
+
+bool ReferenceCasting::VisitCXXConstructExpr(const CXXConstructExpr* cce)
+{
+ // don't bother processing anything in the Reference.h file. Makes my life easier when debugging this.
+ StringRef aFileName = getFileNameOfSpellingLoc(
+ compiler.getSourceManager().getSpellingLoc(compat::getBeginLoc(cce)));
+ if (loplugin::isSamePathname(aFileName, SRCDIR "/include/com/sun/star/uno/Reference.h"))
+ return true;
+ if (loplugin::isSamePathname(aFileName, SRCDIR "/include/com/sun/star/uno/Reference.hxx"))
+ return true;
+
+ // look for calls to the Reference<T>(x, UNO_something) constructor
+ auto constructorClass = cce->getConstructor()->getParent();
+ if (!constructorClass->getIdentifier() || constructorClass->getName() != "Reference")
+ return true;
+
+ if (cce->getNumArgs() != 2)
+ return true;
+
+ if (CheckForUnnecessaryGet(cce->getArg(0)))
+ report(DiagnosticsEngine::Warning, "unnecessary get() call", compat::getBeginLoc(cce))
+ << cce->getSourceRange();
+
+ // ignore the up-casting constructor
+ if (!isa<EnumType>(cce->getConstructor()->getParamDecl(1)->getType()))
+ return true;
+
+ // extract the type parameter passed to the template
+ const RecordType* templateParamType = extractTemplateType(cce->getType().getTypePtr());
+ if (!templateParamType)
+ return true;
+
+ // extract the type of the first parameter passed to the constructor
+ const Expr* constructorArg0 = cce->getArg(0);
+ if (!constructorArg0)
+ return true;
+
+ // drill down the expression tree till we hit the bottom, because at the top, the type is BaseReference
+ const clang::Type* argType;
+ for (;;)
+ {
+ if (auto castExpr = dyn_cast<CastExpr>(constructorArg0))
+ {
+ constructorArg0 = castExpr->getSubExpr();
+ continue;
+ }
+ if (auto matTempExpr = dyn_cast<MaterializeTemporaryExpr>(constructorArg0))
+ {
+ constructorArg0 = matTempExpr->GetTemporaryExpr();
+ continue;
+ }
+ if (auto bindTempExpr = dyn_cast<CXXBindTemporaryExpr>(constructorArg0))
+ {
+ constructorArg0 = bindTempExpr->getSubExpr();
+ continue;
+ }
+ if (auto tempObjExpr = dyn_cast<CXXTemporaryObjectExpr>(constructorArg0))
+ {
+ constructorArg0 = tempObjExpr->getArg(0);
+ continue;
+ }
+ if (auto parenExpr = dyn_cast<ParenExpr>(constructorArg0))
+ {
+ constructorArg0 = parenExpr->getSubExpr();
+ continue;
+ }
+ argType = constructorArg0->getType().getTypePtr();
+ break;
+ }
+
+ const RecordType* argTemplateType = extractTemplateType(argType);
+ if (!argTemplateType)
+ return true;
+
+ CXXRecordDecl* templateParamRD = dyn_cast<CXXRecordDecl>(templateParamType->getDecl());
+ CXXRecordDecl* constructorArgRD = dyn_cast<CXXRecordDecl>(argTemplateType->getDecl());
+
+ // querying for XInterface (instead of doing an upcast) has special semantics,
+ // to check for UNO object equivalence.
+ if (templateParamRD->getName() == "XInterface")
+ return true;
+
+ // XShape is used in UNO aggregates in very "entertaining" ways, which means an UNO_QUERY
+ // can return a completely different object, e.g. see SwXShape::queryInterface
+ if (templateParamRD->getName() == "XShape")
+ return true;
+
+ if (auto declRefExpr = dyn_cast<DeclRefExpr>(cce->getArg(1)))
+ {
+ // no warning expected, used to reject null references
+ if (auto enumConstantDecl = dyn_cast<EnumConstantDecl>(declRefExpr->getDecl()))
+ {
+ if (enumConstantDecl->getName() == "UNO_SET_THROW")
+ return true;
+ if (enumConstantDecl->getName() == "UNO_QUERY_THROW")
+ return true;
+ if (enumConstantDecl->getName() == "SAL_NO_ACQUIRE")
+ return true;
+ }
+ }
+
+ if (constructorArgRD->Equals(templateParamRD)
+ || isDerivedFrom(constructorArgRD, templateParamRD))
+ {
+ report(DiagnosticsEngine::Warning,
+ "the source reference is already a subtype of the destination reference, just use =",
+ compat::getBeginLoc(cce))
+ << cce->getSourceRange();
+ }
+ return true;
+}
+
+bool ReferenceCasting::VisitCXXMemberCallExpr(const CXXMemberCallExpr* mce)
+{
+ // don't bother processing anything in the Reference.h file. Makes my life easier when debugging this.
+ StringRef aFileName = getFileNameOfSpellingLoc(
+ compiler.getSourceManager().getSpellingLoc(compat::getBeginLoc(mce)));
+ if (loplugin::isSamePathname(aFileName, SRCDIR "/include/com/sun/star/uno/Reference.h"))
+ return true;
+ if (loplugin::isSamePathname(aFileName, SRCDIR "/include/com/sun/star/uno/Reference.hxx"))
+ return true;
+
+ // look for calls to the Reference<T>.set(x, UNO_QUERY) constructor
+ auto method = mce->getMethodDecl();
+ if (!method || !method->getIdentifier() || method->getName() != "set")
+ return true;
+ if (mce->getNumArgs() != 2)
+ return true;
+
+ auto methodRecordDecl = dyn_cast<ClassTemplateSpecializationDecl>(mce->getRecordDecl());
+ if (!methodRecordDecl || !methodRecordDecl->getIdentifier()
+ || methodRecordDecl->getName() != "Reference")
+ return true;
+
+ if (CheckForUnnecessaryGet(mce->getArg(0)))
+ report(DiagnosticsEngine::Warning, "unnecessary get() call", compat::getBeginLoc(mce))
+ << mce->getSourceRange();
+
+ // extract the type parameter passed to the template
+ const RecordType* templateParamType
+ = dyn_cast<RecordType>(methodRecordDecl->getTemplateArgs()[0].getAsType());
+ if (!templateParamType)
+ return true;
+
+ // extract the type of the first parameter passed to the method
+ const Expr* arg0 = mce->getArg(0);
+ if (!arg0)
+ return true;
+
+ // drill down the expression tree till we hit the bottom, because at the top, the type is BaseReference
+ const clang::Type* argType;
+ for (;;)
+ {
+ if (auto castExpr = dyn_cast<CastExpr>(arg0))
+ {
+ arg0 = castExpr->getSubExpr();
+ continue;
+ }
+ if (auto matTempExpr = dyn_cast<MaterializeTemporaryExpr>(arg0))
+ {
+ arg0 = matTempExpr->GetTemporaryExpr();
+ continue;
+ }
+ if (auto bindTempExpr = dyn_cast<CXXBindTemporaryExpr>(arg0))
+ {
+ arg0 = bindTempExpr->getSubExpr();
+ continue;
+ }
+ if (auto tempObjExpr = dyn_cast<CXXTemporaryObjectExpr>(arg0))
+ {
+ arg0 = tempObjExpr->getArg(0);
+ continue;
+ }
+ if (auto parenExpr = dyn_cast<ParenExpr>(arg0))
+ {
+ arg0 = parenExpr->getSubExpr();
+ continue;
+ }
+ argType = arg0->getType().getTypePtr();
+ break;
+ }
+
+ const RecordType* argTemplateType = extractTemplateType(argType);
+ if (!argTemplateType)
+ return true;
+
+ CXXRecordDecl* templateParamRD = dyn_cast<CXXRecordDecl>(templateParamType->getDecl());
+ CXXRecordDecl* methodArgRD = dyn_cast<CXXRecordDecl>(argTemplateType->getDecl());
+
+ // querying for XInterface (instead of doing an upcast) has special semantics,
+ // to check for UNO object equivalence.
+ if (templateParamRD->getName() == "XInterface")
+ return true;
+
+ // XShape is used in UNO aggregates in very "entertaining" ways, which means an UNO_QUERY
+ // can return a completely different object, e.g. see SwXShape::queryInterface
+ if (templateParamRD->getName() == "XShape")
+ return true;
+
+ if (auto declRefExpr = dyn_cast<DeclRefExpr>(mce->getArg(1)))
+ {
+ // no warning expected, used to reject null references
+ if (auto enumConstantDecl = dyn_cast<EnumConstantDecl>(declRefExpr->getDecl()))
+ {
+ if (enumConstantDecl->getName() == "UNO_SET_THROW")
+ return true;
+ if (enumConstantDecl->getName() == "UNO_QUERY_THROW")
+ return true;
+ if (enumConstantDecl->getName() == "SAL_NO_ACQUIRE")
+ return true;
+ }
+ }
+
+ if (methodArgRD->Equals(templateParamRD) || isDerivedFrom(methodArgRD, templateParamRD))
+ {
+ report(DiagnosticsEngine::Warning,
+ "the source reference is already a subtype of the destination reference, just use =",
+ compat::getBeginLoc(mce))
+ << mce->getSourceRange();
+ }
+ return true;
+}
+
+/**
+ Check for
+ Reference<T>(x.get(), UNO_QUERY)
+ because sometimes simplifying that means the main purpose of this plugin can kick in.
+ */
+bool ReferenceCasting::CheckForUnnecessaryGet(const Expr* expr)
+{
+ expr = expr->IgnoreImplicit();
+ auto cxxMemberCallExpr = dyn_cast<CXXMemberCallExpr>(expr);
+ if (!cxxMemberCallExpr)
+ return false;
+ auto methodDecl = cxxMemberCallExpr->getMethodDecl();
+ if (!methodDecl)
+ return false;
+ if (!methodDecl->getIdentifier() || methodDecl->getName() != "get")
+ return false;
+
+ if (!loplugin::TypeCheck(expr->getType()).Pointer())
+ return false;
+ if (!loplugin::DeclCheck(methodDecl->getParent()).Class("Reference").Namespace("uno"))
+ return false;
+
+ StringRef aFileName = getFileNameOfSpellingLoc(
+ compiler.getSourceManager().getSpellingLoc(compat::getBeginLoc(expr)));
+ if (loplugin::isSamePathname(aFileName, SRCDIR "/cppu/qa/test_reference.cxx"))
+ return false;
+
+ return true;
+}
+
+static const RecordType* extractTemplateType(const clang::Type* cceType)
+{
+ // check for passing raw pointer to interface case
+ if (cceType->isPointerType())
+ {
+ auto pointeeType = cceType->getPointeeType();
+ if (auto elaboratedType = dyn_cast<ElaboratedType>(pointeeType))
+ pointeeType = elaboratedType->desugar();
+ if (auto recordType = dyn_cast<RecordType>(pointeeType))
+ return recordType;
+ }
+
+ if (auto elaboratedType = dyn_cast<ElaboratedType>(cceType))
+ cceType = elaboratedType->desugar().getTypePtr();
+ auto cceTST = dyn_cast<TemplateSpecializationType>(cceType);
+ if (!cceTST)
+ return NULL;
+ if (cceTST->getNumArgs() != 1)
+ return NULL;
+ const TemplateArgument& cceTA = cceTST->getArg(0);
+ const clang::Type* templateParamType = cceTA.getAsType().getTypePtr();
+ if (auto elaboratedType = dyn_cast<ElaboratedType>(templateParamType))
+ templateParamType = elaboratedType->desugar().getTypePtr();
+ return dyn_cast<RecordType>(templateParamType);
+}
+
+static int derivedFromCount(QualType qt, const CXXRecordDecl* baseRecord);
+
+static int derivedFromCount(const CXXRecordDecl* subtypeRecord, const CXXRecordDecl* baseRecord)
+{
+ if (!subtypeRecord->hasDefinition())
+ return 0;
+ int derivedCount = 0;
+ for (auto it = subtypeRecord->bases_begin(); it != subtypeRecord->bases_end(); ++it)
+ {
+ derivedCount += derivedFromCount(it->getType(), baseRecord);
+ if (derivedCount > 1)
+ return derivedCount;
+ }
+ for (auto it = subtypeRecord->vbases_begin(); it != subtypeRecord->vbases_end(); ++it)
+ {
+ derivedCount += derivedFromCount(it->getType(), baseRecord);
+ if (derivedCount > 1)
+ return derivedCount;
+ }
+ return derivedCount;
+}
+
+static int derivedFromCount(QualType qt, const CXXRecordDecl* baseRecord)
+{
+ int derivedCount = 0;
+ auto type = qt.getTypePtr();
+ if (auto elaboratedType = dyn_cast<ElaboratedType>(type))
+ type = elaboratedType->desugar().getTypePtr();
+ if (auto recordType = dyn_cast<RecordType>(type))
+ {
+ if (auto cxxRecordDecl = dyn_cast<CXXRecordDecl>(recordType->getDecl()))
+ {
+ if (cxxRecordDecl->Equals(baseRecord))
+ derivedCount++;
+ derivedCount += derivedFromCount(cxxRecordDecl, baseRecord);
+ }
+ }
+ return derivedCount;
+}
+
+/**
+ Implement my own isDerived because we can't always see all the definitions of the classes involved.
+ which will cause an assert with the normal clang isDerivedFrom code.
+*/
+static bool isDerivedFrom(const CXXRecordDecl* subtypeRecord, const CXXRecordDecl* baseRecord)
+{
+ // if there is more than one case, then we have an ambigous conversion, and we can't change the code
+ // to use the upcasting constructor.
+ return derivedFromCount(subtypeRecord, baseRecord) == 1;
+}
+
+loplugin::Plugin::Registration<ReferenceCasting> X2("referencecasting");
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/compilerplugins/clang/store/referencecasting.cxx b/compilerplugins/clang/store/referencecasting.cxx
deleted file mode 100644
index ed74b0b6e14a..000000000000
--- a/compilerplugins/clang/store/referencecasting.cxx
+++ /dev/null
@@ -1,195 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * Based on LLVM/Clang.
- *
- * This file is distributed under the University of Illinois Open Source
- * License. See LICENSE.TXT for details.
- *
- */
-
-#include "referencecasting.hxx"
-
-#include <clang/AST/Attr.h>
-#include <iostream>
-
-namespace loplugin
-{
-
-/*
-This is a compile-time checker.
-
-Check for cases where we have
- - two IDL interfaces A and B,
- - B extends A
- - we are converting a Reference<B> to a Reference<A>
-
-Note that it generates the occasional false positive.
-
-Also, it makes clang3.2 crash on about 4 files in the LO codebase.
-I have logged a bug here:
- http://llvm.org/bugs/show_bug.cgi?id=15902
-
-*/
-ReferenceCasting::ReferenceCasting( CompilerInstance& compiler )
- : FilteringPlugin( compiler )
-{
-}
-
-void ReferenceCasting::run()
-{
- TraverseDecl( compiler.getASTContext().getTranslationUnitDecl());
-}
-
-// This:
-// static void example_method()
-// {
-// css::uno::Reference<B> b;
-// css::uno::Reference<A>(b, css::uno::UNO_QUERY);
-// }
-// Compiles to this AST:
-// (CompoundStmt 0x205d430 </noel-extra1/libo-clang/compilerplugins/clang/noel1.cxx:17:1, line:20:1>
-// (DeclStmt 0x20580a8 <line:18:5, col:32>
-// (0x20530e0 "css::uno::Reference<B> refB =
-// (CXXConstructExpr 0x2058078 <col:28> 'css::uno::Reference<B>':'class com::sun::star::uno::Reference<class B>''void(void)')"))
-// (DeclStmt 0x205d418 <line:19:5, col:59>
-// (0x2058310 "css::uno::Reference<A> refA =
-// (CXXConstructExpr 0x205d3d8 <col:28, col:58> 'css::uno::Reference<A>':'class com::sun::star::uno::Reference<class A>''void (const class com::sun::star::uno::BaseReference &, enum com::sun::star::uno::UnoReference_Query)'
-// (ImplicitCastExpr 0x205d3c0 <col:33> 'const class com::sun::star::uno::BaseReference' lvalue <NoOp>
-// (ImplicitCastExpr 0x205d3a0 <col:33> 'class com::sun::star::uno::BaseReference' lvalue <DerivedToBase (BaseReference)>
-// (DeclRefExpr 0x20582a0 <col:33> 'css::uno::Reference<B>':'class com::sun::star::uno::Reference<class B>' lvalue Var 0x20530e0 'refB' 'css::uno::Reference<B>':'class com::sun::star::uno::Reference<class B>')))
-// (DeclRefExpr 0x2058398 <col:39, col:49> 'enum com::sun::star::uno::UnoReference_Query' EnumConstant 0x1831de0 'UNO_QUERY' 'enum com::sun::star::uno::UnoReference_Query'))")))
-//
-//
-// This:
-// static void example_method1(css::uno::Reference<A>)
-// {
-// }
-// static void example_method2()
-// {
-// css::uno::Reference<B> refB;
-// example_method1(css::uno::Reference<A>(refB, css::uno::UNO_QUERY));
-// }
-// Compiles to this AST:
-// static void example_method1(css::uno::Reference<A>) (CompoundStmt 0x2a74ee8 </noel-extra1/libo-clang/compilerplugins/clang/noel1.cxx:17:1, line:18:1>)
-// static void example_method2() (CompoundStmt 0x2a7a650 </noel-extra1/libo-clang/compilerplugins/clang/noel1.cxx:21:1, line:24:1>
-// (DeclStmt 0x2a7a1a8 <line:22:5, col:32>
-// (0x2a751e0 "css::uno::Reference<B> refB =
-// (CXXConstructExpr 0x2a7a178 <col:28> 'css::uno::Reference<B>':'class com::sun::star::uno::Reference<class B>''void(void)')"))
-// (ExprWithCleanups 0x2a7a638 <line:23:5, col:70> 'void'
-// (CallExpr 0x2a7a570 <col:5, col:70> 'void'
-// (ImplicitCastExpr 0x2a7a558 <col:5> 'void (*)(css::uno::Reference<A>)' <FunctionToPointerDecay>
-// (DeclRefExpr 0x2a7a4d8 <col:5> 'void (css::uno::Reference<A>)' lvalue Function 0x2a6ff00 'example_method1' 'void (css::uno::Reference<A>)'))
-// (CXXBindTemporaryExpr 0x2a7a618 <col:21, col:69> 'css::uno::Reference<A>':'class com::sun::star::uno::Reference<class A>' (CXXTemporary 0x2a7a610)
-// (CXXConstructExpr 0x2a7a5d8 <col:21, col:69> 'css::uno::Reference<A>':'class com::sun::star::uno::Reference<class A>''void (const Reference<class A> &)' elidable
-// (MaterializeTemporaryExpr 0x2a7a5c0 <col:21, col:69> 'const Reference<class A>':'const class com::sun::star::uno::Reference<class A>' lvalue
-// (ImplicitCastExpr 0x2a7a5a8 <col:21, col:69> 'const Reference<class A>':'const class com::sun::star::uno::Reference<class A>' <NoOp>
-// (CXXBindTemporaryExpr 0x2a7a4b8 <col:21, col:69> 'css::uno::Reference<A>':'class com::sun::star::uno::Reference<class A>' (CXXTemporary 0x2a7a4b0)
-// (CXXTemporaryObjectExpr 0x2a7a460 <col:21, col:69> 'css::uno::Reference<A>':'class com::sun::star::uno::Reference<class A>''void (const class com::sun::star::uno::BaseReference &, enum com::sun::star::uno::UnoReference_Query)'
-// (ImplicitCastExpr 0x2a7a448 <col:44> 'const class com::sun::star::uno::BaseReference' lvalue <NoOp>
-// (ImplicitCastExpr 0x2a7a428 <col:44> 'class com::sun::star::uno::BaseReference' lvalue <DerivedToBase (BaseReference)>
-// (DeclRefExpr 0x2a7a340 <col:44> 'css::uno::Reference<B>':'class com::sun::star::uno::Reference<class B>' lvalue Var 0x2a751e0 'refB' 'css::uno::Reference<B>':'class com::sun::star::uno::Reference<class B>')))
-// (DeclRefExpr 0x2a7a398 <col:50, col:60> 'enum com::sun::star::uno::UnoReference_Query' EnumConstant 0x224ee20 'UNO_QUERY' 'enum com::sun::star::uno::UnoReference_Query'))))))))))
-
-static const Type* extractTemplateType(Expr* cce);
-
-bool ReferenceCasting::VisitCXXConstructExpr( CXXConstructExpr* cce )
-{
- // don't bother processing anything in the Reference.h file. Makes my life easier when debugging this.
- if( StringRef(compiler.getSourceManager().getPresumedLoc( cce->getSourceRange().getBegin() )).find( "Reference.h" ) != StringRef::npos )
- return true;
-
- // look for calls to the Reference<T>(x,UNO_something) constructor
- if( cce->getConstructor()->getNameInfo().getName().getAsString() != "Reference" )
- return true;
-
- if( cce->getNumArgs() != 2 )
- return true;
-
- // extract the type parameter passed to the template
- const Type * templateParamType = extractTemplateType(cce);
- if ( !templateParamType )
- return true;
-
- // extract the type of the first parameter passed to the constructor
- Expr* constructorArg0 = cce->getArg(0);
- if( !constructorArg0 )
- return true;
-
- // ignore the Reference(XInterface*,...) constructor
- if( constructorArg0->getType()->isPointerType() )
- return true;
-
- // drill down the expression tree till we hit the bottom
- DeclRefExpr* constructorSubArg2;
- Expr* constructorArg0SubExpr = constructorArg0;
- for(;;)
- {
- // if we've hit the member expression we want, break
- constructorSubArg2 = dyn_cast<DeclRefExpr>( constructorArg0SubExpr );
- if( constructorSubArg2 )
- break;
- CastExpr* tmp1 = dyn_cast<CastExpr>( constructorArg0SubExpr );
- if( tmp1 ) {
- constructorArg0SubExpr = tmp1->getSubExpr();
- continue;
- }
- MaterializeTemporaryExpr* tmp2 = dyn_cast<MaterializeTemporaryExpr>( constructorArg0SubExpr );
- if( tmp2 ) {
- constructorArg0SubExpr = tmp2->GetTemporaryExpr();
- continue;
- }
- CXXBindTemporaryExpr* tmp3 = dyn_cast<CXXBindTemporaryExpr>( constructorArg0SubExpr );
- if( tmp3 ) {
- constructorArg0SubExpr = tmp3->getSubExpr();
- continue;
- }
- CXXTemporaryObjectExpr* tmp4 = dyn_cast<CXXTemporaryObjectExpr>( constructorArg0SubExpr );
- if( tmp4 ) {
- constructorArg0SubExpr = tmp4->getArg(0);
- continue;
- }
- return true;
- }
-
- const Type * tmp3 = extractTemplateType( constructorSubArg2 );
- if ( !tmp3 )
- return true;
-
- const RecordType* templateParamRT = dyn_cast<RecordType>( templateParamType );
- const RecordType* constructorArgRT = dyn_cast<RecordType>( tmp3 );
- if( !templateParamRT || !constructorArgRT )
- return true;
-
- CXXRecordDecl* templateParamRD = dyn_cast<CXXRecordDecl>( templateParamRT->getDecl() );
- CXXRecordDecl* constructorArgRD = dyn_cast<CXXRecordDecl>( constructorArgRT->getDecl() );
-
- if (constructorArgRD->Equals(templateParamRD) || constructorArgRD->isDerivedFrom(templateParamRD))
- report( DiagnosticsEngine::Warning,
- "the source reference is already a subtype of the destination reference",
- cce->getLocStart()) // and the exact position where the message should point
- << cce->getSourceRange(); // and the full return statement to highlight (optional)
-
- return true;
-}
-
-static const Type* extractTemplateType(Expr* cce)
-{
- QualType cceQT = cce->getType();
- const Type* cceType = cceQT.getTypePtr();
- const TemplateSpecializationType* cceTST = dyn_cast<TemplateSpecializationType>( cceType );
- if( !cceTST )
- return NULL;
- if( cceTST->getNumArgs() != 1 )
- return NULL;
- const TemplateArgument & cceTA = cceTST->getArg(0);
- QualType templateParamQT = cceTA.getAsType();
- return templateParamQT.getTypePtr();
-}
-
-static Plugin::Registration< ReferenceCasting > X( "referencecasting" );
-
-} // namespace
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/compilerplugins/clang/store/referencecasting.hxx b/compilerplugins/clang/store/referencecasting.hxx
deleted file mode 100644
index 3c41b773e0f0..000000000000
--- a/compilerplugins/clang/store/referencecasting.hxx
+++ /dev/null
@@ -1,33 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * Based on LLVM/Clang.
- *
- * This file is distributed under the University of Illinois Open Source
- * License. See LICENSE.TXT for details.
- *
- */
-
-#ifndef REFERENCECASTING_H
-#define REFERENCECASTING_H
-
-#include "plugin.hxx"
-
-namespace loplugin
-{
-
-class ReferenceCasting
- : public FilteringPlugin< ReferenceCasting >
- {
- public:
- explicit ReferenceCasting( CompilerInstance& compiler );
- virtual void run() override;
- bool VisitCXXConstructExpr( CXXConstructExpr* cce );
- };
-
-} // namespace
-
-#endif // REFERENCECASTING_H
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/compilerplugins/clang/test/referencecasting.cxx b/compilerplugins/clang/test/referencecasting.cxx
new file mode 100644
index 000000000000..87324bb86fd6
--- /dev/null
+++ b/compilerplugins/clang/test/referencecasting.cxx
@@ -0,0 +1,150 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include "sal/config.h"
+
+#include "com/sun/star/uno/XInterface.hpp"
+#include "com/sun/star/io/XStreamListener.hpp"
+#include "com/sun/star/lang/XTypeProvider.hpp"
+#include "com/sun/star/lang/XComponent.hpp"
+#include "cppuhelper/weak.hxx"
+
+void test1(const css::uno::Reference<css::io::XStreamListener>& a)
+{
+ // expected-error@+1 {{the source reference is already a subtype of the destination reference, just use = [loplugin:referencecasting]}}
+ css::uno::Reference<css::lang::XEventListener> b(a, css::uno::UNO_QUERY);
+}
+
+namespace test2
+{
+css::uno::Reference<css::io::XStreamListener> getListener();
+
+void test()
+{
+ // expected-error@+1 {{the source reference is already a subtype of the destination reference, just use = [loplugin:referencecasting]}}
+ css::uno::Reference<css::lang::XEventListener> b(getListener(), css::uno::UNO_QUERY);
+}
+}
+
+namespace test3
+{
+void callListener(css::uno::Reference<css::uno::XInterface> const&);
+
+void test(css::uno::Reference<css::io::XStreamListener> const& l)
+{
+ // expected-error@+1 {{the source reference is already a subtype of the destination reference, just use = [loplugin:referencecasting]}}
+ callListener(css::uno::Reference<css::lang::XEventListener>(l, css::uno::UNO_QUERY));
+}
+}
+
+void test4(const css::uno::Reference<css::io::XStreamListener>& a)
+{
+ // no warning expected, used to reject null references
+ css::uno::Reference<css::lang::XEventListener> b(a, css::uno::UNO_SET_THROW);
+}
+
+// no warning expected
+namespace test5
+{
+void test(css::uno::Reference<css::io::XStreamListener> l)
+{
+ css::uno::Reference<css::uno::XInterface> a = l;
+}
+}
+
+namespace test6
+{
+void test(css::uno::Reference<css::io::XStreamListener> l)
+{
+ css::uno::Reference<css::lang::XEventListener> a;
+ // expected-error@+1 {{the source reference is already a subtype of the destination reference, just use = [loplugin:referencecasting]}}
+ a.set(l, css::uno::UNO_QUERY);
+}
+}
+
+namespace test7
+{
+void test(css::uno::Reference<css::io::XStreamListener> l)
+{
+ // expected-error@+1 {{unnecessary get() call [loplugin:referencecasting]}}
+ css::uno::Reference<css::lang::XEventListener> a(l.get(), css::uno::UNO_QUERY);
+ // expected-error@+1 {{unnecessary get() call [loplugin:referencecasting]}}
+ a.set(l.get(), css::uno::UNO_QUERY);
+}
+}
+
+namespace test8
+{
+void test(css::io::XStreamListener* l)
+{
+ // expected-error@+1 {{the source reference is already a subtype of the destination reference, just use = [loplugin:referencecasting]}}
+ css::uno::Reference<css::lang::XEventListener> a(l, css::uno::UNO_QUERY);
+ // expected-error@+1 {{the source reference is already a subtype of the destination reference, just use = [loplugin:referencecasting]}}
+ a.set(l, css::uno::UNO_QUERY);
+}
+}
+
+// check for looking through casts
+namespace test9
+{
+class StatusbarController : public css::io::XStreamListener, public ::cppu::OWeakObject
+{
+};
+
+void test(StatusbarController* pController)
+{
+ css::uno::Reference<css::io::XStreamListener> xController;
+ // expected-error@+1 {{the source reference is already a subtype of the destination reference, just use = [loplugin:referencecasting]}}
+ xController.set(static_cast<::cppu::OWeakObject*>(pController), css::uno::UNO_QUERY);
+}
+}
+
+// no warning expected when we have an ambiguous base
+namespace test10
+{
+class Foo : public css::lang::XTypeProvider, public css::lang::XComponent
+{
+ virtual ~Foo();
+ void bar()
+ {
+ css::uno::Reference<css::lang::XEventListener> xSource(
+ static_cast<css::lang::XTypeProvider*>(this), css::uno::UNO_QUERY);
+ }
+};
+}
+
+// no warning expected for SAL_NO_ACQUIRE
+namespace test11
+{
+void test(css::io::XStreamListener* l)
+{
+ css::uno::Reference<css::lang::XEventListener> a(l, SAL_NO_ACQUIRE);
+ a.set(l, SAL_NO_ACQUIRE);
+}
+}
+
+// no warning expected: querying for XInterface (instead of doing an upcast) has special semantics,
+// to check for UNO object equivalence.
+void test12(const css::uno::Reference<css::io::XStreamListener>& a)
+{
+ css::uno::Reference<css::uno::XInterface> b(a, css::uno::UNO_QUERY);
+}
+
+// no warning expected: querying for XInterface (instead of doing an upcast) has special semantics,
+// to check for UNO object equivalence.
+struct Test13
+{
+ css::uno::Reference<css::uno::XInterface> m_xNormalizedIFace;
+ void newObject(const css::uno::Reference<css::uno::XInterface>& _rxIFace)
+ {
+ m_xNormalizedIFace.set(_rxIFace, css::uno::UNO_QUERY);
+ }
+};
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/solenv/CompilerTest_compilerplugins_clang.mk b/solenv/CompilerTest_compilerplugins_clang.mk
index c3a9054a6931..d70c41faead6 100644
--- a/solenv/CompilerTest_compilerplugins_clang.mk
+++ b/solenv/CompilerTest_compilerplugins_clang.mk
@@ -48,6 +48,7 @@ $(eval $(call gb_CompilerTest_add_exception_objects,compilerplugins_clang, \
compilerplugins/clang/test/redundantinline \
compilerplugins/clang/test/redundantpointerops \
compilerplugins/clang/test/refcounting \
+ compilerplugins/clang/test/referencecasting \
compilerplugins/clang/test/salbool \
compilerplugins/clang/test/salcall \
compilerplugins/clang/test/sallogareas \
diff --git a/sw/qa/extras/accessibility/accessible_relation_set.cxx b/sw/qa/extras/accessibility/accessible_relation_set.cxx
index b544096a37f1..9efcc8ec060c 100644
--- a/sw/qa/extras/accessibility/accessible_relation_set.cxx
+++ b/sw/qa/extras/accessibility/accessible_relation_set.cxx
@@ -55,8 +55,6 @@ AccessibilityTools::getAccessibleObjectForRole(
if ((ac->getAccessibleRole() == role) && isShowing)
{
- css::uno::Reference<css::accessibility::XAccessible> SearchedAccessible(xacc,
- uno::UNO_QUERY);
return ac;
}
else
diff --git a/sw/qa/extras/globalfilter/globalfilter.cxx b/sw/qa/extras/globalfilter/globalfilter.cxx
index 92c64c878a38..f9a8acf615f4 100644
--- a/sw/qa/extras/globalfilter/globalfilter.cxx
+++ b/sw/qa/extras/globalfilter/globalfilter.cxx
@@ -109,7 +109,7 @@ void Test::testEmbeddedGraphicRoundtrip()
// Check whether graphic exported well after it was swapped out
uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
- uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY);
+ uno::Reference<container::XIndexAccess> xDraws = xDrawPageSupplier->getDrawPage();
const OString sFailedMessage = OString("Failed on filter: ") + rFilterName.toUtf8();
CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), static_cast<sal_Int32>(2), xDraws->getCount());
@@ -246,7 +246,7 @@ void Test::testImageWithSpecialID()
// Check whether graphic exported well
uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
- uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY);
+ uno::Reference<container::XIndexAccess> xDraws = xDrawPageSupplier->getDrawPage();
const OString sFailedMessage = OString("Failed on filter: ") + rFilterName.toUtf8();
CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), static_cast<sal_Int32>(2), xDraws->getCount());
@@ -344,7 +344,7 @@ void Test::testGraphicShape()
// Check whether graphic exported well
uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
- uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY);
+ uno::Reference<container::XIndexAccess> xDraws = xDrawPageSupplier->getDrawPage();
const OString sFailedMessage = OString("Failed on filter: ") + rFilterName.toUtf8();
CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), static_cast<sal_Int32>(2), xDraws->getCount());
@@ -801,7 +801,7 @@ void Test::testSkipImages()
// Check shapes (images, textboxes, custom shapes)
uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
- uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY);
+ uno::Reference<container::XIndexAccess> xDraws = xDrawPageSupplier->getDrawPage();
uno::Reference<drawing::XShape> xShape;
uno::Reference<graphic::XGraphic> xGraphic;
uno::Reference< beans::XPropertySet > XPropSet;
diff --git a/sw/qa/extras/mailmerge/mailmerge.cxx b/sw/qa/extras/mailmerge/mailmerge.cxx
index 6c5a2de4d495..139a13a24dd7 100644
--- a/sw/qa/extras/mailmerge/mailmerge.cxx
+++ b/sw/qa/extras/mailmerge/mailmerge.cxx
@@ -126,7 +126,7 @@ public:
uno::Reference< sdbc::XRowSet > xRowSet( xInstance, uno::UNO_QUERY );
if (xRowSet.is())
xRowSet->execute(); // build ResultSet from properties
- xCurResultSet.set( xRowSet, uno::UNO_QUERY );
+ xCurResultSet = xRowSet;
assert( xCurResultSet.is() && "failed to build ResultSet" );
}
return xCurResultSet;
@@ -366,7 +366,7 @@ DECLARE_SHELL_MAILMERGE_TEST(testMultiPageAnchoredDraws, "multiple-page-anchored
CPPUNIT_ASSERT_EQUAL(sal_uInt16(8), nPhysPages);
uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxMMComponent, uno::UNO_QUERY);
- uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY);
+ uno::Reference<container::XIndexAccess> xDraws = xDrawPageSupplier->getDrawPage();
CPPUNIT_ASSERT_EQUAL(sal_Int32(8), xDraws->getCount());
std::set<sal_uInt16> pages;
@@ -393,7 +393,7 @@ DECLARE_FILE_MAILMERGE_TEST(testMissingDefaultLineColor, "missing-default-line-c
// The document was created by LO version which didn't write out the default value for line color
// (see XMLGraphicsDefaultStyle::SetDefaults()).
uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
- uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY);
+ uno::Reference<container::XIndexAccess> xDraws = xDrawPageSupplier->getDrawPage();
uno::Reference<beans::XPropertySet> xPropertySet(xDraws->getByIndex(0), uno::UNO_QUERY);
// Lines do not have a line color.
CPPUNIT_ASSERT( !xPropertySet->getPropertySetInfo()->hasPropertyByName( "LineColor" ));
@@ -700,7 +700,7 @@ DECLARE_SHELL_MAILMERGE_TEST(testTdf118113, "tdf118113.odt", "tdf118113.ods", "t
// verify that there is a text box for each data record
uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxMMComponent, uno::UNO_QUERY);
- uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY);
+ uno::Reference<container::XIndexAccess> xDraws = xDrawPageSupplier->getDrawPage();
CPPUNIT_ASSERT_EQUAL(sal_Int32(4), xDraws->getCount());
// verify the text box for each data record is anchored to the first page of the given data record's pages
diff --git a/sw/qa/extras/odfexport/odfexport.cxx b/sw/qa/extras/odfexport/odfexport.cxx
index 0d7253924d50..99d6d8059c59 100644
--- a/sw/qa/extras/odfexport/odfexport.cxx
+++ b/sw/qa/extras/odfexport/odfexport.cxx
@@ -575,7 +575,7 @@ DECLARE_ODFEXPORT_TEST(testFdo79358, "fdo79358.odt")
{
// the boolean properties of the index were not exported properly
uno::Reference<text::XDocumentIndexesSupplier> xIndexSupplier(mxComponent, uno::UNO_QUERY);
- uno::Reference<container::XIndexAccess> xIndexes(xIndexSupplier->getDocumentIndexes(), uno::UNO_QUERY);
+ uno::Reference<container::XIndexAccess> xIndexes = xIndexSupplier->getDocumentIndexes();
uno::Reference<text::XDocumentIndex> xTOCIndex(xIndexes->getByIndex(0), uno::UNO_QUERY);
uno::Reference<beans::XPropertySet> xTOCProps(xTOCIndex, uno::UNO_QUERY);
CPPUNIT_ASSERT_EQUAL(false, getProperty<bool>(xTOCProps, "CreateFromOutline"));
@@ -637,8 +637,8 @@ DECLARE_ODFEXPORT_TEST(testDuplicateCrossRefHeadingBookmark, "CrossRefHeadingBoo
uno::Reference<text::XBookmarksSupplier> xBookmarksSupplier(mxComponent,
uno::UNO_QUERY);
- uno::Reference<container::XNameAccess> xBookmarks(
- xBookmarksSupplier->getBookmarks(), uno::UNO_QUERY);
+ uno::Reference<container::XNameAccess> xBookmarks =
+ xBookmarksSupplier->getBookmarks();
uno::Reference<text::XTextContent> xBookmark1(
xBookmarks->getByName("__RefHeading__8284_1826734303"), uno::UNO_QUERY);
CPPUNIT_ASSERT(xBookmark1.is());
@@ -721,7 +721,7 @@ DECLARE_ODFEXPORT_TEST(testStylePageNumber, "ooo321_stylepagenumber.odt")
CPPUNIT_ASSERT_EQUAL(OUString("Right Page"), getProperty<OUString>(xPara0, "PageDescName"));
CPPUNIT_ASSERT_EQUAL(uno::Any(), xPara0->getPropertyValue("PageNumberOffset"));
- uno::Reference<container::XNameAccess> xParaStyles(getStyles("ParagraphStyles"), uno::UNO_QUERY);
+ uno::Reference<container::XNameAccess> xParaStyles = getStyles("ParagraphStyles");
uno::Reference<beans::XPropertySet> xStyle1(xParaStyles->getByName("stylewithbreak1"), uno::UNO_QUERY);
CPPUNIT_ASSERT_EQUAL(OUString("Right Page"), getProperty<OUString>(xStyle1, "PageDescName"));
CPPUNIT_ASSERT_EQUAL(sal_Int16(1), getProperty<sal_Int16>(xStyle1, "PageNumberOffset"));
@@ -864,7 +864,7 @@ DECLARE_ODFEXPORT_TEST(testCharacterBorder, "charborder.odt")
// Check character style
{
- uno::Reference< container::XNameAccess > xStyleFamily(getStyles("CharacterStyles"), uno::UNO_QUERY);
+ uno::Reference< container::XNameAccess > xStyleFamily = getStyles("CharacterStyles");
uno::Reference < beans::XPropertySet > xStyleSet(xStyleFamily->getByName("CharDiffBor"), uno::UNO_QUERY);
// Top border
@@ -1149,8 +1149,8 @@ DECLARE_ODFEXPORT_TEST(testWhitespace, "whitespace.odt")
// what a stupid idea to require recursively enumerating this
uno::Reference<container::XEnumerationAccess> xMeta(
getProperty<uno::Reference<text::XTextContent>>(xPortion, "InContentMetadata"), uno::UNO_QUERY);
- uno::Reference<container::XEnumeration> xMetaPortions(
- xMeta->createEnumeration(), uno::UNO_QUERY);
+ uno::Reference<container::XEnumeration> xMetaPortions =
+ xMeta->createEnumeration();
uno::Reference<text::XTextRange> xMP(xMetaPortions->nextElement(), uno::UNO_QUERY);
CPPUNIT_ASSERT_EQUAL(OUString("Text"), getProperty<OUString>(xMP, "TextPortionType"));
CPPUNIT_ASSERT_EQUAL(OUString(" "), xMP->getString());
@@ -1172,8 +1172,8 @@ DECLARE_ODFEXPORT_TEST(testWhitespace, "whitespace.odt")
// what a stupid idea to require recursively enumerating this
uno::Reference<container::XEnumerationAccess> xMeta(
getProperty<uno::Reference<text::XTextContent>>(xPortion, "TextField"), uno::UNO_QUERY);
- uno::Reference<container::XEnumeration> xMetaPortions(
- xMeta->createEnumeration(), uno::UNO_QUERY);
+ uno::Reference<container::XEnumeration> xMetaPortions =
+ xMeta->createEnumeration();
uno::Reference<text::XTextRange> xMP(xMetaPortions->nextElement(), uno::UNO_QUERY);
CPPUNIT_ASSERT_EQUAL(OUString("Text"), getProperty<OUString>(xMP, "TextPortionType"));
CPPUNIT_ASSERT_EQUAL(OUString(" "), xMP->getString());
@@ -2139,7 +2139,7 @@ DECLARE_ODFEXPORT_TEST(tdf101856_overlapped, "tdf101856_overlapped.odt")
// get bookmark interface
uno::Reference<text::XBookmarksSupplier> xBookmarksSupplier(mxComponent, uno::UNO_QUERY);
uno::Reference<container::XIndexAccess> xBookmarksByIdx(xBookmarksSupplier->getBookmarks(), uno::UNO_QUERY);
- uno::Reference<container::XNameAccess> xBookmarksByName(xBookmarksSupplier->getBookmarks(), uno::UNO_QUERY);
+ uno::Reference<container::XNameAccess> xBookmarksByName = xBookmarksSupplier->getBookmarks();
// check: we have 2 bookmarks
CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(2), xBookmarksByIdx->getCount());
@@ -2163,7 +2163,7 @@ DECLARE_ODFEXPORT_TEST(tdf101856, "tdf101856.odt")
// get bookmark interface
uno::Reference<text::XBookmarksSupplier> xBookmarksSupplier(mxComponent, uno::UNO_QUERY);
uno::Reference<container::XIndexAccess> xBookmarksByIdx(xBookmarksSupplier->getBookmarks(), uno::UNO_QUERY);
- uno::Reference<container::XNameAccess> xBookmarksByName(xBookmarksSupplier->getBookmarks(), uno::UNO_QUERY);
+ uno::Reference<container::XNameAccess> xBookmarksByName = xBookmarksSupplier->getBookmarks();
// check: we have 2 bookmarks
CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(5), xBookmarksByIdx->getCount());
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx
index 60263001baf1..50fca6cb0dfa 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx
@@ -346,7 +346,7 @@ DECLARE_OOXMLEXPORT_TEST(testFdo69649, "fdo69649.docx")
uno::Reference<text::XDocumentIndexesSupplier> xIndexSupplier(mxComponent, uno::UNO_QUERY);
uno::Reference<container::XIndexAccess> xIndexes = xIndexSupplier->getDocumentIndexes( );
uno::Reference<text::XDocumentIndex> xTOCIndex(xIndexes->getByIndex(0), uno::UNO_QUERY);
- uno::Reference<text::XTextRange> xTextRange(xTOCIndex->getAnchor(), uno::UNO_QUERY);
+ uno::Reference<text::XTextRange> xTextRange = xTOCIndex->getAnchor();
uno::Reference<text::XText> xText = xTextRange->getText( );
uno::Reference<text::XTextCursor> xTextCursor = xText->createTextCursor( );
xTextCursor->gotoRange(xTextRange->getStart(),false);
@@ -721,7 +721,7 @@ DECLARE_OOXMLEXPORT_TEST(testHidemark, "hidemark.docx")
uno::Reference<text::XTextTablesSupplier> xTablesSupplier(mxComponent, uno::UNO_QUERY);
uno::Reference<container::XIndexAccess> xTables(xTablesSupplier->getTextTables( ), uno::UNO_QUERY);
uno::Reference<text::XTextTable> xTextTable(xTables->getByIndex(0), uno::UNO_QUERY);
- uno::Reference<table::XTableRows> xTableRows(xTextTable->getRows(), uno::UNO_QUERY);
+ uno::Reference<table::XTableRows> xTableRows = xTextTable->getRows();
// Height should be minimal
CPPUNIT_ASSERT_EQUAL(convertTwipToMm100(MINLAY), getProperty<sal_Int64>(xTableRows->getByIndex(1), "Height"));
// Size type was MIN, should be FIX to avoid considering the end of paragraph marker.
@@ -737,7 +737,7 @@ DECLARE_OOXMLEXPORT_TEST(testHidemarkb, "tdf99616_hidemarkb.docx")
uno::Reference<text::XTextTablesSupplier> xTablesSupplier(mxComponent, uno::UNO_QUERY);
uno::Reference<container::XIndexAccess> xTables(xTablesSupplier->getTextTables( ), uno::UNO_QUERY);
uno::Reference<text::XTextTable> xTextTable(xTables->getByIndex(0), uno::UNO_QUERY);
- uno::Reference<table::XTableRows> xTableRows(xTextTable->getRows(), uno::UNO_QUERY);
+ uno::Reference<table::XTableRows> xTableRows = xTextTable->getRows();
// Height should be .5cm
CPPUNIT_ASSERT_EQUAL(sal_Int64(501), getProperty<sal_Int64>(xTableRows->getByIndex(1), "Height"));
// Size type was MIN, should be FIX to avoid considering the end of paragraph marker.
@@ -770,29 +770,28 @@ DECLARE_OOXMLEXPORT_TEST(testFdo85542, "fdo85542.docx")
uno::Reference<text::XBookmarksSupplier> xBookmarksSupplier(mxComponent, uno::UNO_QUERY);
uno::Reference<container::XIndexAccess> xBookmarksByIdx(xBookmarksSupplier->getBookmarks(), uno::UNO_QUERY);
CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(3), xBookmarksByIdx->getCount());
- uno::Reference<container::XNameAccess> xBookmarksByName(xBookmarksSupplier->getBookmarks(), uno::UNO_QUERY);
+ uno::Reference<container::XNameAccess> xBookmarksByName = xBookmarksSupplier->getBookmarks();
CPPUNIT_ASSERT(xBookmarksByName->hasByName("B1"));
CPPUNIT_ASSERT(xBookmarksByName->hasByName("B2"));
CPPUNIT_ASSERT(xBookmarksByName->hasByName("B3"));
// B1
uno::Reference<text::XTextContent> xContent1(xBookmarksByName->getByName("B1"), uno::UNO_QUERY);
- uno::Reference<text::XTextRange> xRange1(xContent1->getAnchor(), uno::UNO_QUERY);
+ uno::Reference<text::XTextRange> xRange1 = xContent1->getAnchor();
CPPUNIT_ASSERT_EQUAL(OUString("ABB"), xRange1->getString());
// B2
uno::Reference<text::XTextContent> xContent2(xBookmarksByName->getByName("B2"), uno::UNO_QUERY);
- uno::Reference<text::XTextRange> xRange2(xContent2->getAnchor(), uno::UNO_QUERY);
+ uno::Reference<text::XTextRange> xRange2 = xContent2->getAnchor();
CPPUNIT_ASSERT_EQUAL(OUString("BBC"), xRange2->getString());
// B3 -- testing a collapsed bookmark
uno::Reference<text::XTextContent> xContent3(xBookmarksByName->getByName("B3"), uno::UNO_QUERY);
- uno::Reference<text::XTextRange> xRange3(xContent3->getAnchor(), uno::UNO_QUERY);
+ uno::Reference<text::XTextRange> xRange3 = xContent3->getAnchor();
CPPUNIT_ASSERT_EQUAL(xRange3->getString(), OUString());
- uno::Reference<text::XText> xText(xRange3->getText( ), uno::UNO_QUERY);
- uno::Reference<text::XTextCursor> xNeighborhoodCursor(xText->createTextCursor( ), uno::UNO_QUERY);
+ uno::Reference<text::XText> xText = xRange3->getText( );
+ uno::Reference<text::XTextCursor> xNeighborhoodCursor = xText->createTextCursor( );
xNeighborhoodCursor->gotoRange(xRange3, false);
xNeighborhoodCursor->goLeft(1, false);
xNeighborhoodCursor->goRight(2, true);
- uno::Reference<text::XTextRange> xTextNeighborhood(xNeighborhoodCursor, uno::UNO_QUERY);
- CPPUNIT_ASSERT_EQUAL(OUString("AB"), xTextNeighborhood->getString());
+ CPPUNIT_ASSERT_EQUAL(OUString("AB"), xNeighborhoodCursor->getString());
}
DECLARE_OOXMLEXPORT_TEST(testTdf65955, "tdf65955.odt")
@@ -800,16 +799,16 @@ DECLARE_OOXMLEXPORT_TEST(testTdf65955, "tdf65955.odt")
uno::Reference<text::XBookmarksSupplier> xBookmarksSupplier(mxComponent, uno::UNO_QUERY);
uno::Reference<container::XIndexAccess> xBookmarksByIdx(xBookmarksSupplier->getBookmarks(), uno::UNO_QUERY);
CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(2), xBookmarksByIdx->getCount());
- uno::Reference<container::XNameAccess> xBookmarksByName(xBookmarksSupplier->getBookmarks(), uno::UNO_QUERY);
+ uno::Reference<container::XNameAccess> xBookmarksByName = xBookmarksSupplier->getBookmarks();
CPPUNIT_ASSERT(xBookmarksByName->hasByName("a"));
CPPUNIT_ASSERT(xBookmarksByName->hasByName("b"));
// a
uno::Reference<text::XTextContent> xContent3(xBookmarksByName->getByName("a"), uno::UNO_QUERY);
- uno::Reference<text::XTextRange> xRange3(xContent3->getAnchor(), uno::UNO_QUERY);
+ uno::Reference<text::XTextRange> xRange3 = xContent3->getAnchor();
CPPUNIT_ASSERT_EQUAL(xRange3->getString(), OUString());
// b
uno::Reference<text::XTextContent> xContent2(xBookmarksByName->getByName("b"), uno::UNO_QUERY);
- uno::Reference<text::XTextRange> xRange2(xContent2->getAnchor(), uno::UNO_QUERY);
+ uno::Reference<text::XTextRange> xRange2 = xContent2->getAnchor();
CPPUNIT_ASSERT_EQUAL(OUString("r"), xRange2->getString());
}
@@ -818,11 +817,11 @@ DECLARE_OOXMLEXPORT_TEST(testTdf65955_2, "tdf65955_2.odt")
uno::Reference<text::XBookmarksSupplier> xBookmarksSupplier(mxComponent, uno::UNO_QUERY);
uno::Reference<container::XIndexAccess> xBookmarksByIdx(xBookmarksSupplier->getBookmarks(), uno::UNO_QUERY);
CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1), xBookmarksByIdx->getCount());
- uno::Reference<container::XNameAccess> xBookmarksByName(xBookmarksSupplier->getBookmarks(), uno::UNO_QUERY);
+ uno::Reference<container::XNameAccess> xBookmarksByName = xBookmarksSupplier->getBookmarks();
CPPUNIT_ASSERT(xBookmarksByName->hasByName("test"));
uno::Reference<text::XTextContent> xContent3(xBookmarksByName->getByName("test"), uno::UNO_QUERY);
- uno::Reference<text::XTextRange> xRange3(xContent3->getAnchor(), uno::UNO_QUERY);
+ uno::Reference<text::XTextRange> xRange3 = xContent3->getAnchor();
CPPUNIT_ASSERT_EQUAL(OUString("foo bar"), xRange3->getString());
}
@@ -879,7 +878,7 @@ DECLARE_OOXMLEXPORT_TEST(testTdf87460, "tdf87460.docx")
DECLARE_OOXMLEXPORT_TEST(testTdf90611, "tdf90611.docx")
{
uno::Reference<text::XFootnotesSupplier> xFootnotesSupplier(mxComponent, uno::UNO_QUERY);
- uno::Reference<container::XIndexAccess> xFootnotes(xFootnotesSupplier->getFootnotes(), uno::UNO_QUERY);
+ uno::Reference<container::XIndexAccess> xFootnotes = xFootnotesSupplier->getFootnotes();
uno::Reference<text::XText> xFootnoteText;
xFootnotes->getByIndex(0) >>= xFootnoteText;
// This was 11.
@@ -905,7 +904,7 @@ DECLARE_OOXMLEXPORT_TEST(testTdf86374, "tdf86374.docx")
uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY);
uno::Reference<container::XIndexAccess> xTables(xTextTablesSupplier->getTextTables(), uno::UNO_QUERY);
uno::Reference<text::XTextTable> xTable(xTables->getByIndex(0), uno::UNO_QUERY);
- uno::Reference<table::XTableRows> xTableRows(xTable->getRows(), uno::UNO_QUERY);
+ uno::Reference<table::XTableRows> xTableRows = xTable->getRows();
// btLr text direction was imported as FIX, it should be MIN to have enough space for the additionally entered paragraphs.
CPPUNIT_ASSERT_EQUAL(text::SizeType::MIN, getProperty<sal_Int16>(xTableRows->getByIndex(0), "SizeType"));
}
@@ -1022,7 +1021,7 @@ DECLARE_OOXMLEXPORT_TEST(testTdf91417, "tdf91417.docx")
{
// The first paragraph should contain a link to "http://www.google.com/"
uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
- uno::Reference<text::XTextCursor> xTextCursor(xTextDocument->getText()->createTextCursor( ), uno::UNO_QUERY);
+ uno::Reference<text::XTextCursor> xTextCursor = xTextDocument->getText()->createTextCursor( );
uno::Reference<beans::XPropertySet> xCursorProps(xTextCursor, uno::UNO_QUERY);
OUString aValue;
xCursorProps->getPropertyValue("HyperLinkURL") >>= aValue;
@@ -1033,7 +1032,7 @@ DECLARE_OOXMLEXPORT_TEST(testTdf90810, "tdf90810short.docx")
{
uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
uno::Reference<text::XFootnotesSupplier> xFootnoteSupp(xTextDocument, uno::UNO_QUERY);
- uno::Reference<container::XIndexAccess> xFootnoteIdxAcc(xFootnoteSupp->getFootnotes(), uno::UNO_QUERY);
+ uno::Reference<container::XIndexAccess> xFootnoteIdxAcc = xFootnoteSupp->getFootnotes();
uno::Reference<text::XFootnote> xFootnote(xFootnoteIdxAcc->getByIndex(0), uno::UNO_QUERY);
uno::Reference<text::XText> xFootnoteText(xFootnote, uno::UNO_QUERY);
OUString sFootnoteText = xFootnoteText->getString();
@@ -1053,7 +1052,7 @@ DECLARE_OOXMLEXPORT_TEST(testTdf95777, "tdf95777.docx")
DECLARE_OOXMLEXPORT_TEST(testTdf94374, "hello.docx")
{
uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
- uno::Reference<text::XTextRange> xText(xTextDocument->getText(), uno::UNO_QUERY);
+ uno::Reference<text::XTextRange> xText = xTextDocument->getText();
uno::Reference<text::XTextRange> xEnd = xText->getEnd();
// This failed: it wasn't possible to insert a DOCX document into an existing Writer one.
CPPUNIT_ASSERT(paste("tdf94374.docx", xEnd));
@@ -1205,7 +1204,7 @@ DECLARE_OOXMLEXPORT_TEST( testTablePosition14, "table-position-14.docx" )
uno::Reference< view::XSelectionSupplier > xCtrl( xModel->getCurrentController(), uno::UNO_QUERY );
xCtrl->select( uno::makeAny( xTable1 ) );
uno::Reference< text::XTextViewCursorSupplier > xTextViewCursorSupplier( xCtrl, uno::UNO_QUERY );
- uno::Reference< text::XTextViewCursor > xCursor( xTextViewCursorSupplier->getViewCursor(), uno::UNO_QUERY );
+ uno::Reference< text::XTextViewCursor > xCursor = xTextViewCursorSupplier->getViewCursor();
awt::Point pos = xCursor->getPosition();
CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE( "Incorrect X coord computed from docx",
aXCoordsFromOffice[i], pos.X, 1 );
@@ -1229,7 +1228,7 @@ DECLARE_OOXMLEXPORT_TEST( testTablePosition15, "table-position-15.docx" )
uno::Reference< view::XSelectionSupplier > xCtrl( xModel->getCurrentController(), uno::UNO_QUERY );
xCtrl->select( uno::makeAny( xTable1 ) );
uno::Reference< text::XTextViewCursorSupplier > xTextViewCursorSupplier( xCtrl, uno::UNO_QUERY );
- uno::Reference< text::XTextViewCursor > xCursor( xTextViewCursorSupplier->getViewCursor(), uno::UNO_QUERY );
+ uno::Reference< text::XTextViewCursor > xCursor = xTextViewCursorSupplier->getViewCursor();
awt::Point pos = xCursor->getPosition();
CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE( "Incorrect X coord computed from docx",
aXCoordsFromOffice[i], pos.X, 1 );
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx
index e4c60af21ea9..04c7bead9830 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx
@@ -149,7 +149,7 @@ DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testTdf121561_tocTitle, "tdf121456_tabsOffse
DECLARE_OOXMLEXPORT_TEST(testTdf124106, "tdf121456.docx")
{
uno::Reference<text::XTextDocument> textDocument(mxComponent, uno::UNO_QUERY);
- uno::Reference<text::XText> text(textDocument->getText(), uno::UNO_QUERY);
+ uno::Reference<text::XText> text = textDocument->getText();
// -1 if the 'Y' character does not occur
CPPUNIT_ASSERT_EQUAL(sal_Int32(-1), text->getString().indexOf('Y'));
CPPUNIT_ASSERT_EQUAL(sal_Int32(-1), text->getString().indexOf('y'));
@@ -161,7 +161,7 @@ DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testTdf121561_tocTitleDocx, "tdf121456_tabsO
// get TOC node
uno::Reference<text::XDocumentIndexesSupplier> xIndexSupplier(mxComponent, uno::UNO_QUERY);
- uno::Reference<container::XIndexAccess> xIndexes(xIndexSupplier->getDocumentIndexes( ), uno::UNO_QUERY);
+ uno::Reference<container::XIndexAccess> xIndexes = xIndexSupplier->getDocumentIndexes( );
uno::Reference<text::XDocumentIndex> xTOCIndex(xIndexes->getByIndex(0), uno::UNO_QUERY);
// ensure TOC title was set in TOC properties
@@ -510,7 +510,7 @@ DECLARE_OOXMLEXPORT_TEST(testTdf104354, "tdf104354.docx")
DECLARE_OOXMLEXPORT_TEST(testTdf104354_firstParaInSection, "tdf104354_firstParaInSection.docx")
{
uno::Reference<text::XFootnotesSupplier> xFootnotesSupplier(mxComponent, uno::UNO_QUERY);
- uno::Reference<container::XIndexAccess> xFootnotes(xFootnotesSupplier->getFootnotes(), uno::UNO_QUERY);
+ uno::Reference<container::XIndexAccess> xFootnotes = xFootnotesSupplier->getFootnotes();
uno::Reference<text::XText> xText(xFootnotes->getByIndex(0), uno::UNO_QUERY);
CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(494),
getProperty<sal_Int32>(getParagraphOfText(1, xText), "ParaTopMargin"));
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport12.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport12.cxx
index 87b1a4cfd37f..1c973369902b 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport12.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport12.cxx
@@ -354,8 +354,7 @@ DECLARE_OOXMLEXPORT_TEST(testObjectCrossReference, "object_cross_reference.odt")
uno::Reference<container::XIndexAccess> xBookmarksByIdx(xBookmarksSupplier->getBookmarks(),
uno::UNO_QUERY);
CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(15), xBookmarksByIdx->getCount());
- uno::Reference<container::XNameAccess> xBookmarksByName(xBookmarksSupplier->getBookmarks(),
- uno::UNO_QUERY);
+ uno::Reference<container::XNameAccess> xBookmarksByName = xBookmarksSupplier->getBookmarks();
CPPUNIT_ASSERT(xBookmarksByName->hasByName("Ref_Drawing0_full"));
CPPUNIT_ASSERT(xBookmarksByName->hasByName("Ref_Drawing0_label_and_number"));
CPPUNIT_ASSERT(xBookmarksByName->hasByName("Ref_Drawing0_caption_only"));
@@ -379,31 +378,31 @@ DECLARE_OOXMLEXPORT_TEST(testObjectCrossReference, "object_cross_reference.odt")
{
uno::Reference<text::XTextContent> xContent(
xBookmarksByName->getByName("Ref_Drawing0_full"), uno::UNO_QUERY);
- uno::Reference<text::XTextRange> xRange(xContent->getAnchor(), uno::UNO_QUERY);
+ uno::Reference<text::XTextRange> xRange = xContent->getAnchor();
CPPUNIT_ASSERT_EQUAL(OUString("Drawing 1: A rectangle"), xRange->getString());
}
{
uno::Reference<text::XTextContent> xContent(
xBookmarksByName->getByName("Ref_Drawing0_label_and_number"), uno::UNO_QUERY);
- uno::Reference<text::XTextRange> xRange(xContent->getAnchor(), uno::UNO_QUERY);
+ uno::Reference<text::XTextRange> xRange = xContent->getAnchor();
CPPUNIT_ASSERT_EQUAL(OUString("Drawing 1"), xRange->getString());
}
{
uno::Reference<text::XTextContent> xContent(
xBookmarksByName->getByName("Ref_Drawing0_caption_only"), uno::UNO_QUERY);
- uno::Reference<text::XTextRange> xRange(xContent->getAnchor(), uno::UNO_QUERY);
+ uno::Reference<text::XTextRange> xRange = xContent->getAnchor();
CPPUNIT_ASSERT_EQUAL(OUString("A rectangle"), xRange->getString());
}
{
uno::Reference<text::XTextContent> xContent(
xBookmarksByName->getByName("Ref_Drawing0_number_only"), uno::UNO_QUERY);
- uno::Reference<text::XTextRange> xRange(xContent->getAnchor(), uno::UNO_QUERY);
+ uno::Reference<text::XTextRange> xRange = xContent->getAnchor();
CPPUNIT_ASSERT_EQUAL(OUString("1"), xRange->getString());
}
{
uno::Reference<text::XTextContent> xContent(
xBookmarksByName->getByName("Ref_Drawing1_full"), uno::UNO_QUERY);
- uno::Reference<text::XTextRange> xRange(xContent->getAnchor(), uno::UNO_QUERY);
+ uno::Reference<text::XTextRange> xRange = xContent->getAnchor();
CPPUNIT_ASSERT_EQUAL(OUString("Drawing 2: a circle"), xRange->getString());
}
@@ -411,31 +410,31 @@ DECLARE_OOXMLEXPORT_TEST(testObjectCrossReference, "object_cross_reference.odt")
{
uno::Reference<text::XTextContent> xContent(
xBookmarksByName->getByName("Ref_Illustration0_full"), uno::UNO_QUERY);
- uno::Reference<text::XTextRange> xRange(xContent->getAnchor(), uno::UNO_QUERY);
+ uno::Reference<text::XTextRange> xRange = xContent->getAnchor();
CPPUNIT_ASSERT_EQUAL(OUString("Illustration 1: A picture"), xRange->getString());
}
{
uno::Reference<text::XTextContent> xContent(
xBookmarksByName->getByName("Ref_Illustration0_label_and_number"), uno::UNO_QUERY);
- uno::Reference<text::XTextRange> xRange(xContent->getAnchor(), uno::UNO_QUERY);
+ uno::Reference<text::XTextRange> xRange = xContent->getAnchor();
CPPUNIT_ASSERT_EQUAL(OUString("Illustration 1"), xRange->getString());
}
{
uno::Reference<text::XTextContent> xContent(
xBookmarksByName->getByName("Ref_Illustration0_caption_only"), uno::UNO_QUERY);
- uno::Reference<text::XTextRange> xRange(xContent->getAnchor(), uno::UNO_QUERY);
+ uno::Reference<text::XTextRange> xRange = xContent->getAnchor();
CPPUNIT_ASSERT_EQUAL(OUString("A picture"), xRange->getString());
}
{
uno::Reference<text::XTextContent> xContent(
xBookmarksByName->getByName("Ref_Illustration0_number_only"), uno::UNO_QUERY);
- uno::Reference<text::XTextRange> xRange(xContent->getAnchor(), uno::UNO_QUERY);
+ uno::Reference<text::XTextRange> xRange = xContent->getAnchor();
CPPUNIT_ASSERT_EQUAL(OUString("1"), xRange->getString());
}
{
uno::Reference<text::XTextContent> xContent(
xBookmarksByName->getByName("Ref_Illustration1_caption_only"), uno::UNO_QUERY);
- uno::Reference<text::XTextRange> xRange(xContent->getAnchor(), uno::UNO_QUERY);
+ uno::Reference<text::XTextRange> xRange = xContent->getAnchor();
CPPUNIT_ASSERT_EQUAL(OUString("an other image"), xRange->getString());
}
@@ -443,31 +442,31 @@ DECLARE_OOXMLEXPORT_TEST(testObjectCrossReference, "object_cross_reference.odt")
{
uno::Reference<text::XTextContent> xContent(xBookmarksByName->getByName("Ref_Text0_full"),
uno::UNO_QUERY);
- uno::Reference<text::XTextRange> xRange(xContent->getAnchor(), uno::UNO_QUERY);
+ uno::Reference<text::XTextRange> xRange = xContent->getAnchor();
CPPUNIT_ASSERT_EQUAL(OUString("Text 1: A frame"), xRange->getString());
}
{
uno::Reference<text::XTextContent> xContent(
xBookmarksByName->getByName("Ref_Text0_label_and_number"), uno::UNO_QUERY);
- uno::Reference<text::XTextRange> xRange(xContent->getAnchor(), uno::UNO_QUERY);
+ uno::Reference<text::XTextRange> xRange = xContent->getAnchor();
CPPUNIT_ASSERT_EQUAL(OUString("Text 1"), xRange->getString());
}
{
uno::Reference<text::XTextContent> xContent(
xBookmarksByName->getByName("Ref_Text0_caption_only"), uno::UNO_QUERY);
- uno::Reference<text::XTextRange> xRange(xContent->getAnchor(), uno::UNO_QUERY);
+ uno::Reference<text::XTextRange> xRange = xContent->getAnchor();
CPPUNIT_ASSERT_EQUAL(OUString("A frame"), xRange->getString());
}
{
uno::Reference<text::XTextContent> xContent(
xBookmarksByName->getByName("Ref_Text0_number_only"), uno::UNO_QUERY);
- uno::Reference<text::XTextRange> xRange(xContent->getAnchor(), uno::UNO_QUERY);
+ uno::Reference<text::XTextRange> xRange = xContent->getAnchor();
CPPUNIT_ASSERT_EQUAL(OUString("1"), xRange->getString());
}
{
uno::Reference<text::XTextContent> xContent(
xBookmarksByName->getByName("Ref_Text1_label_and_number"), uno::UNO_QUERY);
- uno::Reference<text::XTextRange> xRange(xContent->getAnchor(), uno::UNO_QUERY);
+ uno::Reference<text::XTextRange> xRange = xContent->getAnchor();
CPPUNIT_ASSERT_EQUAL(OUString("Text 2"), xRange->getString());
}
@@ -763,8 +762,7 @@ DECLARE_OOXMLEXPORT_TEST(testTdf120224_textControlCrossRef, "tdf120224_textContr
uno::Reference<text::XBookmarksSupplier> xBookmarksSupplier(mxComponent, uno::UNO_QUERY);
uno::Reference<container::XIndexAccess> xBookmarksByIdx(xBookmarksSupplier->getBookmarks(),
uno::UNO_QUERY);
- uno::Reference<container::XNameAccess> xBookmarksByName(xBookmarksSupplier->getBookmarks(),
- uno::UNO_QUERY);
+ uno::Reference<container::XNameAccess> xBookmarksByName = xBookmarksSupplier->getBookmarks();
// TextFields should not be turned into real bookmarks.
CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1), xBookmarksByIdx->getCount());
@@ -786,7 +784,7 @@ DECLARE_OOXMLEXPORT_TEST(testTdf117504_numberingIndent, "tdf117504_numberingInde
DECLARE_OOXMLEXPORT_TEST(testWatermark, "watermark.docx")
{
- uno::Reference<drawing::XShape> xShape(getShape(1), uno::UNO_QUERY);
+ uno::Reference<drawing::XShape> xShape = getShape(1);
uno::Reference<beans::XPropertySet> xPropertySet(xShape, uno::UNO_QUERY);
sal_Int32 nHeight = xShape->getSize().Height;
@@ -801,7 +799,7 @@ DECLARE_OOXMLEXPORT_TEST(testWatermark, "watermark.docx")
DECLARE_OOXMLEXPORT_TEST(testWatermarkTrim, "tdf114308.docx")
{
- uno::Reference<drawing::XShape> xShape(getShape(1), uno::UNO_QUERY);
+ uno::Reference<drawing::XShape> xShape = getShape(1);
// Rounding errors
sal_Int32 nHeight = xShape->getSize().Height;
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
index b0201deb2cd5..3fc5effa1d87 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
@@ -682,7 +682,7 @@ DECLARE_OOXMLEXPORT_TEST(testTdf112446_frameStyle, "tdf112446_frameStyle.docx")
DECLARE_OOXMLEXPORT_TEST(testTdf82173_footnoteStyle, "tdf82173_footnoteStyle.docx")
{
uno::Reference<text::XFootnotesSupplier> xFootnotesSupplier(mxComponent, uno::UNO_QUERY);
- uno::Reference<container::XIndexAccess> xFootnotes(xFootnotesSupplier->getFootnotes(), uno::UNO_QUERY);
+ uno::Reference<container::XIndexAccess> xFootnotes = xFootnotesSupplier->getFootnotes();
uno::Reference<text::XText> xFootnoteText;
xFootnotes->getByIndex(0) >>= xFootnoteText;
@@ -705,7 +705,7 @@ DECLARE_OOXMLEXPORT_TEST(testTdf82173_footnoteStyle, "tdf82173_footnoteStyle.doc
DECLARE_OOXMLEXPORT_TEST(testTdf82173_endnoteStyle, "tdf82173_endnoteStyle.docx")
{
uno::Reference<text::XEndnotesSupplier> xEndnotesSupplier(mxComponent, uno::UNO_QUERY);
- uno::Reference<container::XIndexAccess> xEndnotes(xEndnotesSupplier->getEndnotes(), uno::UNO_QUERY);
+ uno::Reference<container::XIndexAccess> xEndnotes = xEndnotesSupplier->getEndnotes();
uno::Reference<text::XFootnote> xEndnote;
xEndnotes->getByIndex(0) >>= xEndnote;
// character properties were previously not assigned to the footnote/endnote in-text anchor.
@@ -743,10 +743,10 @@ DECLARE_OOXMLEXPORT_TEST(testTdf55427_footnote2endnote, "tdf55427_footnote2endno
CPPUNIT_ASSERT_EQUAL_MESSAGE( "Endnote numbering type", SVX_NUM_ROMAN_LOWER, pDoc->GetEndNoteInfo().aFormat.GetNumberingType() );
uno::Reference<text::XFootnotesSupplier> xFootnotesSupplier(mxComponent, uno::UNO_QUERY);
- uno::Reference<container::XIndexAccess> xFootnotes(xFootnotesSupplier->getFootnotes(), uno::UNO_QUERY);
+ uno::Reference<container::XIndexAccess> xFootnotes = xFootnotesSupplier->getFootnotes();
uno::Reference<text::XEndnotesSupplier> xEndnotesSupplier(mxComponent, uno::UNO_QUERY);
- uno::Reference<container::XIndexAccess> xEndnotes(xEndnotesSupplier->getEndnotes(), uno::UNO_QUERY);
+ uno::Reference<container::XIndexAccess> xEndnotes = xEndnotesSupplier->getEndnotes();
uno::Reference<text::XFootnote> xEndnote;
xEndnotes->getByIndex(0) >>= xEndnote;
uno::Reference<text::XText> xEndnoteText;
@@ -980,7 +980,7 @@ DECLARE_OOXMLEXPORT_TEST(testTdf100075, "tdf100075.docx")
DECLARE_OOXMLEXPORT_TEST(testTdf105095, "tdf105095.docx")
{
uno::Reference<text::XFootnotesSupplier> xFootnotesSupplier(mxComponent, uno::UNO_QUERY);
- uno::Reference<container::XIndexAccess> xFootnotes(xFootnotesSupplier->getFootnotes(), uno::UNO_QUERY);
+ uno::Reference<container::XIndexAccess> xFootnotes = xFootnotesSupplier->getFootnotes();
uno::Reference<text::XTextRange> xTextRange(xFootnotes->getByIndex(0), uno::UNO_QUERY);
// This failed, tab between the footnote number and the footnote content
// was lost on import.
@@ -990,7 +990,7 @@ DECLARE_OOXMLEXPORT_TEST(testTdf105095, "tdf105095.docx")
DECLARE_OOXMLEXPORT_TEST(testTdf106062_nonHangingFootnote, "tdf106062_nonHangingFootnote.odt")
{
uno::Reference<text::XFootnotesSupplier> xFootnotesSupplier(mxComponent, uno::UNO_QUERY);
- uno::Reference<container::XIndexAccess> xFootnotes(xFootnotesSupplier->getFootnotes(), uno::UNO_QUERY);
+ uno::Reference<container::XIndexAccess> xFootnotes = xFootnotesSupplier->getFootnotes();
uno::Reference<text::XTextRange> xTextRange(xFootnotes->getByIndex(0), uno::UNO_QUERY);
// This failed, tab between the footnote number and the footnote content was lost on import.
CPPUNIT_ASSERT_MESSAGE( "Footnote starts with a tab", xTextRange->getString().startsWith("\t") );
@@ -1265,7 +1265,7 @@ DECLARE_OOXMLEXPORT_TEST(testTdf90789, "tdf90789.docx")
uno::Reference<text::XTextViewCursorSupplier> xTextViewCursorSupplier(xCtrl, uno::UNO_QUERY_THROW);
uno::Reference<text::XTextViewCursor> xTextCursor(xTextViewCursorSupplier->getViewCursor(), uno::UNO_SET_THROW);
- uno::Reference<text::XPageCursor> xPageCursor(xTextCursor.get(), uno::UNO_QUERY_THROW);
+ uno::Reference<text::XPageCursor> xPageCursor(xTextCursor, uno::UNO_QUERY_THROW);
CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16>(1), xPageCursor->getPage());
}
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
index e9901a72cba7..4799a44db8c4 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
@@ -94,13 +94,11 @@ public:
{
OUString aURL(m_directories.getURLFromSrc(mpTestDocumentPath) + OUString::createFromAscii(filename));
CPPUNIT_ASSERT_MESSAGE("no desktop", mxDesktop.is());
- uno::Reference<frame::XComponentLoader> xLoader(mxDesktop, uno::UNO_QUERY);
- CPPUNIT_ASSERT_MESSAGE("no loader", xLoader.is());
uno::Sequence<beans::PropertyValue> args( comphelper::InitPropertySequence({
{ "DocumentService", uno::Any(OUString("com.sun.star.text.TextDocument")) }
}));
- uno::Reference<lang::XComponent> xComponent = xLoader->loadComponentFromURL(aURL, "_default", 0, args);
+ uno::Reference<lang::XComponent> xComponent = mxDesktop->loadComponentFromURL(aURL, "_default", 0, args);
OUString sMessage = "loading succeeded: " + aURL;
CPPUNIT_ASSERT_MESSAGE(OUStringToOString(sMessage, RTL_TEXTENCODING_UTF8).getStr(), !xComponent.is());
}
@@ -492,7 +490,7 @@ DECLARE_OOXMLIMPORT_TEST(testN780645, "n780645.docx")
uno::Reference<text::XTextTablesSupplier> xTablesSupplier(mxComponent, uno::UNO_QUERY);
uno::Reference<container::XIndexAccess> xTables(xTablesSupplier->getTextTables( ), uno::UNO_QUERY);
uno::Reference<text::XTextTable> xTextTable(xTables->getByIndex(0), uno::UNO_QUERY);
- uno::Reference<table::XTableRows> xTableRows(xTextTable->getRows(), uno::UNO_QUERY);
+ uno::Reference<table::XTableRows> xTableRows = xTextTable->getRows();
CPPUNIT_ASSERT_EQUAL(sal_Int16(2135), getProperty< uno::Sequence<text::TableColumnSeparator> >(xTableRows->getByIndex(1), "TableColumnSeparators")[0].Position); // was 1999
}
@@ -503,7 +501,7 @@ DECLARE_OOXMLIMPORT_TEST(testWordArtResizing, "WordArt.docx")
The test-case ensures the original height and width of the word-art is not changed while importing*/
uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
- uno::Reference<container::XIndexAccess> xDrawPage(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY);
+ uno::Reference<container::XIndexAccess> xDrawPage = xDrawPageSupplier->getDrawPage();
CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xDrawPage->getCount());
uno::Reference<drawing::XShape> xShape(xDrawPage->getByIndex(0), uno::UNO_QUERY);
@@ -525,7 +523,7 @@ DECLARE_OOXMLIMPORT_TEST(testGroupshapeLine, "groupshape-line.docx")
* xray ThisComponent.DrawPage(1).getByIndex(0).Size 'width: 10160, height: 0
*/
uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
- uno::Reference<container::XIndexAccess> xDrawPage(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY);
+ uno::Reference<container::XIndexAccess> xDrawPage = xDrawPageSupplier->getDrawPage();
CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xDrawPage->getCount());
uno::Reference<drawing::XShape> xShape(xDrawPage->getByIndex(0), uno::UNO_QUERY);
@@ -588,7 +586,7 @@ DECLARE_OOXMLIMPORT_TEST(testN820788, "n820788.docx")
DECLARE_OOXMLIMPORT_TEST(testN820504, "n820504.docx")
{
uno::Reference<style::XStyleFamiliesSupplier> xFamiliesSupplier(mxComponent, uno::UNO_QUERY);
- uno::Reference<container::XNameAccess> xFamiliesAccess(xFamiliesSupplier->getStyleFamilies(), uno::UNO_QUERY);
+ uno::Reference<container::XNameAccess> xFamiliesAccess = xFamiliesSupplier->getStyleFamilies();
uno::Reference<container::XNameAccess> xStylesAccess(xFamiliesAccess->getByName("ParagraphStyles"), uno::UNO_QUERY);
uno::Reference<beans::XPropertySet> xStyle(xStylesAccess->getByName("Default Style"), uno::UNO_QUERY);
// The problem was that the CharColor was set to AUTO (-1) even if we have some default char color set
@@ -726,7 +724,7 @@ DECLARE_OOXMLIMPORT_TEST(testTdf75573_lostTable, "tdf75573_lostTable.docx")
CPPUNIT_ASSERT_EQUAL_MESSAGE("# of tables", sal_Int32(1), xTables->getCount() );
uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
- uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY);
+ uno::Reference<container::XIndexAccess> xDraws = xDrawPageSupplier->getDrawPage();
CPPUNIT_ASSERT_EQUAL_MESSAGE("# of frames/shapes", sal_Int32(0), xDraws->getCount() );
CPPUNIT_ASSERT_EQUAL_MESSAGE("# of pages", 3, getPages() );
@@ -1072,7 +1070,7 @@ DECLARE_OOXMLIMPORT_TEST(testTdf85232, "tdf85232.docx")
{
uno::Reference<drawing::XShapes> xShapes(getShapeByName("Group 219"), uno::UNO_QUERY);
uno::Reference<drawing::XShape> xShape(xShapes->getByIndex(1), uno::UNO_QUERY);
- uno::Reference<drawing::XShapeDescriptor> xShapeDescriptor(xShape, uno::UNO_QUERY);
+ uno::Reference<drawing::XShapeDescriptor> xShapeDescriptor = xShape;
// Make sure we're not testing the ellipse child.
CPPUNIT_ASSERT_EQUAL(OUString("com.sun.star.drawing.LineShape"), xShapeDescriptor->getShapeType());
@@ -1159,7 +1157,7 @@ DECLARE_OOXMLIMPORT_TEST(testTdf95970, "tdf95970.docx")
DECLARE_OOXMLIMPORT_TEST(testTdf96674, "tdf96674.docx")
{
- uno::Reference<drawing::XShape> xShape(getShape(1), uno::UNO_QUERY);
+ uno::Reference<drawing::XShape> xShape = getShape(1);
CPPUNIT_ASSERT(xShape.is());
awt::Size aActualSize(xShape->getSize());
// Width was 3493: the vertical line was horizontal.
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx
index 3c7154ec3016..d664d78e6d33 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx
@@ -348,10 +348,9 @@ DECLARE_OOXMLIMPORT_TEST(testTdf115094, "tdf115094.docx")
// anchor of graphic has to be the text in the text frame
// xray ThisComponent.DrawPage(1).Anchor.Text
uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
- uno::Reference<container::XIndexAccess> xDrawPage(xDrawPageSupplier->getDrawPage(),
- uno::UNO_QUERY);
+ uno::Reference<container::XIndexAccess> xDrawPage = xDrawPageSupplier->getDrawPage();
uno::Reference<text::XTextContent> xShape(xDrawPage->getByIndex(1), uno::UNO_QUERY);
- uno::Reference<text::XTextRange> xText1(xShape->getAnchor()->getText(), uno::UNO_QUERY);
+ uno::Reference<text::XTextRange> xText1 = xShape->getAnchor()->getText();
// xray ThisComponent.TextTables(0).getCellByName("A1")
uno::Reference<text::XTextTablesSupplier> xTablesSupplier(mxComponent, uno::UNO_QUERY);
diff --git a/sw/qa/extras/rtfimport/rtfimport.cxx b/sw/qa/extras/rtfimport/rtfimport.cxx
index 45a54092454e..316cfc06f7d5 100644
--- a/sw/qa/extras/rtfimport/rtfimport.cxx
+++ b/sw/qa/extras/rtfimport/rtfimport.cxx
@@ -71,8 +71,7 @@ DECLARE_RTFIMPORT_TEST(testN695479, "n695479.rtf")
getProperty<sal_Int32>(xPropertySet, "Height"));
uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
- uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(),
- uno::UNO_QUERY);
+ uno::Reference<container::XIndexAccess> xDraws = xDrawPageSupplier->getDrawPage();
bool bFrameFound = false, bDrawFound = false;
for (int i = 0; i < xDraws->getCount(); ++i)
{
@@ -82,8 +81,8 @@ DECLARE_RTFIMPORT_TEST(testN695479, "n695479.rtf")
// Both frames should be anchored to the first paragraph.
bFrameFound = true;
uno::Reference<text::XTextContent> xTextContent(xServiceInfo, uno::UNO_QUERY);
- uno::Reference<text::XTextRange> xRange(xTextContent->getAnchor(), uno::UNO_QUERY);
- uno::Reference<text::XText> xText(xRange->getText(), uno::UNO_QUERY);
+ uno::Reference<text::XTextRange> xRange = xTextContent->getAnchor();
+ uno::Reference<text::XText> xText = xRange->getText();
CPPUNIT_ASSERT_EQUAL(OUString("plain"), xText->getString());
if (i == 0)
@@ -191,8 +190,7 @@ DECLARE_RTFIMPORT_TEST(testTdf108951, "tdf108951.rtf")
DECLARE_RTFIMPORT_TEST(testFdo47036, "fdo47036.rtf")
{
uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
- uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(),
- uno::UNO_QUERY);
+ uno::Reference<container::XIndexAccess> xDraws = xDrawPageSupplier->getDrawPage();
int nAtCharacter = 0;
for (int i = 0; i < xDraws->getCount(); ++i)
{
@@ -213,8 +211,7 @@ DECLARE_RTFIMPORT_TEST(testFdo47036, "fdo47036.rtf")
DECLARE_RTFIMPORT_TEST(testFdo45182, "fdo45182.rtf")
{
uno::Reference<text::XFootnotesSupplier> xFootnotesSupplier(mxComponent, uno::UNO_QUERY);
- uno::Reference<container::XIndexAccess> xFootnotes(xFootnotesSupplier->getFootnotes(),
- uno::UNO_QUERY);
+ uno::Reference<container::XIndexAccess> xFootnotes = xFootnotesSupplier->getFootnotes();
uno::Reference<text::XTextRange> xTextRange(xFootnotes->getByIndex(0), uno::UNO_QUERY);
// Encoding in the footnote was wrong.
OUString aExpected(u"\u017Eivnost\u00ED" SAL_NEWLINE_STRING);
@@ -331,7 +328,7 @@ DECLARE_RTFIMPORT_TEST(testFdo52066, "fdo52066.rtf")
*
* xray ThisComponent.DrawPage(0).Size.Height
*/
- uno::Reference<drawing::XShape> xShape(getShape(1), uno::UNO_QUERY);
+ uno::Reference<drawing::XShape> xShape = getShape(1);
CPPUNIT_ASSERT_EQUAL(sal_Int32(convertTwipToMm100(19)), xShape->getSize().Height);
}
@@ -354,8 +351,7 @@ DECLARE_RTFIMPORT_TEST(testTdf122430, "tdf122430.rtf")
DECLARE_RTFIMPORT_TEST(testFdo49892, "fdo49892.rtf")
{
uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
- uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(),
- uno::UNO_QUERY);
+ uno::Reference<container::XIndexAccess> xDraws = xDrawPageSupplier->getDrawPage();
for (int i = 0; i < xDraws->getCount(); ++i)
{
OUString aDescription = getProperty<OUString>(xDraws->getByIndex(i), "Description");
@@ -422,7 +418,7 @@ DECLARE_RTFIMPORT_TEST(testInk, "ink.rtf")
DECLARE_RTFIMPORT_TEST(testFdo79319, "fdo79319.rtf")
{
// the thin horizontal rule was imported as a big fat rectangle
- uno::Reference<drawing::XShape> xShape(getShape(1), uno::UNO_QUERY);
+ uno::Reference<drawing::XShape> xShape = getShape(1);
CPPUNIT_ASSERT_EQUAL(sal_Int16(100), getProperty<sal_Int16>(xShape, "RelativeWidth"));
CPPUNIT_ASSERT_DOUBLES_EQUAL(sal_Int32(15238), xShape->getSize().Width, 10);
CPPUNIT_ASSERT_DOUBLES_EQUAL(sal_Int32(53), xShape->getSize().Height, 10);
@@ -449,7 +445,7 @@ DECLARE_RTFIMPORT_TEST(testFdo55525, "fdo55525.rtf")
// Negative left margin was ~missing, -191
CPPUNIT_ASSERT_EQUAL(sal_Int32(-1877), getProperty<sal_Int32>(xTable, "LeftMargin"));
// Cell width of A1 was 3332 (e.g. not set, 30% percent of total width)
- uno::Reference<table::XTableRows> xTableRows(xTable->getRows(), uno::UNO_QUERY);
+ uno::Reference<table::XTableRows> xTableRows = xTable->getRows();
CPPUNIT_ASSERT_EQUAL(sal_Int16(896), getProperty<uno::Sequence<text::TableColumnSeparator>>(
xTableRows->getByIndex(0), "TableColumnSeparators")[0]
.Position);
@@ -460,8 +456,7 @@ DECLARE_RTFIMPORT_TEST(testFdo57708, "fdo57708.rtf")
// There were two issues: the doc was of 2 pages and the picture was missing.
CPPUNIT_ASSERT_EQUAL(1, getPages());
uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
- uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(),
- uno::UNO_QUERY);
+ uno::Reference<container::XIndexAccess> xDraws = xDrawPageSupplier->getDrawPage();
// Two objects: a picture and a textframe.
CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xDraws->getCount());
}
@@ -486,7 +481,7 @@ DECLARE_RTFIMPORT_TEST(testFdo59953, "fdo59953.rtf")
uno::UNO_QUERY);
uno::Reference<text::XTextTable> xTable(xTables->getByIndex(0), uno::UNO_QUERY);
// Cell width of A1 was 4998 (e.g. not set / not wide enough, ~50% of total width)
- uno::Reference<table::XTableRows> xTableRows(xTable->getRows(), uno::UNO_QUERY);
+ uno::Reference<table::XTableRows> xTableRows = xTable->getRows();
CPPUNIT_ASSERT_EQUAL(sal_Int16(7649), getProperty<uno::Sequence<text::TableColumnSeparator>>(
xTableRows->getByIndex(0), "TableColumnSeparators")[0]
.Position);
@@ -624,8 +619,7 @@ DECLARE_RTFIMPORT_TEST(testN823675, "n823675.rtf")
DECLARE_RTFIMPORT_TEST(testGroupshape, "groupshape.rtf")
{
uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
- uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(),
- uno::UNO_QUERY);
+ uno::Reference<container::XIndexAccess> xDraws = xDrawPageSupplier->getDrawPage();
// There should be a single groupshape with 2 children.
CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xDraws->getCount());
uno::Reference<drawing::XShapes> xGroupshape(xDraws->getByIndex(0), uno::UNO_QUERY);
@@ -635,8 +629,7 @@ DECLARE_RTFIMPORT_TEST(testGroupshape, "groupshape.rtf")
DECLARE_RTFIMPORT_TEST(testGroupshape_notext, "groupshape-notext.rtf")
{
uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
- uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(),
- uno::UNO_QUERY);
+ uno::Reference<container::XIndexAccess> xDraws = xDrawPageSupplier->getDrawPage();
// There should be a single groupshape with 2 children.
CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xDraws->getCount());
uno::Reference<drawing::XShapes> xGroupshape(xDraws->getByIndex(0), uno::UNO_QUERY);
@@ -680,7 +673,7 @@ DECLARE_RTFIMPORT_TEST(testFdo66565, "fdo66565.rtf")
uno::UNO_QUERY);
uno::Reference<text::XTextTable> xTable(xTables->getByIndex(0), uno::UNO_QUERY);
// Cell width of A2 was 554, should be 453/14846*10000
- uno::Reference<table::XTableRows> xTableRows(xTable->getRows(), uno::UNO_QUERY);
+ uno::Reference<table::XTableRows> xTableRows = xTable->getRows();
CPPUNIT_ASSERT_EQUAL(sal_Int16(304), getProperty<uno::Sequence<text::TableColumnSeparator>>(
xTableRows->getByIndex(1), "TableColumnSeparators")[0]
.Position);
@@ -750,7 +743,7 @@ DECLARE_RTFIMPORT_TEST(testTdf115153, "tdf115153.rtf")
DECLARE_RTFIMPORT_TEST(testFdo68291, "fdo68291.odt")
{
uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
- uno::Reference<text::XTextRange> xText(xTextDocument->getText(), uno::UNO_QUERY);
+ uno::Reference<text::XTextRange> xText = xTextDocument->getText();
uno::Reference<text::XTextRange> xEnd = xText->getEnd();
paste("rtfimport/data/fdo68291-paste.rtf", xEnd);
@@ -818,7 +811,7 @@ DECLARE_RTFIMPORT_TEST(testFdo74823, "fdo74823.rtf")
uno::UNO_QUERY);
uno::Reference<text::XTextTable> xTable(xTables->getByIndex(0), uno::UNO_QUERY);
// Cell width of C2 was too large / column separator being 3749 too small (e.g. not set, around 3/7 of total width)
- uno::Reference<table::XTableRows> xTableRows(xTable->getRows(), uno::UNO_QUERY);
+ uno::Reference<table::XTableRows> xTableRows = xTable->getRows();
CPPUNIT_ASSERT_EQUAL(sal_Int16(5391), getProperty<uno::Sequence<text::TableColumnSeparator>>(
xTableRows->getByIndex(1), "TableColumnSeparators")[2]
.Position);
@@ -1069,8 +1062,7 @@ DECLARE_RTFIMPORT_TEST(testTdf90046, "tdf90046.rtf")
{
// this was crashing on importing the footnote
uno::Reference<text::XFootnotesSupplier> xFootnotesSupplier(mxComponent, uno::UNO_QUERY);
- uno::Reference<container::XIndexAccess> xFootnotes(xFootnotesSupplier->getFootnotes(),
- uno::UNO_QUERY);
+ uno::Reference<container::XIndexAccess> xFootnotes = xFootnotesSupplier->getFootnotes();
uno::Reference<text::XTextRange> xTextRange(xFootnotes->getByIndex(0), uno::UNO_QUERY);
CPPUNIT_ASSERT_EQUAL(OUString("Ma"), xTextRange->getString());
}
@@ -1078,7 +1070,7 @@ DECLARE_RTFIMPORT_TEST(testTdf90046, "tdf90046.rtf")
DECLARE_RTFIMPORT_TEST(testFdo49893, "fdo49893.rtf")
{
// Image from shape was not loaded, invalid size of image after load
- uno::Reference<drawing::XShape> xShape(getShape(2), uno::UNO_QUERY);
+ uno::Reference<drawing::XShape> xShape = getShape(2);
CPPUNIT_ASSERT(xShape.is());
CPPUNIT_ASSERT_EQUAL(sal_Int32(convertTwipToMm100(432)), xShape->getSize().Height);
CPPUNIT_ASSERT_EQUAL(sal_Int32(convertTwipToMm100(1296)), xShape->getSize().Width);
@@ -1089,7 +1081,7 @@ DECLARE_RTFIMPORT_TEST(testFdo49893_3, "fdo49893-3.rtf")
// No artifacts (black lines in left top corner) as shape #3 are expected
try
{
- uno::Reference<drawing::XShape> xShape2(getShape(3), uno::UNO_QUERY);
+ uno::Reference<drawing::XShape> xShape2 = getShape(3);
CPPUNIT_FAIL("exception expected: no shape #3 in document");
}
catch (lang::IndexOutOfBoundsException const&)
@@ -1131,7 +1123,7 @@ DECLARE_RTFIMPORT_TEST(testWrapDistance, "wrap-distance.rtf")
DECLARE_RTFIMPORT_TEST(testTdf90260Par, "hello.rtf")
{
uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
- uno::Reference<text::XTextRange> xText(xTextDocument->getText(), uno::UNO_QUERY);
+ uno::Reference<text::XTextRange> xText = xTextDocument->getText();
uno::Reference<text::XTextRange> xEnd = xText->getEnd();
paste("rtfimport/data/tdf90260-par.rtf", xEnd);
CPPUNIT_ASSERT_EQUAL(2, getParagraphs());
@@ -1233,7 +1225,7 @@ DECLARE_RTFIMPORT_TEST(testTdf99498, "tdf99498.rtf")
DECLARE_RTFIMPORT_TEST(testClassificatonPaste, "hello.rtf")
{
uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
- uno::Reference<text::XTextRange> xText(xTextDocument->getText(), uno::UNO_QUERY);
+ uno::Reference<text::XTextRange> xText = xTextDocument->getText();
uno::Reference<text::XTextRange> xEnd = xText->getEnd();
// Not classified source, not classified destination: OK.
@@ -1334,18 +1326,15 @@ DECLARE_RTFIMPORT_TEST(testImportHeaderFooter, "tdf108055.rtf")
// Check if any Header or Footer text snuck into the TextBody
uno::Reference<text::XTextRange> paragraph = getParagraph(1);
- uno::Reference<text::XTextRange> text(paragraph, uno::UNO_QUERY);
- OUString value = text->getString();
+ OUString value = paragraph->getString();
CPPUNIT_ASSERT_EQUAL(OUString("First Page"), value);
paragraph = getParagraph(4);
- uno::Reference<text::XTextRange> text2(paragraph, uno::UNO_QUERY);
- value = text2->getString();
+ value = paragraph->getString();
CPPUNIT_ASSERT_EQUAL(OUString("Second Page"), value);
paragraph = getParagraph(7);
- uno::Reference<text::XTextRange> text3(paragraph, uno::UNO_QUERY);
- value = text3->getString();
+ value = paragraph->getString();
CPPUNIT_ASSERT_EQUAL(OUString("Third Page"), value);
//Check if Headers/Footers only contain what they should in this document
@@ -1403,7 +1392,7 @@ DECLARE_RTFIMPORT_TEST(testTdf108947, "tdf108947.rtf")
DECLARE_RTFIMPORT_TEST(testWatermark, "watermark.rtf")
{
Size aExpectedSize(14965, 7482);
- uno::Reference<drawing::XShape> xShape(getShape(1), uno::UNO_QUERY);
+ uno::Reference<drawing::XShape> xShape = getShape(1);
awt::Size aActualSize(xShape->getSize());
CPPUNIT_ASSERT_EQUAL(sal_Int32(aExpectedSize.Width()), aActualSize.Width);
diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx
index d5a53d73841c..3c955903a5e5 100644
--- a/sw/qa/extras/uiwriter/uiwriter.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter.cxx
@@ -916,12 +916,11 @@ void SwUiWriterTest::testFdo70807()
for (sal_Int32 i = 0; i < xStylesIter->getCount(); ++i)
{
uno::Reference<style::XStyle> xStyle(xStylesIter->getByIndex(i), uno::UNO_QUERY);
- uno::Reference<container::XNamed> xName(xStyle, uno::UNO_QUERY);
bool expectedUsedStyle = false;
bool expectedUserDefined = false;
- OUString styleName(xName->getName());
+ OUString styleName(xStyle->getName());
// just these styles are user defined styles
if (styleName == "pagestyle1" || styleName == "pagestyle2")
@@ -1113,7 +1112,7 @@ void SwUiWriterTest::testWatermarkPosition()
const OUString rPageStyleName = "Default Style";
uno::Reference<frame::XModel> xModel = pDoc->GetDocShell()->GetBaseModel();
uno::Reference<style::XStyleFamiliesSupplier> xStyleFamiliesSupplier(xModel, uno::UNO_QUERY);
- uno::Reference<container::XNameAccess> xStyleFamilies(xStyleFamiliesSupplier->getStyleFamilies(), uno::UNO_QUERY);
+ uno::Reference<container::XNameAccess> xStyleFamilies = xStyleFamiliesSupplier->getStyleFamilies();
uno::Reference<container::XNameAccess> xStyleFamily(xStyleFamilies->getByName("PageStyles"), uno::UNO_QUERY);
uno::Reference<beans::XPropertySet> xPageStyle(xStyleFamily->getByName(rPageStyleName), uno::UNO_QUERY);
@@ -1147,7 +1146,7 @@ void SwUiWriterTest::testWatermarkPosition()
pEditShell->SetWatermark(aWatermark);
- uno::Reference<css::drawing::XShape> xShape(getShape(1), uno::UNO_QUERY);
+ uno::Reference<css::drawing::XShape> xShape = getShape(1);
CPPUNIT_ASSERT(xShape.is());
SdrPage* pPage = pWrtShell->GetDoc()->getIDocumentDrawModelAccess().GetDrawModel()->GetPage(0);
@@ -2195,7 +2194,7 @@ void SwUiWriterTest::testTextSearch()
rIDCO.InsertPoolItem(*pCursor, aWeightItem);
//Performing Search Operation and also covering the UNO coverage for setProperty
uno::Reference<util::XSearchable> xSearch(mxComponent, uno::UNO_QUERY);
- uno::Reference<util::XSearchDescriptor> xSearchDes(xSearch->createSearchDescriptor(), uno::UNO_QUERY);
+ uno::Reference<util::XSearchDescriptor> xSearchDes = xSearch->createSearchDescriptor();
uno::Reference<util::XPropertyReplace> xProp(xSearchDes, uno::UNO_QUERY);
//setting some properties
uno::Sequence<beans::PropertyValue> aDescriptor( comphelper::InitPropertySequence({
@@ -2216,7 +2215,7 @@ void SwUiWriterTest::testTextSearch()
CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xIndex->getCount());
//Replacing the searched string via XReplaceable
uno::Reference<util::XReplaceable> xReplace(mxComponent, uno::UNO_QUERY);
- uno::Reference<util::XReplaceDescriptor> xReplaceDes(xReplace->createReplaceDescriptor(), uno::UNO_QUERY);
+ uno::Reference<util::XReplaceDescriptor> xReplaceDes = xReplace->createReplaceDescriptor();
uno::Reference<util::XPropertyReplace> xProp2(xReplaceDes, uno::UNO_QUERY);
xProp2->setReplaceAttributes(aDescriptor);
//checking that the proper attributes are there or not
@@ -2244,7 +2243,7 @@ void SwUiWriterTest::testTdf69282()
SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument *>(mxComponent.get());
CPPUNIT_ASSERT(pTextDoc);
SwDoc* source = pTextDoc->GetDocShell()->GetDoc();
- uno::Reference<lang::XComponent> xSourceDoc(mxComponent, uno::UNO_QUERY);
+ uno::Reference<lang::XComponent> xSourceDoc = mxComponent;
mxComponent.clear();
SwDoc* target = createDoc();
SwPageDesc* sPageDesc = source->MakePageDesc("SourceStyle");
@@ -2305,7 +2304,7 @@ void SwUiWriterTest::testTdf69282WithMirror()
SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument *>(mxComponent.get());
CPPUNIT_ASSERT(pTextDoc);
SwDoc* source = pTextDoc->GetDocShell()->GetDoc();
- uno::Reference<lang::XComponent> xSourceDoc(mxComponent, uno::UNO_QUERY);
+ uno::Reference<lang::XComponent> xSourceDoc = mxComponent;
mxComponent.clear();
SwDoc* target = createDoc();
SwPageDesc* sPageDesc = source->MakePageDesc("SourceStyle");
@@ -3335,8 +3334,8 @@ void SwUiWriterTest::testTdf90808()
{
createDoc();
uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
- uno::Reference<text::XTextRange> xTextRange(xTextDocument->getText(), uno::UNO_QUERY);
- uno::Reference<text::XText> xText(xTextRange->getText(), uno::UNO_QUERY);
+ uno::Reference<text::XTextRange> xTextRange = xTextDocument->getText();
+ uno::Reference<text::XText> xText = xTextRange->getText();
uno::Reference<text::XParagraphCursor> xCursor(xText->createTextCursor(), uno::UNO_QUERY);
//inserting text into document so that the paragraph is not empty
xText->setString("Hello World!");
@@ -3649,7 +3648,7 @@ void SwUiWriterTest::testTdf88899()
createDoc();
uno::Reference<document::XDocumentPropertiesSupplier> xDocumentPropertiesSupplier(mxComponent, uno::UNO_QUERY);
uno::Reference<document::XDocumentProperties> xProps(xDocumentPropertiesSupplier->getDocumentProperties());
- uno::Reference<beans::XPropertyContainer> xUserProps(xProps->getUserDefinedProperties(), uno::UNO_QUERY);
+ uno::Reference<beans::XPropertyContainer> xUserProps = xProps->getUserDefinedProperties();
css::util::DateTime aDateTime = {sal_uInt32(1234567), sal_uInt16(3), sal_uInt16(3), sal_uInt16(3), sal_uInt16(10), sal_uInt16(11), sal_uInt16(2014), true};
xUserProps->addProperty("dateTime", sal_Int16(beans::PropertyAttribute::OPTIONAL), uno::makeAny(aDateTime));
uno::Reference<lang::XMultiServiceFactory> xFact(mxComponent, uno::UNO_QUERY);
@@ -3667,8 +3666,8 @@ void SwUiWriterTest::testTdf88899()
xPropSet->setPropertyValue("NumberFormat", uno::makeAny(key));
//Inserting Text Content
uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
- uno::Reference<text::XTextRange> xTextRange(xTextDocument->getText(), uno::UNO_QUERY);
- uno::Reference<text::XText> xText(xTextRange->getText(), uno::UNO_QUERY);
+ uno::Reference<text::XTextRange> xTextRange = xTextDocument->getText();
+ uno::Reference<text::XText> xText = xTextRange->getText();
xText->insertTextContent(xTextRange, xTextField, true);
//Retrieving the contents for verification
CPPUNIT_ASSERT_EQUAL(OUString("11/10/14 03:03 AM"), xTextField->getPresentation(false));
@@ -3924,10 +3923,9 @@ void SwUiWriterTest::testEmbeddedDataSource()
uno::Reference<sdbc::XDataSource> xDataSource(xDatabaseContext->getByName("calc-data-source"), uno::UNO_QUERY);
CPPUNIT_ASSERT(xDataSource.is());
auto xConnection = xDataSource->getConnection("", "");
- uno::Reference<container::XNameAccess> xTables(
+ uno::Reference<container::XNameAccess> xTables =
css::uno::Reference<css::sdbcx::XTablesSupplier>(
- xConnection, uno::UNO_QUERY_THROW)->getTables(),
- uno::UNO_QUERY);
+ xConnection, uno::UNO_QUERY_THROW)->getTables();
CPPUNIT_ASSERT(xTables.is());
CPPUNIT_ASSERT(xTables->hasByName("Sheet1"));
xConnection->close();
@@ -3940,11 +3938,10 @@ void SwUiWriterTest::testEmbeddedDataSource()
// Data source has a table named Sheet1 after saving to a different directory.
xDataSource.set(xDatabaseContext->getByName("calc-data-source"), uno::UNO_QUERY);
CPPUNIT_ASSERT(xDataSource.is());
- xConnection.set(xDataSource->getConnection("", ""), uno::UNO_QUERY);
- xTables.set(
+ xConnection = xDataSource->getConnection("", "");
+ xTables =
css::uno::Reference<css::sdbcx::XTablesSupplier>(
- xConnection, uno::UNO_QUERY_THROW)->getTables(),
- uno::UNO_QUERY);
+ xConnection, uno::UNO_QUERY_THROW)->getTables();
CPPUNIT_ASSERT(xTables.is());
CPPUNIT_ASSERT(xTables->hasByName("Sheet1"));
xConnection->close();
@@ -4598,8 +4595,8 @@ void SwUiWriterTest::testTdf96479()
// Create cursor from bookmark
uno::Reference<text::XTextContent> xTextContent(xBookmarksSupplier->getBookmarks()->getByName("original"), uno::UNO_QUERY);
- uno::Reference<text::XTextRange> xRange(xTextContent->getAnchor(), uno::UNO_QUERY);
- uno::Reference<text::XTextCursor> xCursor(xRange->getText()->createTextCursorByRange(xRange), uno::UNO_QUERY);
+ uno::Reference<text::XTextRange> xRange = xTextContent->getAnchor();
+ uno::Reference<text::XTextCursor> xCursor = xRange->getText()->createTextCursorByRange(xRange);
CPPUNIT_ASSERT(xCursor->isCollapsed());
// Remove bookmark
@@ -4654,8 +4651,8 @@ void SwUiWriterTest::testTdf96479()
CPPUNIT_ASSERT(xBookmarksSupplier->getBookmarks()->hasByName("replacement"));
uno::Reference<text::XTextContent> xTextContent(xBookmarksSupplier->getBookmarks()->getByName("replacement"), uno::UNO_QUERY);
- uno::Reference<text::XTextRange> xRange(xTextContent->getAnchor(), uno::UNO_QUERY);
- uno::Reference<text::XTextCursor> xCursor(xRange->getText()->createTextCursorByRange(xRange), uno::UNO_QUERY);
+ uno::Reference<text::XTextRange> xRange = xTextContent->getAnchor();
+ uno::Reference<text::XTextCursor> xCursor = xRange->getText()->createTextCursorByRange(xRange);
CPPUNIT_ASSERT(!xCursor->isCollapsed());
// Verify bookmark content via text node / PaM
@@ -4858,7 +4855,7 @@ void SwUiWriterTest::testRemoveBookmarkTextAndAddNew()
// Create cursor from bookmark
uno::Reference<text::XTextContent> xTextContent(xBookmarksSupplier->getBookmarks()->getByName("testBookmark"), uno::UNO_QUERY);
- uno::Reference<text::XTextRange> xRange(xTextContent->getAnchor(), uno::UNO_QUERY);
+ uno::Reference<text::XTextRange> xRange = xTextContent->getAnchor();
CPPUNIT_ASSERT_EQUAL(OUString(""), xRange->getString());
// write "abc"
@@ -4925,7 +4922,7 @@ void SwUiWriterTest::testRemoveBookmarkTextAndAddNewAfterReload()
// Create cursor from bookmark
uno::Reference<text::XTextContent> xTextContent(xBookmarksSupplier->getBookmarks()->getByName("test"), uno::UNO_QUERY);
- uno::Reference<text::XTextRange> xRange(xTextContent->getAnchor(), uno::UNO_QUERY);
+ uno::Reference<text::XTextRange> xRange = xTextContent->getAnchor();
CPPUNIT_ASSERT_EQUAL(OUString(""), xRange->getString());
// write "abc"
@@ -6375,7 +6372,7 @@ void SwUiWriterTest::testParagraphOfTextRange()
// Assert that we get the right paragraph object.
uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY);
uno::Reference<text::XTextViewCursorSupplier> xController(xModel->getCurrentController(), uno::UNO_QUERY);
- uno::Reference<text::XTextRange> xViewCursor(xController->getViewCursor(), uno::UNO_QUERY);
+ uno::Reference<text::XTextRange> xViewCursor = xController->getViewCursor();
// This failed as there were no TextParagraph property.
auto xParagraph = getProperty< uno::Reference<text::XTextRange> >(xViewCursor->getStart(), "TextParagraph");
CPPUNIT_ASSERT_EQUAL(OUString("In section"), xParagraph->getString());
diff --git a/sw/qa/extras/uiwriter/uiwriter2.cxx b/sw/qa/extras/uiwriter/uiwriter2.cxx
index a5298652f5a2..7c10db4e7730 100644
--- a/sw/qa/extras/uiwriter/uiwriter2.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter2.cxx
@@ -573,7 +573,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf64242_optimizeTable)
uno::Reference<container::XIndexAccess> xTables(xTablesSupplier->getTextTables(),
uno::UNO_QUERY);
uno::Reference<text::XTextTable> xTextTable(xTables->getByIndex(0), uno::UNO_QUERY);
- uno::Reference<table::XTableRows> xTableRows(xTextTable->getRows(), uno::UNO_QUERY);
+ uno::Reference<table::XTableRows> xTableRows = xTextTable->getRows();
double origWidth = getProperty<double>(xTextTable, "Width");
sal_Int32 nToleranceW = origWidth * .01;
@@ -1413,8 +1413,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testDocxAttributeTableExport)
// get the table frame, set new values and dismiss the references
{
uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
- uno::Reference<container::XIndexAccess> xDrawPage(xDrawPageSupplier->getDrawPage(),
- uno::UNO_QUERY);
+ uno::Reference<container::XIndexAccess> xDrawPage = xDrawPageSupplier->getDrawPage();
uno::Reference<beans::XPropertySet> xShape(xDrawPage->getByIndex(0), uno::UNO_QUERY);
// change the properties
@@ -1431,8 +1430,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testDocxAttributeTableExport)
reload("Office Open XML Text", "floating-table-position.docx");
uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
- uno::Reference<container::XIndexAccess> xDrawPage(xDrawPageSupplier->getDrawPage(),
- uno::UNO_QUERY);
+ uno::Reference<container::XIndexAccess> xDrawPage = xDrawPageSupplier->getDrawPage();
uno::Reference<beans::XPropertySet> xShape(xDrawPage->getByIndex(0), uno::UNO_QUERY);
// test the new values
diff --git a/sw/qa/extras/unowriter/unowriter.cxx b/sw/qa/extras/unowriter/unowriter.cxx
index ae042c1210a3..f27d40e19839 100644
--- a/sw/qa/extras/unowriter/unowriter.cxx
+++ b/sw/qa/extras/unowriter/unowriter.cxx
@@ -95,7 +95,7 @@ CPPUNIT_TEST_FIXTURE(SwUnoWriter, testDefaultCharStyle)
loadURL("private:factory/swriter", nullptr);
uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
- uno::Reference<text::XSimpleText> xBodyText(xTextDocument->getText(), uno::UNO_QUERY);
+ uno::Reference<text::XSimpleText> xBodyText = xTextDocument->getText();
xBodyText->insertString(xBodyText->getStart(), "x", false);
uno::Reference<text::XTextCursor> xCursor(xBodyText->createTextCursor());
@@ -131,7 +131,7 @@ CPPUNIT_TEST_FIXTURE(SwUnoWriter, testGraphicDesciptorURL)
// Insert it.
uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
- uno::Reference<text::XText> xBodyText(xTextDocument->getText(), uno::UNO_QUERY);
+ uno::Reference<text::XText> xBodyText = xTextDocument->getText();
uno::Reference<text::XTextCursor> xCursor(xBodyText->createTextCursor());
uno::Reference<text::XTextContent> xTextContent(xTextGraphic, uno::UNO_QUERY);
xBodyText->insertTextContent(xCursor, xTextContent, false);
@@ -161,7 +161,7 @@ CPPUNIT_TEST_FIXTURE(SwUnoWriter, testGraphicDesciptorURLBitmap)
// Insert it.
uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
- uno::Reference<text::XText> xBodyText(xTextDocument->getText(), uno::UNO_QUERY);
+ uno::Reference<text::XText> xBodyText = xTextDocument->getText();
uno::Reference<text::XTextCursor> xCursor(xBodyText->createTextCursor());
uno::Reference<text::XTextContent> xTextContent(xTextGraphic, uno::UNO_QUERY);
xBodyText->insertTextContent(xCursor, xTextContent, false);
@@ -211,8 +211,8 @@ CPPUNIT_TEST_FIXTURE(SwUnoWriter, testXAutoTextGroup)
const OUString sTextTitleNew = "Test Auto Text Renamed";
// Create new temporary group
- uno::Reference<text::XAutoTextGroup> xAutoTextGroup(
- xAutoTextContainer->insertNewByName(sGroupName), uno::UNO_QUERY);
+ uno::Reference<text::XAutoTextGroup> xAutoTextGroup
+ = xAutoTextContainer->insertNewByName(sGroupName);
CPPUNIT_ASSERT_MESSAGE("AutoTextGroup was not found!", xAutoTextGroup.is());
// Insert new element and ensure it exists
@@ -340,7 +340,7 @@ CPPUNIT_TEST_FIXTURE(SwUnoWriter, testSetPagePrintSettings)
loadURL("private:factory/swriter", nullptr);
uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
- uno::Reference<text::XSimpleText> xBodyText(xTextDocument->getText(), uno::UNO_QUERY);
+ uno::Reference<text::XSimpleText> xBodyText = xTextDocument->getText();
xBodyText->insertString(xBodyText->getStart(), "x", false);
uno::Reference<text::XPagePrintable> xPagePrintable(mxComponent, uno::UNO_QUERY);
@@ -480,7 +480,7 @@ CPPUNIT_TEST_FIXTURE(SwUnoWriter, testPasteListener)
// Insert initial string.
uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
- uno::Reference<text::XSimpleText> xBodyText(xTextDocument->getText(), uno::UNO_QUERY);
+ uno::Reference<text::XSimpleText> xBodyText = xTextDocument->getText();
xBodyText->insertString(xBodyText->getStart(), "ABCDEF", false);
// Add paste listener.
diff --git a/sw/qa/extras/ww8export/ww8export.cxx b/sw/qa/extras/ww8export/ww8export.cxx
index 2aee73518377..61506b8f3702 100644
--- a/sw/qa/extras/ww8export/ww8export.cxx
+++ b/sw/qa/extras/ww8export/ww8export.cxx
@@ -392,8 +392,8 @@ DECLARE_WW8EXPORT_TEST(testBorderColours, "bordercolours.doc")
// Paragraph border
uno::Reference<text::XBookmarksSupplier> bookmarksSupplier(mxComponent,
uno::UNO_QUERY);
- uno::Reference<container::XNameAccess> bookmarks(
- bookmarksSupplier->getBookmarks(), uno::UNO_QUERY);
+ uno::Reference<container::XNameAccess> bookmarks =
+ bookmarksSupplier->getBookmarks();
uno::Reference<text::XTextContent> bookmark(
bookmarks->getByName("ParagraphBorder"), uno::UNO_QUERY);
uno::Reference<text::XTextRange> anchor(bookmark->getAnchor());
@@ -435,8 +435,8 @@ DECLARE_WW8EXPORT_TEST(testBorderColours, "bordercolours.doc")
// Table border
uno::Reference<text::XTextTablesSupplier> tablesSupplier(mxComponent,
uno::UNO_QUERY);
- uno::Reference<container::XNameAccess> tables(
- tablesSupplier->getTextTables(), uno::UNO_QUERY);
+ uno::Reference<container::XNameAccess> tables =
+ tablesSupplier->getTextTables();
uno::Reference<text::XTextTable> table(
tables->getByName("Table1"), uno::UNO_QUERY);
table::TableBorder2 tableBorder = getProperty<table::TableBorder2>(
@@ -447,8 +447,8 @@ DECLARE_WW8EXPORT_TEST(testBorderColours, "bordercolours.doc")
CPPUNIT_ASSERT_EQUAL(expectedBottom.Color, tableBorder.BottomLine.Color);
// Table cells
- uno::Reference<table::XCell> cell(
- table->getCellByName("A2"), uno::UNO_QUERY);
+ uno::Reference<table::XCell> cell =
+ table->getCellByName("A2");
border = getProperty<table::BorderLine2>(cell, "TopBorder");
CPPUNIT_ASSERT_BORDER_EQUAL(expectedTop, border);
border = getProperty<table::BorderLine2>(cell, "LeftBorder");
@@ -456,7 +456,7 @@ DECLARE_WW8EXPORT_TEST(testBorderColours, "bordercolours.doc")
border = getProperty<table::BorderLine2>(cell, "BottomBorder");
CPPUNIT_ASSERT_BORDER_EQUAL(expectedBottom, border);
- cell.set(table->getCellByName("B2"), uno::UNO_QUERY);
+ cell = table->getCellByName("B2");
border = getProperty<table::BorderLine2>(cell, "TopBorder");
CPPUNIT_ASSERT_BORDER_EQUAL(expectedDoubleGreen, border);
border = getProperty<table::BorderLine2>(cell, "LeftBorder");
@@ -464,7 +464,7 @@ DECLARE_WW8EXPORT_TEST(testBorderColours, "bordercolours.doc")
border = getProperty<table::BorderLine2>(cell, "BottomBorder");
CPPUNIT_ASSERT_BORDER_EQUAL(expectedDoubleGreen, border);
- cell.set(table->getCellByName("C2"), uno::UNO_QUERY);
+ cell = table->getCellByName("C2");
border = getProperty<table::BorderLine2>(cell, "TopBorder");
CPPUNIT_ASSERT_BORDER_EQUAL(expectedDoubleGreen, border);
border = getProperty<table::BorderLine2>(cell, "LeftBorder");
@@ -493,7 +493,7 @@ DECLARE_WW8EXPORT_TEST(testBorderColours, "bordercolours.doc")
DECLARE_WW8EXPORT_TEST(testMsoBrightnessContrast, "msobrightnesscontrast.doc")
{
uno::Reference<text::XTextDocument> textDocument(mxComponent, uno::UNO_QUERY);
- uno::Reference<drawing::XShape> image(getShape(1), uno::UNO_QUERY);
+ uno::Reference<drawing::XShape> image = getShape(1);
uno::Reference<beans::XPropertySet> imageProperties(image, uno::UNO_QUERY);
uno::Reference<graphic::XGraphic> graphic;
imageProperties->getPropertyValue( "Graphic" ) >>= graphic;
@@ -579,8 +579,8 @@ DECLARE_WW8EXPORT_TEST(testFdo81102, "fdo81102.doc")
// get page style at beginning of document
uno::Reference<text::XTextDocument> textDocument(
mxComponent, uno::UNO_QUERY);
- uno::Reference<text::XTextRange> start(
- textDocument->getText()->getStart(), uno::UNO_QUERY);
+ uno::Reference<text::XTextRange> start =
+ textDocument->getText()->getStart();
OUString pageStyleName = getProperty<OUString>(start, "PageStyleName");
uno::Reference<style::XStyle> pageStyle(
getStyles("PageStyles")->getByName(pageStyleName), uno::UNO_QUERY);
@@ -632,7 +632,7 @@ DECLARE_WW8EXPORT_TEST(testTdf74328, "tdf74328.doc")
reading page numbers at sections > 255, in this case 256
*/
uno::Reference<text::XTextDocument> textDocument(mxComponent, uno::UNO_QUERY);
- uno::Reference<text::XTextCursor> xTextCursor(textDocument->getText()->createTextCursor( ), uno::UNO_QUERY);
+ uno::Reference<text::XTextCursor> xTextCursor = textDocument->getText()->createTextCursor( );
uno::Reference<beans::XPropertySet> xProps(xTextCursor, uno::UNO_QUERY);
uno::Any aOffset = xProps->getPropertyValue("PageNumberOffset");
sal_Int16 nOffset = 0;
@@ -765,7 +765,7 @@ DECLARE_WW8EXPORT_TEST(testFdo46020, "fdo46020.odt")
{
// The footnote in that document wasn't exported, check that it is actually exported
uno::Reference<text::XFootnotesSupplier> xFootnotesSupplier(mxComponent, uno::UNO_QUERY);
- uno::Reference<container::XIndexAccess> xFootnotes(xFootnotesSupplier->getFootnotes(), uno::UNO_QUERY);
+ uno::Reference<container::XIndexAccess> xFootnotes = xFootnotesSupplier->getFootnotes();
CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xFootnotes->getCount());
}
@@ -968,8 +968,8 @@ DECLARE_WW8EXPORT_TEST(testBorderColoursExport, "bordercolours.odt")
// Paragraph border
uno::Reference<text::XBookmarksSupplier> bookmarksSupplier(mxComponent,
uno::UNO_QUERY);
- uno::Reference<container::XNameAccess> bookmarks(
- bookmarksSupplier->getBookmarks(), uno::UNO_QUERY);
+ uno::Reference<container::XNameAccess> bookmarks =
+ bookmarksSupplier->getBookmarks();
uno::Reference<text::XTextContent> bookmark(
bookmarks->getByName("ParagraphBorder"), uno::UNO_QUERY);
uno::Reference<text::XTextRange> anchor(bookmark->getAnchor());
@@ -1011,8 +1011,8 @@ DECLARE_WW8EXPORT_TEST(testBorderColoursExport, "bordercolours.odt")
// Table border
uno::Reference<text::XTextTablesSupplier> tablesSupplier(mxComponent,
uno::UNO_QUERY);
- uno::Reference<container::XNameAccess> tables(
- tablesSupplier->getTextTables(), uno::UNO_QUERY);
+ uno::Reference<container::XNameAccess> tables =
+ tablesSupplier->getTextTables();
uno::Reference<text::XTextTable> table(
tables->getByName("Table1"), uno::UNO_QUERY);
table::TableBorder2 tableBorder = getProperty<table::TableBorder2>(
@@ -1027,8 +1027,8 @@ DECLARE_WW8EXPORT_TEST(testBorderColoursExport, "bordercolours.odt")
#endif
// Table cells
- uno::Reference<table::XCell> cell(
- table->getCellByName("A2"), uno::UNO_QUERY);
+ uno::Reference<table::XCell> cell =
+ table->getCellByName("A2");
border = getProperty<table::BorderLine2>(cell, "TopBorder");
CPPUNIT_ASSERT_BORDER_EQUAL(expectedTop, border);
border = getProperty<table::BorderLine2>(cell, "LeftBorder");
@@ -1040,7 +1040,7 @@ DECLARE_WW8EXPORT_TEST(testBorderColoursExport, "bordercolours.odt")
CPPUNIT_ASSERT_BORDER_EQUAL(expectedBottom, border);
#endif
- cell.set(table->getCellByName("B2"), uno::UNO_QUERY);
+ cell = table->getCellByName("B2");
border = getProperty<table::BorderLine2>(cell, "TopBorder");
CPPUNIT_ASSERT_BORDER_EQUAL(expectedDoubleGreen, border);
border = getProperty<table::BorderLine2>(cell, "LeftBorder");
@@ -1048,7 +1048,7 @@ DECLARE_WW8EXPORT_TEST(testBorderColoursExport, "bordercolours.odt")
border = getProperty<table::BorderLine2>(cell, "BottomBorder");
CPPUNIT_ASSERT_BORDER_EQUAL(expectedDoubleGreen, border);
- cell.set(table->getCellByName("C2"), uno::UNO_QUERY);
+ cell = table->getCellByName("C2");
border = getProperty<table::BorderLine2>(cell, "TopBorder");
CPPUNIT_ASSERT_BORDER_EQUAL(expectedDoubleGreen, border);
border = getProperty<table::BorderLine2>(cell, "LeftBorder");
@@ -1157,8 +1157,8 @@ DECLARE_WW8EXPORT_TEST(testTdf92281, "tdf92281.doc")
CPPUNIT_ASSERT_EQUAL(OUString("Wingdings"), getProperty<OUString>(xRun, "CharFontNameAsian"));
CPPUNIT_ASSERT_EQUAL(OUString("Wingdings"), getProperty<OUString>(xRun, "CharFontNameComplex"));
- uno::Reference<text::XText> xXText(getParagraph(1)->getText(), uno::UNO_QUERY);
- uno::Reference<text::XTextCursor> xCursor( xXText->createTextCursor() , uno::UNO_QUERY );
+ uno::Reference<text::XText> xXText = getParagraph(1)->getText();
+ uno::Reference<text::XTextCursor> xCursor = xXText->createTextCursor();
xCursor->goRight( 5 , false );
uno::Reference< beans::XPropertySet > xPropSet(xCursor, uno::UNO_QUERY);
@@ -1263,7 +1263,7 @@ DECLARE_WW8EXPORT_TEST(testCommentExport, "comment-export.odt")
for (int i = 0; i < nNumberOfTextPortions; ++i)
{
OUString sKind = aTextPortions[i].sKind;
- uno::Reference<text::XTextRange> xRun(getRun(xPara, i + 1), uno::UNO_QUERY);
+ uno::Reference<text::XTextRange> xRun = getRun(xPara, i + 1);
uno::Reference<beans::XPropertySet> xPropertySet(xRun, uno::UNO_QUERY);
CPPUNIT_ASSERT_EQUAL(sKind, getProperty<OUString>(xPropertySet, "TextPortionType"));
diff --git a/sw/qa/extras/ww8export/ww8export2.cxx b/sw/qa/extras/ww8export/ww8export2.cxx
index 1900d0569a03..053307cb0d73 100644
--- a/sw/qa/extras/ww8export/ww8export2.cxx
+++ b/sw/qa/extras/ww8export/ww8export2.cxx
@@ -116,10 +116,10 @@ DECLARE_WW8EXPORT_TEST(testTdf55427_footnote2endnote, "tdf55427_footnote2endnote
CPPUNIT_ASSERT_EQUAL_MESSAGE( "Endnote numbering type", SVX_NUM_ROMAN_LOWER, pDoc->GetEndNoteInfo().aFormat.GetNumberingType() );
uno::Reference<text::XFootnotesSupplier> xFootnotesSupplier(mxComponent, uno::UNO_QUERY);
- uno::Reference<container::XIndexAccess> xFootnotes(xFootnotesSupplier->getFootnotes(), uno::UNO_QUERY);
+ uno::Reference<container::XIndexAccess> xFootnotes = xFootnotesSupplier->getFootnotes();
uno::Reference<text::XEndnotesSupplier> xEndnotesSupplier(mxComponent, uno::UNO_QUERY);
- uno::Reference<container::XIndexAccess> xEndnotes(xEndnotesSupplier->getEndnotes(), uno::UNO_QUERY);
+ uno::Reference<container::XIndexAccess> xEndnotes = xEndnotesSupplier->getEndnotes();
uno::Reference<text::XFootnote> xEndnote;
xEndnotes->getByIndex(0) >>= xEndnote;
uno::Reference<text::XText> xEndnoteText;
@@ -215,7 +215,7 @@ DECLARE_WW8EXPORT_TEST(testTdf112517_maxSprms, "tdf112517_maxSprms.doc")
DECLARE_WW8EXPORT_TEST(testTdf108448_endNote, "tdf108448_endNote.odt")
{
uno::Reference<text::XEndnotesSupplier> xEndnotesSupplier(mxComponent, uno::UNO_QUERY);
- uno::Reference<container::XIndexAccess> xEndnotes(xEndnotesSupplier->getEndnotes(), uno::UNO_QUERY);
+ uno::Reference<container::XIndexAccess> xEndnotes = xEndnotesSupplier->getEndnotes();
uno::Reference<text::XText> xEndnote;
xEndnotes->getByIndex(0) >>= xEndnote;
@@ -225,7 +225,7 @@ DECLARE_WW8EXPORT_TEST(testTdf108448_endNote, "tdf108448_endNote.odt")
DECLARE_WW8EXPORT_TEST(testTdf106062_nonHangingFootnote, "tdf106062_nonHangingFootnote.odt")
{
uno::Reference<text::XFootnotesSupplier> xFootnotesSupplier(mxComponent, uno::UNO_QUERY);
- uno::Reference<container::XIndexAccess> xFootnotes(xFootnotesSupplier->getFootnotes(), uno::UNO_QUERY);
+ uno::Reference<container::XIndexAccess> xFootnotes = xFootnotesSupplier->getFootnotes();
uno::Reference<text::XTextRange> xTextRange(xFootnotes->getByIndex(0), uno::UNO_QUERY);
// This failed, tab between the footnote number and the footnote content was lost on import.
CPPUNIT_ASSERT_MESSAGE( "Footnote starts with a tab", xTextRange->getString().startsWith("\t") );
@@ -234,7 +234,7 @@ DECLARE_WW8EXPORT_TEST(testTdf106062_nonHangingFootnote, "tdf106062_nonHangingFo
DECLARE_WW8EXPORT_TEST(testTdf116570_exportFootnote, "tdf116570_exportFootnote.odt")
{
uno::Reference<text::XFootnotesSupplier> xFootnotesSupplier(mxComponent, uno::UNO_QUERY);
- uno::Reference<container::XIndexAccess> xFootnotes(xFootnotesSupplier->getFootnotes(), uno::UNO_QUERY);
+ uno::Reference<container::XIndexAccess> xFootnotes = xFootnotesSupplier->getFootnotes();
uno::Reference<text::XText> xFootnoteText;
xFootnotes->getByIndex(0) >>= xFootnoteText;
@@ -323,7 +323,7 @@ DECLARE_WW8EXPORT_TEST(testTdf108072, "tdf108072.doc")
uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY);
uno::Reference<container::XIndexAccess> xTables(xTextTablesSupplier->getTextTables(), uno::UNO_QUERY);
uno::Reference<text::XTextTable> xTable(xTables->getByIndex(0), uno::UNO_QUERY);
- uno::Reference<container::XIndexAccess> xTableRows(xTable->getRows(), uno::UNO_QUERY);
+ uno::Reference<container::XIndexAccess> xTableRows = xTable->getRows();
CPPUNIT_ASSERT_EQUAL(true, getProperty<bool>(xTableRows->getByIndex(0), "IsSplitAllowed"));
}
@@ -450,7 +450,7 @@ DECLARE_OOXMLEXPORT_TEST( testTableCrossReference, "table_cross_reference.odt" )
uno::Reference<text::XBookmarksSupplier> xBookmarksSupplier(mxComponent, uno::UNO_QUERY);
uno::Reference<container::XIndexAccess> xBookmarksByIdx(xBookmarksSupplier->getBookmarks(), uno::UNO_QUERY);
CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(4), xBookmarksByIdx->getCount());
- uno::Reference<container::XNameAccess> xBookmarksByName(xBookmarksSupplier->getBookmarks(), uno::UNO_QUERY);
+ uno::Reference<container::XNameAccess> xBookmarksByName = xBookmarksSupplier->getBookmarks();
CPPUNIT_ASSERT(xBookmarksByName->hasByName("Ref_Table0_full"));
CPPUNIT_ASSERT(xBookmarksByName->hasByName("Ref_Table0_label_and_number"));
CPPUNIT_ASSERT(xBookmarksByName->hasByName("Ref_Table0_caption_only"));
@@ -459,22 +459,22 @@ DECLARE_OOXMLEXPORT_TEST( testTableCrossReference, "table_cross_reference.odt" )
// Check bookmark text ranges
{
uno::Reference<text::XTextContent> xContent(xBookmarksByName->getByName("Ref_Table0_full"), uno::UNO_QUERY);
- uno::Reference<text::XTextRange> xRange(xContent->getAnchor(), uno::UNO_QUERY);
+ uno::Reference<text::XTextRange> xRange = xContent->getAnchor();
CPPUNIT_ASSERT_EQUAL(OUString("Table 1: Table caption"), xRange->getString());
}
{
uno::Reference<text::XTextContent> xContent(xBookmarksByName->getByName("Ref_Table0_label_and_number"), uno::UNO_QUERY);
- uno::Reference<text::XTextRange> xRange(xContent->getAnchor(), uno::UNO_QUERY);
+ uno::Reference<text::XTextRange> xRange = xContent->getAnchor();
CPPUNIT_ASSERT_EQUAL(OUString("Table 1"), xRange->getString());
}
{
uno::Reference<text::XTextContent> xContent(xBookmarksByName->getByName("Ref_Table0_caption_only"), uno::UNO_QUERY);
- uno::Reference<text::XTextRange> xRange(xContent->getAnchor(), uno::UNO_QUERY);
+ uno::Reference<text::XTextRange> xRange = xContent->getAnchor();
CPPUNIT_ASSERT_EQUAL(OUString("Table caption"), xRange->getString());
}
{
uno::Reference<text::XTextContent> xContent(xBookmarksByName->getByName("Ref_Table0_number_only"), uno::UNO_QUERY);
- uno::Reference<text::XTextRange> xRange(xContent->getAnchor(), uno::UNO_QUERY);
+ uno::Reference<text::XTextRange> xRange = xContent->getAnchor();
CPPUNIT_ASSERT_EQUAL(OUString("1"), xRange->getString());
}
@@ -608,7 +608,7 @@ DECLARE_OOXMLEXPORT_TEST( testTableCrossReferenceCustomFormat, "table_cross_refe
uno::Reference<text::XBookmarksSupplier> xBookmarksSupplier(mxComponent, uno::UNO_QUERY);
uno::Reference<container::XIndexAccess> xBookmarksByIdx(xBookmarksSupplier->getBookmarks(), uno::UNO_QUERY);
CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(16), xBookmarksByIdx->getCount());
- uno::Reference<container::XNameAccess> xBookmarksByName(xBookmarksSupplier->getBookmarks(), uno::UNO_QUERY);
+ uno::Reference<container::XNameAccess> xBookmarksByName = xBookmarksSupplier->getBookmarks();
CPPUNIT_ASSERT(xBookmarksByName->hasByName("Ref_Table0_full"));
CPPUNIT_ASSERT(xBookmarksByName->hasByName("Ref_Table0_label_and_number"));
CPPUNIT_ASSERT(xBookmarksByName->hasByName("Ref_Table0_caption_only"));
@@ -630,85 +630,85 @@ DECLARE_OOXMLEXPORT_TEST( testTableCrossReferenceCustomFormat, "table_cross_refe
// First table's caption
{
uno::Reference<text::XTextContent> xContent(xBookmarksByName->getByName("Ref_Table0_full"), uno::UNO_QUERY);
- uno::Reference<text::XTextRange> xRange(xContent->getAnchor(), uno::UNO_QUERY);
+ uno::Reference<text::XTextRange> xRange = xContent->getAnchor();
CPPUNIT_ASSERT_EQUAL(OUString("1. Table: Table caption"), xRange->getString());
}
{
uno::Reference<text::XTextContent> xContent(xBookmarksByName->getByName("Ref_Table0_label_and_number"), uno::UNO_QUERY);
- uno::Reference<text::XTextRange> xRange(xContent->getAnchor(), uno::UNO_QUERY);
+ uno::Reference<text::XTextRange> xRange = xContent->getAnchor();
CPPUNIT_ASSERT_EQUAL(OUString("1. Table"), xRange->getString());
}
{
uno::Reference<text::XTextContent> xContent(xBookmarksByName->getByName("Ref_Table0_caption_only"), uno::UNO_QUERY);
- uno::Reference<text::XTextRange> xRange(xContent->getAnchor(), uno::UNO_QUERY);
+ uno::Reference<text::XTextRange> xRange = xContent->getAnchor();
CPPUNIT_ASSERT_EQUAL(OUString("Table caption"), xRange->getString());
}
{
uno::Reference<text::XTextContent> xContent(xBookmarksByName->getByName("Ref_Table0_number_only"), uno::UNO_QUERY);
- uno::Reference<text::XTextRange> xRange(xContent->getAnchor(), uno::UNO_QUERY);
+ uno::Reference<text::XTextRange> xRange = xContent->getAnchor();
CPPUNIT_ASSERT_EQUAL(OUString("1"), xRange->getString());
}
// Second table's caption
{
uno::Reference<text::XTextContent> xContent(xBookmarksByName->getByName("Ref_Table1_full"), uno::UNO_QUERY);
- uno::Reference<text::XTextRange> xRange(xContent->getAnchor(), uno::UNO_QUERY);
+ uno::Reference<text::XTextRange> xRange = xContent->getAnchor();
CPPUNIT_ASSERT_EQUAL(OUString("2. TableTable caption"), xRange->getString());
}
{
uno::Reference<text::XTextContent> xContent(xBookmarksByName->getByName("Ref_Table1_label_and_number"), uno::UNO_QUERY);
- uno::Reference<text::XTextRange> xRange(xContent->getAnchor(), uno::UNO_QUERY);
+ uno::Reference<text::XTextRange> xRange = xContent->getAnchor();
CPPUNIT_ASSERT_EQUAL(OUString("2. Table"), xRange->getString());
}
{
uno::Reference<text::XTextContent> xContent(xBookmarksByName->getByName("Ref_Table1_caption_only"), uno::UNO_QUERY);
- uno::Reference<text::XTextRange> xRange(xContent->getAnchor(), uno::UNO_QUERY);
+ uno::Reference<text::XTextRange> xRange = xContent->getAnchor();
CPPUNIT_ASSERT_EQUAL(OUString("Table caption"), xRange->getString());
}
{
uno::Reference<text::XTextContent> xContent(xBookmarksByName->getByName("Ref_Table1_number_only"), uno::UNO_QUERY);
- uno::Reference<text::XTextRange> xRange(xContent->getAnchor(), uno::UNO_QUERY);
+ uno::Reference<text::XTextRange> xRange = xContent->getAnchor();
CPPUNIT_ASSERT_EQUAL(OUString("2"), xRange->getString());
}
// Third table's caption
{
uno::Reference<text::XTextContent> xContent(xBookmarksByName->getByName("Ref_Table2_full"), uno::UNO_QUERY);
- uno::Reference<text::XTextRange> xRange(xContent->getAnchor(), uno::UNO_QUERY);
+ uno::Reference<text::XTextRange> xRange = xContent->getAnchor();
CPPUNIT_ASSERT_EQUAL(OUString("3) Table Table caption"), xRange->getString());
}
{
uno::Reference<text::XTextContent> xContent(xBookmarksByName->getByName("Ref_Table2_label_and_number"), uno::UNO_QUERY);
- uno::Reference<text::XTextRange> xRange(xContent->getAnchor(), uno::UNO_QUERY);
+ uno::Reference<text::XTextRange> xRange = xContent->getAnchor();
CPPUNIT_ASSERT_EQUAL(OUString("3) Table"), xRange->getString());
}
{
uno::Reference<text::XTextContent> xContent(xBookmarksByName->getByName("Ref_Table2_caption_only"), uno::UNO_QUERY);
- uno::Reference<text::XTextRange> xRange(xContent->getAnchor(), uno::UNO_QUERY);
+ uno::Reference<text::XTextRange> xRange = xContent->getAnchor();
CPPUNIT_ASSERT_EQUAL(OUString("Table caption"), xRange->getString());
}
{
uno::Reference<text::XTextContent> xContent(xBookmarksByName->getByName("Ref_Table2_number_only"), uno::UNO_QUERY);
- uno::Reference<text::XTextRange> xRange(xContent->getAnchor(), uno::UNO_QUERY);
+ uno::Reference<text::XTextRange> xRange = xContent->getAnchor();
CPPUNIT_ASSERT_EQUAL(OUString("3"), xRange->getString());
}
// Fourth table's caption
{
uno::Reference<text::XTextContent> xContent(xBookmarksByName->getByName("Ref_Table3_full"), uno::UNO_QUERY);
- uno::Reference<text::XTextRange> xRange(xContent->getAnchor(), uno::UNO_QUERY);
+ uno::Reference<text::XTextRange> xRange = xContent->getAnchor();
CPPUNIT_ASSERT_EQUAL(OUString("Table 4- Table caption"), xRange->getString());
}
{
uno::Reference<text::XTextContent> xContent(xBookmarksByName->getByName("Ref_Table3_label_and_number"), uno::UNO_QUERY);
- uno::Reference<text::XTextRange> xRange(xContent->getAnchor(), uno::UNO_QUERY);
+ uno::Reference<text::XTextRange> xRange = xContent->getAnchor();
CPPUNIT_ASSERT_EQUAL(OUString("Table 4"), xRange->getString());
}
{
uno::Reference<text::XTextContent> xContent(xBookmarksByName->getByName("Ref_Table3_caption_only"), uno::UNO_QUERY);
- uno::Reference<text::XTextRange> xRange(xContent->getAnchor(), uno::UNO_QUERY);
+ uno::Reference<text::XTextRange> xRange = xContent->getAnchor();
CPPUNIT_ASSERT_EQUAL(OUString("Table caption"), xRange->getString());
}
{
uno::Reference<text::XTextContent> xContent(xBookmarksByName->getByName("Ref_Table3_number_only"), uno::UNO_QUERY);
- uno::Reference<text::XTextRange> xRange(xContent->getAnchor(), uno::UNO_QUERY);
+ uno::Reference<text::XTextRange> xRange = xContent->getAnchor();
CPPUNIT_ASSERT_EQUAL(OUString("4"), xRange->getString());
}
}
@@ -724,7 +724,7 @@ DECLARE_OOXMLEXPORT_TEST( testObjectCrossReference, "object_cross_reference.odt"
uno::Reference<text::XBookmarksSupplier> xBookmarksSupplier(mxComponent, uno::UNO_QUERY);
uno::Reference<container::XIndexAccess> xBookmarksByIdx(xBookmarksSupplier->getBookmarks(), uno::UNO_QUERY);
CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(15), xBookmarksByIdx->getCount());
- uno::Reference<container::XNameAccess> xBookmarksByName(xBookmarksSupplier->getBookmarks(), uno::UNO_QUERY);
+ uno::Reference<container::XNameAccess> xBookmarksByName = xBookmarksSupplier->getBookmarks();
CPPUNIT_ASSERT(xBookmarksByName->hasByName("Ref_Drawing0_full"));
CPPUNIT_ASSERT(xBookmarksByName->hasByName("Ref_Drawing0_label_and_number"));
CPPUNIT_ASSERT(xBookmarksByName->hasByName("Ref_Drawing0_caption_only"));
@@ -747,81 +747,81 @@ DECLARE_OOXMLEXPORT_TEST( testObjectCrossReference, "object_cross_reference.odt"
// Cross references to shapes
{
uno::Reference<text::XTextContent> xContent(xBookmarksByName->getByName("Ref_Drawing0_full"), uno::UNO_QUERY);
- uno::Reference<text::XTextRange> xRange(xContent->getAnchor(), uno::UNO_QUERY);
+ uno::Reference<text::XTextRange> xRange = xContent->getAnchor();
CPPUNIT_ASSERT_EQUAL(OUString("Drawing 1: A rectangle"), xRange->getString());
}
{
uno::Reference<text::XTextContent> xContent(xBookmarksByName->getByName("Ref_Drawing0_label_and_number"), uno::UNO_QUERY);
- uno::Reference<text::XTextRange> xRange(xContent->getAnchor(), uno::UNO_QUERY);
+ uno::Reference<text::XTextRange> xRange = xContent->getAnchor();
CPPUNIT_ASSERT_EQUAL(OUString("Drawing 1"), xRange->getString());
}
{
uno::Reference<text::XTextContent> xContent(xBookmarksByName->getByName("Ref_Drawing0_caption_only"), uno::UNO_QUERY);
- uno::Reference<text::XTextRange> xRange(xContent->getAnchor(), uno::UNO_QUERY);
+ uno::Reference<text::XTextRange> xRange = xContent->getAnchor();
CPPUNIT_ASSERT_EQUAL(OUString("A rectangle"), xRange->getString());
}
{
uno::Reference<text::XTextContent> xContent(xBookmarksByName->getByName("Ref_Drawing0_number_only"), uno::UNO_QUERY);
- uno::Reference<text::XTextRange> xRange(xContent->getAnchor(), uno::UNO_QUERY);
+ uno::Reference<text::XTextRange> xRange = xContent->getAnchor();
CPPUNIT_ASSERT_EQUAL(OUString("1"), xRange->getString());
}
{
uno::Reference<text::XTextContent> xContent(xBookmarksByName->getByName("Ref_Drawing1_full"), uno::UNO_QUERY);
- uno::Reference<text::XTextRange> xRange(xContent->getAnchor(), uno::UNO_QUERY);
+ uno::Reference<text::XTextRange> xRange = xContent->getAnchor();
CPPUNIT_ASSERT_EQUAL(OUString("Drawing 2: a circle"), xRange->getString());
}
// Cross references to pictures
{
uno::Reference<text::XTextContent> xContent(xBookmarksByName->getByName("Ref_Illustration0_full"), uno::UNO_QUERY);
- uno::Reference<text::XTextRange> xRange(xContent->getAnchor(), uno::UNO_QUERY);
+ uno::Reference<text::XTextRange> xRange = xContent->getAnchor();
CPPUNIT_ASSERT_EQUAL(OUString("Illustration 1: A picture"), xRange->getString());
}
{
uno::Reference<text::XTextContent> xContent(xBookmarksByName->getByName("Ref_Illustration0_label_and_number"), uno::UNO_QUERY);
- uno::Reference<text::XTextRange> xRange(xContent->getAnchor(), uno::UNO_QUERY);
+ uno::Reference<text::XTextRange> xRange = xContent->getAnchor();
CPPUNIT_ASSERT_EQUAL(OUString("Illustration 1"), xRange->getString());
}
{
uno::Reference<text::XTextContent> xContent(xBookmarksByName->getByName("Ref_Illustration0_caption_only"), uno::UNO_QUERY);
- uno::Reference<text::XTextRange> xRange(xContent->getAnchor(), uno::UNO_QUERY);
+ uno::Reference<text::XTextRange> xRange = xContent->getAnchor();
CPPUNIT_ASSERT_EQUAL(OUString("A picture"), xRange->getString());
}
{
uno::Reference<text::XTextContent> xContent(xBookmarksByName->getByName("Ref_Illustration0_number_only"), uno::UNO_QUERY);
- uno::Reference<text::XTextRange> xRange(xContent->getAnchor(), uno::UNO_QUERY);
+ uno::Reference<text::XTextRange> xRange = xContent->getAnchor();
CPPUNIT_ASSERT_EQUAL(OUString("1"), xRange->getString());
}
{
uno::Reference<text::XTextContent> xContent(xBookmarksByName->getByName("Ref_Illustration1_caption_only"), uno::UNO_QUERY);
- uno::Reference<text::XTextRange> xRange(xContent->getAnchor(), uno::UNO_QUERY);
+ uno::Reference<text::XTextRange> xRange = xContent->getAnchor();
CPPUNIT_ASSERT_EQUAL(OUString("an other image"), xRange->getString());
}
// Cross references to text frames
{
uno::Reference<text::XTextContent> xContent(xBookmarksByName->getByName("Ref_Text0_full"), uno::UNO_QUERY);
- uno::Reference<text::XTextRange> xRange(xContent->getAnchor(), uno::UNO_QUERY);
+ uno::Reference<text::XTextRange> xRange = xContent->getAnchor();
CPPUNIT_ASSERT_EQUAL(OUString("Text 1: A frame"), xRange->getString());
}
{
uno::Reference<text::XTextContent> xContent(xBookmarksByName->getByName("Ref_Text0_label_and_number"), uno::UNO_QUERY);
- uno::Reference<text::XTextRange> xRange(xContent->getAnchor(), uno::UNO_QUERY);
+ uno::Reference<text::XTextRange> xRange = xContent->getAnchor();
CPPUNIT_ASSERT_EQUAL(OUString("Text 1"), xRange->getString());
}
{
uno::Reference<text::XTextContent> xContent(xBookmarksByName->getByName("Ref_Text0_caption_only"), uno::UNO_QUERY);
- uno::Reference<text::XTextRange> xRange(xContent->getAnchor(), uno::UNO_QUERY);
+ uno::Reference<text::XTextRange> xRange = xContent->getAnchor();
CPPUNIT_ASSERT_EQUAL(OUString("A frame"), xRange->getString());
}
{
uno::Reference<text::XTextContent> xContent(xBookmarksByName->getByName("Ref_Text0_number_only"), uno::UNO_QUERY);
- uno::Reference<text::XTextRange> xRange(xContent->getAnchor(), uno::UNO_QUERY);
+ uno::Reference<text::XTextRange> xRange = xContent->getAnchor();
CPPUNIT_ASSERT_EQUAL(OUString("1"), xRange->getString());
}
{
uno::Reference<text::XTextContent> xContent(xBookmarksByName->getByName("Ref_Text1_label_and_number"), uno::UNO_QUERY);
- uno::Reference<text::XTextRange> xRange(xContent->getAnchor(), uno::UNO_QUERY);
+ uno::Reference<text::XTextRange> xRange = xContent->getAnchor();
CPPUNIT_ASSERT_EQUAL(OUString("Text 2"), xRange->getString());
}
}
diff --git a/sw/qa/extras/ww8export/ww8export3.cxx b/sw/qa/extras/ww8export/ww8export3.cxx
index 20de0969805a..dfb20c81fc67 100644
--- a/sw/qa/extras/ww8export/ww8export3.cxx
+++ b/sw/qa/extras/ww8export/ww8export3.cxx
@@ -159,7 +159,7 @@ DECLARE_WW8EXPORT_TEST(testTdf120225_textControlCrossRef, "tdf120225_textControl
uno::Reference<text::XBookmarksSupplier> xBookmarksSupplier(mxComponent, uno::UNO_QUERY);
uno::Reference<container::XIndexAccess> xBookmarksByIdx(xBookmarksSupplier->getBookmarks(), uno::UNO_QUERY);
- uno::Reference<container::XNameAccess> xBookmarksByName(xBookmarksSupplier->getBookmarks(), uno::UNO_QUERY);
+ uno::Reference<container::XNameAccess> xBookmarksByName = xBookmarksSupplier->getBookmarks();
// TextFields should not be turned into real bookmarks.
CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0), xBookmarksByIdx->getCount());