24#include <ooo/vba/word/WdBreakType.hpp> 
   25#include <com/sun/star/style/BreakType.hpp> 
   26#include <com/sun/star/text/ControlCharacter.hpp> 
   27#include <com/sun/star/style/XStyleFamiliesSupplier.hpp> 
   28#include <com/sun/star/text/XTextRangeCompare.hpp> 
   29#include <com/sun/star/text/XTextViewCursor.hpp> 
   46SwVbaRange::SwVbaRange( 
const uno::Reference< ooo::vba::XHelperInterface >& rParent, 
const uno::Reference< uno::XComponentContext >& rContext, uno::Reference< text::XTextDocument > xTextDocument, 
const uno::Reference< text::XTextRange >& rStart ) : 
SwVbaRange_BASE( rParent, rContext ), mxTextDocument(
std::move( xTextDocument ))
 
   48    uno::Reference< text::XTextRange > xEnd;
 
   49    initialize( rStart, xEnd );
 
   52SwVbaRange::SwVbaRange( 
const uno::Reference< ooo::vba::XHelperInterface >& rParent, 
const uno::Reference< uno::XComponentContext >& rContext, uno::Reference< text::XTextDocument > xTextDocument, 
const uno::Reference< text::XTextRange >& rStart, 
const uno::Reference< text::XTextRange >& rEnd ) : 
SwVbaRange_BASE( rParent, rContext ), mxTextDocument(
std::move( xTextDocument ))
 
   54    initialize( rStart, rEnd );
 
   57SwVbaRange::SwVbaRange( 
const uno::Reference< ooo::vba::XHelperInterface >& rParent, 
const uno::Reference< uno::XComponentContext >& rContext, uno::Reference< text::XTextDocument > xTextDocument, 
const uno::Reference< text::XTextRange >& rStart, 
const uno::Reference< text::XTextRange >& rEnd, uno::Reference< text::XText > xText ) : 
SwVbaRange_BASE( rParent, rContext ),mxTextDocument(
std::move( xTextDocument )), 
mxText(
std::move( xText ))
 
   59    initialize( rStart, rEnd );
 
   66void SwVbaRange::initialize( 
const uno::Reference< text::XTextRange >& rStart, 
const uno::Reference< text::XTextRange >& rEnd )
 
   75        throw uno::RuntimeException(
"Fails to create text cursor" );
 
   84uno::Reference< text::XTextRange > SAL_CALL
 
   87    uno::Reference< text::XTextRange > xTextRange( 
mxTextCursor, uno::UNO_QUERY_THROW );
 
  100    sal_Int32 nLen = aText.getLength();
 
  113            uno::Reference< text::XTextRange > xStart = 
mxTextCursor->getStart();
 
  114            uno::Reference< text::XTextRange > xEnd = 
mxTextCursor->getEnd();
 
  131    uno::Reference< text::XTextRange > xRange( 
mxTextCursor, uno::UNO_QUERY_THROW );
 
  137            uno::Reference< container::XNamed > xNamed( xBookmark, uno::UNO_QUERY_THROW );
 
  138            sName = xNamed->getName();
 
  141    catch (
const uno::Exception&)
 
  146    if( rText.indexOf( 
'\n' )  != -1 )
 
  158    if( !
sName.isEmpty() )
 
  160        uno::Reference< text::XBookmarksSupplier > xBookmarksSupplier( 
mxTextDocument, uno::UNO_QUERY_THROW );
 
  161        uno::Reference< container::XNameAccess > xNameAccess( xBookmarksSupplier->getBookmarks(), uno::UNO_SET_THROW );
 
  162        if( !xNameAccess->hasByName( 
sName ) )
 
  174    sal_Int32 nBreakType = word::WdBreakType::wdPageBreak;
 
  176        _breakType >>= nBreakType;
 
  178    style::BreakType eBreakType = style::BreakType_NONE;
 
  181        case word::WdBreakType::wdPageBreak:
 
  182            eBreakType = style::BreakType_PAGE_BEFORE;
 
  184        case word::WdBreakType::wdColumnBreak:
 
  185            eBreakType = style::BreakType_COLUMN_AFTER;
 
  187        case word::WdBreakType::wdLineBreak:
 
  188        case word::WdBreakType::wdLineBreakClearLeft:
 
  189        case word::WdBreakType::wdLineBreakClearRight:
 
  190        case word::WdBreakType::wdSectionBreakContinuous:
 
  191        case word::WdBreakType::wdSectionBreakEvenPage:
 
  192        case word::WdBreakType::wdSectionBreakNextPage:
 
  193        case word::WdBreakType::wdSectionBreakOddPage:
 
  194        case word::WdBreakType::wdTextWrappingBreak:
 
  201    if( eBreakType != style::BreakType_NONE )
 
  209        uno::Reference< beans::XPropertySet > xProp( 
mxTextCursor, uno::UNO_QUERY_THROW );
 
  210        xProp->setPropertyValue(
"BreakType", 
uno::Any( eBreakType ) );
 
  219    xTextViewCursor->gotoRange( 
mxTextCursor->getStart(), 
false );
 
  220    xTextViewCursor->gotoRange( 
mxTextCursor->getEnd(), 
true );
 
  233    uno::Reference< text::XTextRange > xTextRange = 
mxTextCursor->getStart();
 
  234    mxText->insertControlCharacter( xTextRange, text::ControlCharacter::PARAGRAPH_BREAK, 
true );
 
  241    uno::Reference< text::XTextRange > xTextRange = 
mxTextCursor->getEnd();
 
  242    mxText->insertControlCharacter( xTextRange, text::ControlCharacter::PARAGRAPH_BREAK, 
true );
 
  245uno::Reference< word::XParagraphFormat > SAL_CALL
 
  248    uno::Reference< beans::XPropertySet > xParaProps( 
mxTextCursor, uno::UNO_QUERY_THROW );
 
  255    throw uno::RuntimeException(
"Not implemented" );
 
  260    uno::Reference< beans::XPropertySet > xProp( 
mxTextCursor, uno::UNO_QUERY_THROW );
 
  261    if( ( xProp->getPropertyValue(
"CharStyleName") >>= aStyleName ) && !aStyleName.isEmpty() )
 
  263        aStyleType = 
"CharacterStyles";
 
  265    else if( ( xProp->getPropertyValue(
"ParaStyleName") >>= aStyleName ) && !aStyleName.isEmpty() )
 
  267        aStyleType = 
"ParagraphStyles";
 
  269    if( aStyleType.isEmpty() )
 
  281    uno::Reference< style::XStyleFamiliesSupplier > xStyleSupplier( 
mxTextDocument, uno::UNO_QUERY_THROW);
 
  282    uno::Reference< container::XNameAccess > xStylesAccess( xStyleSupplier->getStyleFamilies()->getByName( aStyleType ), uno::UNO_QUERY_THROW );
 
  283    uno::Reference< beans::XPropertySet > xStyleProps( xStylesAccess->getByName( aStyleName ), uno::UNO_QUERY_THROW );
 
  291    uno::Reference< beans::XPropertySet > xParaProps( 
mxTextCursor, uno::UNO_QUERY_THROW );
 
  295uno::Reference< word::XFont > SAL_CALL
 
  302uno::Reference< word::XFind > SAL_CALL
 
  305    uno::Reference< text::XTextRange > xTextRange = 
getXTextRange();
 
  310uno::Reference< word::XListFormat > SAL_CALL
 
  318    uno::Reference< beans::XPropertySet > xParaProps( 
mxTextCursor, uno::UNO_QUERY_THROW );
 
  324    uno::Reference< beans::XPropertySet > xParaProps( 
mxTextCursor, uno::UNO_QUERY_THROW );
 
  331    uno::Reference< beans::XPropertySet > xParaProps( 
mxTextCursor, uno::UNO_QUERY_THROW );
 
  333    OUString aPageStyleName;
 
  334    xParaProps->getPropertyValue(
"PageStyleName") >>= aPageStyleName;
 
  335    uno::Reference< style::XStyleFamiliesSupplier > xSytleFamSupp( 
xModel, uno::UNO_QUERY_THROW );
 
  336    uno::Reference< container::XNameAccess > xSytleFamNames( xSytleFamSupp->getStyleFamilies(), uno::UNO_SET_THROW );
 
  337    uno::Reference< container::XNameAccess > xPageStyles( xSytleFamNames->getByName(
"PageStyles"), uno::UNO_QUERY_THROW );
 
  338    uno::Reference< beans::XPropertySet > xPageProps( xPageStyles->getByName( aPageStyleName ), uno::UNO_QUERY_THROW );
 
  352    uno::Reference< text::XTextRange > xEnd = 
mxTextCursor->getEnd();
 
  377        throw uno::RuntimeException();
 
  378    uno::Reference< text::XTextRange > xTextRange = pRange->
getXTextRange();
 
  379    uno::Reference< text::XTextRangeCompare > xTRC( 
mxTextCursor->getText(), uno::UNO_QUERY_THROW );
 
  380    if( xTRC->compareRegionStarts( xTextRange, 
getXTextRange() ) >= 0 && xTRC->compareRegionEnds( xTextRange, 
getXTextRange() ) <= 0 )
 
  388    uno::Reference< text::XTextRange > xTextRange = 
getXTextRange();
 
  391    if ( 
index.hasValue() )
 
  399    uno::Reference< text::XTextRange > xTextRange = 
getXTextRange();
 
  402    if ( 
index.hasValue() )
 
  413    if ( 
index.hasValue() )
 
  424uno::Sequence< OUString >
 
css::uno::Reference< css::uno::XComponentContext > mxContext
 
css::uno::WeakReference< ov::XHelperInterface > mxParent
 
static void addBookmarkByName(const css::uno::Reference< css::frame::XModel > &xModel, const OUString &rName, const css::uno::Reference< css::text::XTextRange > &rTextRange)
 
static css::uno::Reference< ooo::vba::word::XFind > GetOrCreateFind(const css::uno::Reference< ooo::vba::XHelperInterface > &rParent, const css::uno::Reference< com::sun::star::uno::XComponentContext > &rContext, const css::uno::Reference< com::sun::star::frame::XModel > &xModel, const css::uno::Reference< css::text::XTextRange > &xTextRange)
 
static void insertString(css::uno::Reference< css::text::XTextRange > const &rTextRange, css::uno::Reference< css::text::XText > const &rText, std::u16string_view aStr, bool _bAbsorb)
 
static sal_Int32 getPosition(const css::uno::Reference< css::text::XText > &rText, const css::uno::Reference< css::text::XTextRange > &rTextRange)
 
static css::uno::Reference< css::text::XTextCursor > initCursor(const css::uno::Reference< css::text::XTextRange > &rTextRange, const css::uno::Reference< css::text::XText > &rText)
 
static css::uno::Reference< css::text::XTextRange > getRangeByPosition(const css::uno::Reference< css::text::XText > &rText, sal_Int32 _position)
get a range in a xText by creating a cursor that iterates over the text.
 
static css::uno::Reference< css::text::XTextContent > findBookmarkByPosition(const css::uno::Reference< css::text::XTextDocument > &xTextDoc, const css::uno::Reference< css::text::XTextRange > &xTextRange)
 
virtual ::sal_Int32 SAL_CALL getStart() override
 
void initialize(const css::uno::Reference< css::text::XTextRange > &rStart, const css::uno::Reference< css::text::XTextRange > &rEnd)
 
