| 1 | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
| 2 | /* |
| 3 | * This file is part of the LibreOffice project. |
| 4 | * |
| 5 | * This Source Code Form is subject to the terms of the Mozilla Public |
| 6 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
| 7 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. |
| 8 | * |
| 9 | * This file incorporates work covered by the following license notice: |
| 10 | * |
| 11 | * Licensed to the Apache Software Foundation (ASF) under one or more |
| 12 | * contributor license agreements. See the NOTICE file distributed |
| 13 | * with this work for additional information regarding copyright |
| 14 | * ownership. The ASF licenses this file to you under the Apache |
| 15 | * License, Version 2.0 (the "License"); you may not use this file |
| 16 | * except in compliance with the License. You may obtain a copy of |
| 17 | * the License at http://www.apache.org/licenses/LICENSE-2.0 . |
| 18 | */ |
| 19 | |
| 20 | #pragma once |
| 21 | |
| 22 | #include <cppuhelper/implbase.hxx> |
| 23 | |
| 24 | #include <com/sun/star/beans/XPropertySet.hpp> |
| 25 | #include <com/sun/star/text/XFlatParagraph.hpp> |
| 26 | #include <com/sun/star/text/XFlatParagraphIterator.hpp> |
| 27 | #include <svl/listener.hxx> |
| 28 | #include "unotextmarkup.hxx" |
| 29 | #include <nodeoffset.hxx> |
| 30 | |
| 31 | #include <set> |
| 32 | |
| 33 | class SwTextNode; |
| 34 | class SwDoc; |
| 35 | class ModelToViewHelper; |
| 36 | |
| 37 | typedef ::cppu::ImplInheritanceHelper |
| 38 | < SwXTextMarkup |
| 39 | , css::beans::XPropertySet |
| 40 | , css::text::XFlatParagraph |
| 41 | > SwXFlatParagraph_Base; |
| 42 | |
| 43 | class SwXFlatParagraph final |
| 44 | : public SwXFlatParagraph_Base |
| 45 | { |
| 46 | public: |
| 47 | SwXFlatParagraph( SwTextNode& rTextNode, OUString aExpandText, const ModelToViewHelper& rConversionMap ); |
| 48 | virtual ~SwXFlatParagraph() override; |
| 49 | |
| 50 | // XPropertySet |
| 51 | virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL |
| 52 | getPropertySetInfo() override; |
| 53 | virtual void SAL_CALL setPropertyValue( |
| 54 | const OUString& rPropertyName, |
| 55 | const css::uno::Any& rValue) override; |
| 56 | virtual css::uno::Any SAL_CALL getPropertyValue( |
| 57 | const OUString& rPropertyName) override; |
| 58 | virtual void SAL_CALL addPropertyChangeListener( |
| 59 | const OUString& rPropertyName, |
| 60 | const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener) override; |
| 61 | virtual void SAL_CALL removePropertyChangeListener( |
| 62 | const OUString& rPropertyName, |
| 63 | const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener) override; |
| 64 | virtual void SAL_CALL addVetoableChangeListener( |
| 65 | const OUString& rPropertyName, |
| 66 | const css::uno::Reference< css::beans::XVetoableChangeListener >& xListener) override; |
| 67 | virtual void SAL_CALL removeVetoableChangeListener( |
| 68 | const OUString& rPropertyName, |
| 69 | const css::uno::Reference< css::beans::XVetoableChangeListener >& xListener) override; |
| 70 | |
| 71 | // text::XTextMarkup: |
| 72 | virtual css::uno::Reference< css::container::XStringKeyMap > SAL_CALL getMarkupInfoContainer() override; |
| 73 | |
| 74 | virtual void SAL_CALL commitStringMarkup(::sal_Int32 nType, const OUString & aIdentifier, ::sal_Int32 nStart, ::sal_Int32 nLength, |
| 75 | const css::uno::Reference< css::container::XStringKeyMap > & xMarkupInfoContainer) override; |
| 76 | |
| 77 | virtual void SAL_CALL commitTextRangeMarkup(::sal_Int32 nType, const OUString & aIdentifier, const css::uno::Reference< css::text::XTextRange> & xRange, |
| 78 | const css::uno::Reference< css::container::XStringKeyMap > & xMarkupInfoContainer) override; |
| 79 | |
| 80 | // text::XFlatParagraph: |
| 81 | virtual OUString SAL_CALL getText() override; |
| 82 | virtual sal_Bool SAL_CALL isModified() override; |
| 83 | virtual void SAL_CALL setChecked(::sal_Int32 nType, sal_Bool bVal) override; |
| 84 | virtual sal_Bool SAL_CALL isChecked(::sal_Int32 nType) override; |
| 85 | virtual css::lang::Locale SAL_CALL getLanguageOfText(::sal_Int32 nPos, ::sal_Int32 nLen) override; |
| 86 | virtual css::lang::Locale SAL_CALL getPrimaryLanguageOfText(::sal_Int32 nPos, ::sal_Int32 nLen) override; |
| 87 | virtual void SAL_CALL changeText(::sal_Int32 nPos, ::sal_Int32 nLen, const OUString & aNewText, const css::uno::Sequence< css::beans::PropertyValue > & aAttributes) override; |
| 88 | virtual void SAL_CALL changeAttributes(::sal_Int32 nPos, ::sal_Int32 nLen, const css::uno::Sequence< css::beans::PropertyValue > & aAttributes) override; |
| 89 | virtual css::uno::Sequence< ::sal_Int32 > SAL_CALL getLanguagePortions() override; |
| 90 | |
| 91 | using SwXTextMarkup::GetTextNode; |
| 92 | |
| 93 | private: |
| 94 | SwXFlatParagraph( const SwXFlatParagraph & ) = delete; |
| 95 | SwXFlatParagraph & operator = ( const SwXFlatParagraph & ) = delete; |
| 96 | |
| 97 | OUString maExpandText; |
| 98 | OUString maOrigText; |
| 99 | }; |
| 100 | |
| 101 | class SwXFlatParagraphIterator final : |
| 102 | public ::cppu::WeakImplHelper |
| 103 | < |
| 104 | css::text::XFlatParagraphIterator |
| 105 | >, |
| 106 | public SvtListener |
| 107 | { |
| 108 | public: |
| 109 | SwXFlatParagraphIterator( SwDoc& rDoc, sal_Int32 nType, bool bAutomatic ); |
| 110 | virtual ~SwXFlatParagraphIterator() override; |
| 111 | |
| 112 | // text::XFlatParagraphIterator: |
| 113 | virtual css::uno::Reference< css::text::XFlatParagraph > SAL_CALL getFirstPara() override; |
| 114 | virtual css::uno::Reference< css::text::XFlatParagraph > SAL_CALL getNextPara() override; |
| 115 | virtual css::uno::Reference< css::text::XFlatParagraph > SAL_CALL getLastPara() override; |
| 116 | virtual css::uno::Reference< css::text::XFlatParagraph > SAL_CALL getParaBefore(const css::uno::Reference< css::text::XFlatParagraph > & xPara) override; |
| 117 | virtual css::uno::Reference< css::text::XFlatParagraph > SAL_CALL getParaAfter(const css::uno::Reference< css::text::XFlatParagraph > & xPara) override; |
| 118 | |
| 119 | virtual void Notify( const SfxHint& ) override; |
| 120 | |
| 121 | private: |
| 122 | SwXFlatParagraphIterator( const SwXFlatParagraphIterator & ) = delete; |
| 123 | SwXFlatParagraphIterator & operator =(const SwXFlatParagraphIterator & ) = delete; |
| 124 | |
| 125 | SwDoc* mpDoc; |
| 126 | const sal_Int32 mnType; |
| 127 | const bool mbAutomatic; |
| 128 | |
| 129 | SwNodeOffset mnCurrentNode; // used for non-automatic mode |
| 130 | SwNodeOffset mnEndNode; // used for non-automatic mode |
| 131 | }; |
| 132 | |
| 133 | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |