https://bugs.documentfoundation.org/show_bug.cgi?id=156776

--- Comment #25 from Lionel Elie Mamane <lio...@mamane.lu> ---
For discussion on code, you can use gerrit's "draft" or "work in progress"
feature (which makes the change not visible publicly, and I think also not
auto-built by Jenkins), and then invite the persons you want to discuss with.

See https://gerritcodereview-test.gsrc.io/marking-a-change-as-a-wip.html

(In reply to prrvchr from comment #24)
> Although I added XConnection2 to the file offapi/UnoApi_offapi.mk, I got an
> error:

> /home/prrvchr/github/libreoffice/dbaccess/source/ui/dlg/dlgsave.cxx: In
> constructor ‘dbaui::OSaveAsDlg::OSaveAsDlg(weld::Window*, sal_Int32, const
> com::sun::star::uno::Reference<com::sun::star::uno::XComponentContext>&,
> const com::sun::star::uno::Reference<com::sun::star::sdbc::XConnection>&,
> const rtl::OUString&, const dbaui::IObjectNameCheck&, SADFlags)’:
> /home/prrvchr/github/libreoffice/dbaccess/source/ui/dlg/dlgsave.cxx:134:41:
> error: ‘class com::sun::star::sdbc::XConnection’ has no member named
> ‘getSchema’
>   134 |                 sSchema = _xConnection->getSchema();
>       |                                         ^~~~~~~~~
> 
> I missed something...

_xConnection is a reference to com::sun::star::sdbc::XConnection while
getSchema() is defined in com::sun::star::sdbc::XConnection2. You need to cast
_xConnection to a (reference to a) com::sun::star::sdbc::XConnection2 _and_
since there is not guarantee that the object referred to by _xConnection
implements com::sun::star::sdbc::XConnection2, before using it, check that the
cast gave a non-NULL result.


1. Add #include <com/sun/star/sdbc/XConnection2.hpp> in the list of #includes
at the beginning of the file

2. The cast actually happens rather automatically, IIRC the code to write is:

   const Reference< XConnection2 > xCon2(_xConnection);
   if (xCon2.is())
   {
      sSchema = _xConnection->getSchema();
   }
   else
   {
      deal with the situation otherwise... e.g. as it is done now
   }

-- 
You are receiving this mail because:
You are the assignee for the bug.

Reply via email to