23 #include <ooo/vba/word/WdBreakType.hpp>
24 #include <com/sun/star/style/BreakType.hpp>
25 #include <com/sun/star/text/ControlCharacter.hpp>
26 #include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
27 #include <com/sun/star/text/XTextRangeCompare.hpp>
28 #include <com/sun/star/text/XTextViewCursor.hpp>
44 SwVbaRange::SwVbaRange(
const uno::Reference< ooo::vba::XHelperInterface >& rParent,
const uno::Reference< uno::XComponentContext >& rContext,
const uno::Reference< text::XTextDocument >& rTextDocument,
const uno::Reference< text::XTextRange >& rStart ) :
SwVbaRange_BASE( rParent, rContext ), mxTextDocument( rTextDocument )
46 uno::Reference< text::XTextRange > xEnd;
47 initialize( rStart, xEnd );
50 SwVbaRange::SwVbaRange(
const uno::Reference< ooo::vba::XHelperInterface >& rParent,
const uno::Reference< uno::XComponentContext >& rContext,
const uno::Reference< text::XTextDocument >& rTextDocument,
const uno::Reference< text::XTextRange >& rStart,
const uno::Reference< text::XTextRange >& rEnd ) :
SwVbaRange_BASE( rParent, rContext ), mxTextDocument( rTextDocument )
52 initialize( rStart, rEnd );
55 SwVbaRange::SwVbaRange(
const uno::Reference< ooo::vba::XHelperInterface >& rParent,
const uno::Reference< uno::XComponentContext >& rContext,
const uno::Reference< text::XTextDocument >& rTextDocument,
const uno::Reference< text::XTextRange >& rStart,
const uno::Reference< text::XTextRange >& rEnd,
const uno::Reference< text::XText >& rText ) :
SwVbaRange_BASE( rParent, rContext ),mxTextDocument( rTextDocument ),
mxText( rText )
57 initialize( rStart, rEnd );
64 void SwVbaRange::initialize(
const uno::Reference< text::XTextRange >& rStart,
const uno::Reference< text::XTextRange >& rEnd )
73 throw uno::RuntimeException(
"Fails to create text cursor" );
82 uno::Reference< text::XTextRange > SAL_CALL
85 uno::Reference< text::XTextRange > xTextRange(
mxTextCursor, uno::UNO_QUERY_THROW );
98 sal_Int32 nLen = aText.getLength();
111 uno::Reference< text::XTextRange > xStart =
mxTextCursor->getStart();
112 uno::Reference< text::XTextRange > xEnd =
mxTextCursor->getEnd();
129 uno::Reference< text::XTextRange > xRange(
mxTextCursor, uno::UNO_QUERY_THROW );
135 uno::Reference< container::XNamed > xNamed( xBookmark, uno::UNO_QUERY_THROW );
136 sName = xNamed->getName();
139 catch (
const uno::Exception&)
144 if( rText.indexOf(
'\n' ) != -1 )
156 if( !sName.isEmpty() )
158 uno::Reference< text::XBookmarksSupplier > xBookmarksSupplier(
mxTextDocument, uno::UNO_QUERY_THROW );
159 uno::Reference< container::XNameAccess > xNameAccess( xBookmarksSupplier->getBookmarks(), uno::UNO_SET_THROW );
160 if( !xNameAccess->hasByName( sName ) )
172 sal_Int32 nBreakType = word::WdBreakType::wdPageBreak;
174 _breakType >>= nBreakType;
176 style::BreakType eBreakType = style::BreakType_NONE;
179 case word::WdBreakType::wdPageBreak:
180 eBreakType = style::BreakType_PAGE_BEFORE;
182 case word::WdBreakType::wdColumnBreak:
183 eBreakType = style::BreakType_COLUMN_AFTER;
185 case word::WdBreakType::wdLineBreak:
186 case word::WdBreakType::wdLineBreakClearLeft:
187 case word::WdBreakType::wdLineBreakClearRight:
188 case word::WdBreakType::wdSectionBreakContinuous:
189 case word::WdBreakType::wdSectionBreakEvenPage:
190 case word::WdBreakType::wdSectionBreakNextPage:
191 case word::WdBreakType::wdSectionBreakOddPage:
192 case word::WdBreakType::wdTextWrappingBreak:
199 if( eBreakType != style::BreakType_NONE )
207 uno::Reference< beans::XPropertySet > xProp(
mxTextCursor, uno::UNO_QUERY_THROW );
208 xProp->setPropertyValue(
"BreakType", uno::makeAny( eBreakType ) );
217 xTextViewCursor->gotoRange(
mxTextCursor->getStart(), false );
218 xTextViewCursor->gotoRange(
mxTextCursor->getEnd(), true );
231 uno::Reference< text::XTextRange > xTextRange =
mxTextCursor->getStart();
232 mxText->insertControlCharacter( xTextRange, text::ControlCharacter::PARAGRAPH_BREAK,
true );
239 uno::Reference< text::XTextRange > xTextRange =
mxTextCursor->getEnd();
240 mxText->insertControlCharacter( xTextRange, text::ControlCharacter::PARAGRAPH_BREAK,
true );
243 uno::Reference< word::XParagraphFormat > SAL_CALL
246 uno::Reference< beans::XPropertySet > xParaProps(
mxTextCursor, uno::UNO_QUERY_THROW );
253 throw uno::RuntimeException(
"Not implemented" );
258 uno::Reference< beans::XPropertySet > xProp(
mxTextCursor, uno::UNO_QUERY_THROW );
259 if( ( xProp->getPropertyValue(
"CharStyleName") >>= aStyleName ) && !aStyleName.isEmpty() )
261 aStyleType =
"CharacterStyles";
263 else if( ( xProp->getPropertyValue(
"ParaStyleName") >>= aStyleName ) && !aStyleName.isEmpty() )
265 aStyleType =
"ParagraphStyles";
267 if( aStyleType.isEmpty() )
279 uno::Reference< style::XStyleFamiliesSupplier > xStyleSupplier(
mxTextDocument, uno::UNO_QUERY_THROW);
280 uno::Reference< container::XNameAccess > xStylesAccess( xStyleSupplier->getStyleFamilies()->getByName( aStyleType ), uno::UNO_QUERY_THROW );
281 uno::Reference< beans::XPropertySet > xStyleProps( xStylesAccess->getByName( aStyleName ), uno::UNO_QUERY_THROW );
283 return uno::makeAny( uno::Reference< word::XStyle >(
new SwVbaStyle(
this,
mxContext, xModel, xStyleProps ) ) );
289 uno::Reference< beans::XPropertySet > xParaProps(
mxTextCursor, uno::UNO_QUERY_THROW );
293 uno::Reference< word::XFont > SAL_CALL
300 uno::Reference< word::XListFormat > SAL_CALL
308 uno::Reference< beans::XPropertySet > xParaProps(
mxTextCursor, uno::UNO_QUERY_THROW );
314 uno::Reference< beans::XPropertySet > xParaProps(
mxTextCursor, uno::UNO_QUERY_THROW );
321 uno::Reference< beans::XPropertySet > xParaProps(
mxTextCursor, uno::UNO_QUERY_THROW );
323 OUString aPageStyleName;
324 xParaProps->getPropertyValue(
"PageStyleName") >>= aPageStyleName;
325 uno::Reference< style::XStyleFamiliesSupplier > xSytleFamSupp( xModel, uno::UNO_QUERY_THROW );
326 uno::Reference< container::XNameAccess > xSytleFamNames( xSytleFamSupp->getStyleFamilies(), uno::UNO_SET_THROW );
327 uno::Reference< container::XNameAccess > xPageStyles( xSytleFamNames->getByName(
"PageStyles"), uno::UNO_QUERY_THROW );
328 uno::Reference< beans::XPropertySet > xPageProps( xPageStyles->getByName( aPageStyleName ), uno::UNO_QUERY_THROW );
329 return uno::makeAny( uno::Reference< word::XPageSetup >(
new SwVbaPageSetup(
this,
mxContext, xModel, xPageProps ) ) );
342 uno::Reference< text::XTextRange > xEnd =
mxTextCursor->getEnd();
367 throw uno::RuntimeException();
368 uno::Reference< text::XTextRange > xTextRange = pRange->
getXTextRange();
369 uno::Reference< text::XTextRangeCompare > xTRC(
mxTextCursor->getText(), uno::UNO_QUERY_THROW );
370 if( xTRC->compareRegionStarts( xTextRange,
getXTextRange() ) >= 0 && xTRC->compareRegionEnds( xTextRange,
getXTextRange() ) <= 0 )
378 uno::Reference< text::XTextRange > xTextRange =
getXTextRange();
382 return xCol->Item( index,
uno::Any() );
383 return uno::makeAny( xCol );
389 uno::Reference< text::XTextRange > xTextRange =
getXTextRange();
393 return xCol->Item( index,
uno::Any() );
394 return uno::makeAny( xCol );
404 return xCol->Item( index,
uno::Any() );
405 return uno::makeAny( xCol );
414 uno::Sequence< OUString >
static css::uno::Reference< css::text::XTextContent > findBookmarkByPosition(const css::uno::Reference< css::text::XTextDocument > &xTextDoc, const css::uno::Reference< css::text::XTextRange > &xTextRange)
static css::uno::Reference< css::text::XTextCursor > initCursor(const css::uno::Reference< css::text::XTextRange > &rTextRange, const css::uno::Reference< css::text::XText > &rText)
virtual sal_Bool SAL_CALL InRange(const css::uno::Reference< ::ooo::vba::word::XRange > &Range) override
virtual void SAL_CALL setText(const OUString &rText) override
virtual css::uno::Any SAL_CALL Revisions(const css::uno::Any &aIndex) override
virtual css::uno::Any SAL_CALL getStyle() override
virtual void SAL_CALL setLanguageID(::sal_Int32 _languageid) override
virtual ::sal_Int32 SAL_CALL getStart() override
Sequence< OUString > aServiceNames
css::uno::Reference< css::text::XTextDocument > mxTextDocument
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::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.
#define ERRCODE_BASIC_NOT_IMPLEMENTED
virtual css::uno::Reference< ooo::vba::word::XParagraphFormat > SAL_CALL getParagraphFormat() override
virtual css::uno::Reference< css::text::XTextRange > SAL_CALL getXTextRange() override
uno::Reference< text::XTextViewCursor > getXTextViewCursor(const uno::Reference< frame::XModel > &xModel)
virtual ~SwVbaRange() override
virtual css::uno::Reference< ooo::vba::word::XListFormat > SAL_CALL getListFormat() override
virtual ::sal_Int32 SAL_CALL getEnd() override
virtual css::uno::Reference< ooo::vba::word::XFont > SAL_CALL getFont() override
virtual void SAL_CALL Select() override
void GetStyleInfo(OUString &aStyleName, OUString &aStyleType)
virtual css::uno::Any SAL_CALL PageSetup() override
virtual void SAL_CALL InsertParagraphAfter() override
static void insertString(css::uno::Reference< css::text::XTextRange > const &rTextRange, css::uno::Reference< css::text::XText > const &rText, const OUString &rStr, bool _bAbsorb)
virtual ::sal_Int32 SAL_CALL getLanguageID() override
virtual css::uno::Any SAL_CALL Fields(const css::uno::Any &aIndex) 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 ::sal_Int32 SAL_CALL getLanguageID() override
const css::uno::Reference< css::container::XIndexAccess > & getPalette() const
virtual void SAL_CALL setStart(::sal_Int32 _start) override
css::uno::WeakReference< ov::XHelperInterface > mxParent
Reference< text::XText > mxText
static void setStyle(const css::uno::Reference< css::beans::XPropertySet > &xParaProps, const css::uno::Any &xStyle)
#define ERRCODE_BASIC_BAD_PARAMETER
virtual void SAL_CALL InsertParagraph() override
css::uno::Reference< css::text::XTextCursor > mxTextCursor
virtual OUString getServiceImplName() override
static void addBookmarkByName(const css::uno::Reference< css::frame::XModel > &xModel, const OUString &rName, const css::uno::Reference< css::text::XTextRange > &rTextRange)
css::uno::Reference< css::uno::XComponentContext > mxContext
SwVbaRange(const css::uno::Reference< ooo::vba::XHelperInterface > &rParent, const css::uno::Reference< css::uno::XComponentContext > &rContext, const css::uno::Reference< css::text::XTextDocument > &rTextDocument, const css::uno::Reference< css::text::XTextRange > &rStart)
#define ERRCODE_BASIC_INTERNAL_ERROR
virtual css::uno::Any SAL_CALL Sections(const css::uno::Any &aIndex) override
void initialize(const css::uno::Reference< css::text::XTextRange > &rStart, const css::uno::Reference< css::text::XTextRange > &rEnd)
virtual css::uno::Sequence< OUString > getServiceNames() override
virtual void SAL_CALL setEnd(::sal_Int32 _end) override
css::uno::Reference< css::text::XText > mxText
virtual void SAL_CALL setParagraphFormat(const css::uno::Reference< ooo::vba::word::XParagraphFormat > &rParagraphFormat) override
virtual void SAL_CALL setStyle(const css::uno::Any &_xStyle) override
Reference< XModel > xModel
virtual void SAL_CALL InsertBreak(const css::uno::Any &_breakType) override
static void setLanguageID(const css::uno::Reference< css::beans::XPropertySet > &xTCProps, LanguageType _languageid)
virtual void SAL_CALL InsertParagraphBefore() override