Hi, is it possible to get a XTextTable object from the current cursor position?
I'm going to search for matching words in the document text and check if those words are inside table cells, then modify the matching words and also insert new rows.
I'm using c++ bindings.
Get XTextTable from current cursor position.
Get XTextTable from current cursor position.
OpenOffice 4 on Windows 10
Re: Get XTextTable from current cursor position.
Hi,
maybe the basic code helps:
maybe the basic code helps:
Code: Select all
Sub get_currentTexttable
oController = ThisComponent.CurrentController
oViewCursor = oController.getViewCursor
if not isEmpty(oViewCursor.TextTable) then
oTextTable = oViewCursor.TextTable 'oTexttable is the object
print oTextTable.Name
end if
End Sub
- MMove 1.0.6
- Extension for easy, exact positioning of shapes, pictures, controls, frames ...
- my current system
- Windows 10 AOO, LOLinux Mint AOO, LO
Re: Get XTextTable from current cursor position.
How am I writing this in c++?
Im having a hard time to understand how I'm supposed to write all those basic examples in c++.
I can't really find any good information about this.
Im having a hard time to understand how I'm supposed to write all those basic examples in c++.
I can't really find any good information about this.
OpenOffice 4 on Windows 10
Re: Get XTextTable from current cursor position.
I recorded the commands to get the TextTable object in C++ with MRI.
I don't do C++ but I hope that helps. The equivalent in Basic is
Code: Select all
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/frame/XController.hpp>
#include <com/sun/star/frame/XModel.hpp>
#include <com/sun/star/text/XTextTable.hpp>
#include <com/sun/star/text/XTextViewCursor.hpp>
#include <com/sun/star/text/XTextViewCursorSupplier.hpp>
#include <com/sun/star/uno/XComponentContext.hpp>
#include <com/sun/star/uno/XInterface.hpp>
using namespace ::com::sun::star::beans;
using namespace ::com::sun::star::frame;
using namespace ::com::sun::star::lang;
using namespace ::com::sun::star::text;
using namespace ::com::sun::star::uno;
using namespace ::rtl;
void snippet(const Reference< XComponentContext > &xContext, const Reference< XInterface > &oInitialTarget)
{
try
{
Reference< XModel > xModel(oInitialTarget, UNO_QUERY);
Reference< XController > xController = xModel->getCurrentController();
Reference< XTextViewCursorSupplier > xTextViewCursorSupplier(xController, UNO_QUERY);
Reference< XTextViewCursor > xTextViewCursor = xTextViewCursorSupplier->getViewCursor();
Reference< XPropertySet > xPropSet(xTextViewCursor, UNO_QUERY);
XTextTable xTextTable;
xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("TextTable"))) >>= xTextTable;
}
catch (WrappedTargetException &e)
{
// getPropertyValue
//printf(OUStringToOString(e.Message, RTL_TEXTENCODING_ASCII_US).getStr());
}
catch (UnknownPropertyException &e)
{
// getPropertyValue
//printf(OUStringToOString(e.Message, RTL_TEXTENCODING_ASCII_US).getStr());
}
}
Code: Select all
oCurrentController = ThisComponent.getCurrentController()
oViewCursor = oCurrentController.getViewCursor()
oTextTable = oViewCursor.TextTable
OpenOffice 4.1 on Windows 10 and Linux Mint
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.