virtual void SAL_CALL setText(const OUString &rText) override
 
virtual css::uno::Any SAL_CALL Revisions(const css::uno::Any &aIndex) override
 
css::uno::Reference< css::text::XTextDocument > mxTextDocument
 
virtual css::uno::Any SAL_CALL getStyle() override
 
virtual OUString SAL_CALL getText() override
The complexity in this method is because we need to workaround an issue that the last paragraph in a ...
 
virtual void SAL_CALL InsertParagraph() override
 
virtual void SAL_CALL setParagraphFormat(const css::uno::Reference< ooo::vba::word::XParagraphFormat > &rParagraphFormat) override
 
virtual css::uno::Reference< ooo::vba::word::XFont > SAL_CALL getFont() override
 
virtual css::uno::Reference< css::text::XTextRange > SAL_CALL getXTextRange() override
 
virtual void SAL_CALL Select() override
 
virtual void SAL_CALL setStart(::sal_Int32 _start) override
 
virtual css::uno::Sequence< OUString > getServiceNames() override
 
virtual void SAL_CALL setEnd(::sal_Int32 _end) override
 
virtual css::uno::Any SAL_CALL PageSetup() override
 
virtual ::sal_Int32 SAL_CALL getEnd() override
 
virtual css::uno::Reference< ooo::vba::word::XListFormat > SAL_CALL getListFormat() override
 
virtual css::uno::Reference< ooo::vba::word::XFind > SAL_CALL getFind() override
 
virtual css::uno::Any SAL_CALL Fields(const css::uno::Any &aIndex) override
 
SwVbaRange(const css::uno::Reference< ooo::vba::XHelperInterface > &rParent, const css::uno::Reference< css::uno::XComponentContext > &rContext, css::uno::Reference< css::text::XTextDocument > xTextDocument, const css::uno::Reference< css::text::XTextRange > &rStart)
 
virtual css::uno::Reference< ooo::vba::word::XParagraphFormat > SAL_CALL getParagraphFormat() override
 
void GetStyleInfo(OUString &aStyleName, OUString &aStyleType)
 
virtual void SAL_CALL setLanguageID(::sal_Int32 _languageid) override
 
virtual OUString getServiceImplName() override
 
virtual void SAL_CALL InsertParagraphBefore() override
 
virtual sal_Bool SAL_CALL InRange(const css::uno::Reference< ::ooo::vba::word::XRange > &Range) override
 
css::uno::Reference< css::text::XText > mxText
 
virtual css::uno::Any SAL_CALL Sections(const css::uno::Any &aIndex) override
 
virtual void SAL_CALL InsertParagraphAfter() override
 
virtual ::sal_Int32 SAL_CALL getLanguageID() override
 
css::uno::Reference< css::text::XTextCursor > mxTextCursor
 
virtual void SAL_CALL setStyle(const css::uno::Any &_xStyle) override
 
virtual ~SwVbaRange() override
 
virtual void SAL_CALL InsertBreak(const css::uno::Any &_breakType) override
 
virtual ::sal_Int32 SAL_CALL getLanguageID() override
 
static void setStyle(const css::uno::Reference< css::beans::XPropertySet > &xParaProps, const css::uno::Any &xStyle)
 
static void setLanguageID(const css::uno::Reference< css::beans::XPropertySet > &xTCProps, LanguageType _languageid)
 
const css::uno::Reference< css::container::XIndexAccess > & getPalette() const
 
Sequence< OUString > aServiceNames
 
uno::Reference< text::XTextViewCursor > getXTextViewCursor(const uno::Reference< frame::XModel > &xModel)
 
Reference< text::XText > mxText
 
#define ERRCODE_BASIC_BAD_PARAMETER
 
#define ERRCODE_BASIC_INTERNAL_ERROR
 
#define ERRCODE_BASIC_NOT_IMPLEMENTED
 
Reference< XModel > xModel