1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 #ifndef _UNOFLATPARA_HXX 29 #define _UNOFLATPARA_HXX 30 31 #include <cppuhelper/implbase1.hxx> 32 #include <com/sun/star/lang/XUnoTunnel.hpp> 33 #include <com/sun/star/text/XFlatParagraph.hpp> 34 #include <com/sun/star/text/XFlatParagraphIterator.hpp> 35 #include <calbck.hxx> 36 #include <modeltoviewhelper.hxx> 37 #include <unotextmarkup.hxx> 38 39 #include <set> 40 41 namespace css = com::sun::star; 42 43 namespace com { namespace sun { namespace star { namespace container { 44 class XStringKeyMap; 45 } } } } 46 47 class SwTxtNode; 48 class SwDoc; 49 50 /****************************************************************************** 51 * SwXFlatParagraph 52 ******************************************************************************/ 53 54 class SwXFlatParagraph: 55 public ::cppu::WeakImplHelper2 56 < 57 css::text::XFlatParagraph, 58 css::lang::XUnoTunnel 59 >, 60 public SwXTextMarkup 61 { 62 public: 63 SwXFlatParagraph( SwTxtNode& rTxtNode, rtl::OUString aExpandText, const ModelToViewHelper::ConversionMap* pConversionMap ); 64 virtual ~SwXFlatParagraph(); 65 66 virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& aType ) throw(::com::sun::star::uno::RuntimeException); 67 virtual void SAL_CALL acquire( ) throw(); 68 virtual void SAL_CALL release( ) throw(); 69 70 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw(::com::sun::star::uno::RuntimeException); 71 virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId( ) throw(::com::sun::star::uno::RuntimeException); 72 73 // text::XTextMarkup: 74 virtual css::uno::Reference< css::container::XStringKeyMap > SAL_CALL getMarkupInfoContainer() throw (css::uno::RuntimeException); 75 virtual void SAL_CALL commitTextMarkup(::sal_Int32 nType, const ::rtl::OUString & aIdentifier, ::sal_Int32 nStart, ::sal_Int32 nLength, const css::uno::Reference< css::container::XStringKeyMap > & xMarkupInfoContainer) throw (css::uno::RuntimeException); 76 77 // text::XFlatParagraph: 78 virtual ::rtl::OUString SAL_CALL getText() throw (css::uno::RuntimeException); 79 virtual ::sal_Bool SAL_CALL isModified() throw (css::uno::RuntimeException); 80 virtual void SAL_CALL setChecked(::sal_Int32 nType, ::sal_Bool bVal) throw (css::uno::RuntimeException); 81 virtual ::sal_Bool SAL_CALL isChecked(::sal_Int32 nType) throw (css::uno::RuntimeException); 82 virtual css::lang::Locale SAL_CALL getLanguageOfText(::sal_Int32 nPos, ::sal_Int32 nLen) throw (css::uno::RuntimeException, css::lang::IllegalArgumentException); 83 virtual css::lang::Locale SAL_CALL getPrimaryLanguageOfText(::sal_Int32 nPos, ::sal_Int32 nLen) throw (css::uno::RuntimeException, css::lang::IllegalArgumentException); 84 virtual void SAL_CALL changeText(::sal_Int32 nPos, ::sal_Int32 nLen, const ::rtl::OUString & aNewText, const css::uno::Sequence< css::beans::PropertyValue > & aAttributes) throw (css::uno::RuntimeException, css::lang::IllegalArgumentException); 85 virtual void SAL_CALL changeAttributes(::sal_Int32 nPos, ::sal_Int32 nLen, const css::uno::Sequence< css::beans::PropertyValue > & aAttributes) throw (css::uno::RuntimeException, css::lang::IllegalArgumentException); 86 virtual css::uno::Sequence< ::sal_Int32 > SAL_CALL getLanguagePortions() throw (css::uno::RuntimeException); 87 88 const SwTxtNode* getTxtNode() const; 89 90 static const css::uno::Sequence< sal_Int8 >& getUnoTunnelId(); 91 92 // XUnoTunnel 93 virtual sal_Int64 SAL_CALL getSomething(const css::uno::Sequence< sal_Int8 >& rId) 94 throw (css::uno::RuntimeException); 95 96 private: 97 SwXFlatParagraph( const SwXFlatParagraph & ); // not defined 98 SwXFlatParagraph & operator = ( const SwXFlatParagraph & ); // not defined 99 100 rtl::OUString maExpandText; 101 }; 102 103 /****************************************************************************** 104 * SwXFlatParagraphIterator 105 ******************************************************************************/ 106 107 class SwXFlatParagraphIterator: 108 public ::cppu::WeakImplHelper1 109 < 110 css::text::XFlatParagraphIterator 111 >, 112 public SwClient // to get notified when doc is closed... 113 { 114 public: 115 SwXFlatParagraphIterator( SwDoc& rDoc, sal_Int32 nType, sal_Bool bAutomatic ); 116 virtual ~SwXFlatParagraphIterator(); 117 118 // text::XFlatParagraphIterator: 119 virtual css::uno::Reference< css::text::XFlatParagraph > SAL_CALL getFirstPara() throw (css::uno::RuntimeException); 120 virtual css::uno::Reference< css::text::XFlatParagraph > SAL_CALL getNextPara() throw (css::uno::RuntimeException); 121 virtual css::uno::Reference< css::text::XFlatParagraph > SAL_CALL getLastPara() throw (css::uno::RuntimeException); 122 virtual css::uno::Reference< css::text::XFlatParagraph > SAL_CALL getParaBefore(const css::uno::Reference< css::text::XFlatParagraph > & xPara) throw (css::uno::RuntimeException, css::lang::IllegalArgumentException); 123 virtual css::uno::Reference< css::text::XFlatParagraph > SAL_CALL getParaAfter(const css::uno::Reference< css::text::XFlatParagraph > & xPara) throw (css::uno::RuntimeException, css::lang::IllegalArgumentException); 124 125 protected: 126 // SwClient 127 virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew ); 128 129 private: 130 SwXFlatParagraphIterator( const SwXFlatParagraphIterator & ); // not defined 131 SwXFlatParagraphIterator & operator =(const SwXFlatParagraphIterator & ); // not defined 132 133 // container to hold the 'hard' references as long as necessary and valid 134 std::set< css::uno::Reference< css::text::XFlatParagraph > > m_aFlatParaList; 135 136 SwDoc* mpDoc; 137 const sal_Int32 mnType; 138 const sal_Bool mbAutomatic; 139 140 sal_uLong mnCurrentNode; // used for non-automatic mode 141 sal_uLong mnStartNode; // used for non-automatic mode 142 sal_uLong mnEndNode; // used for non-automatic mode 143 sal_Bool mbWrapped; // used for non-automatic mode 144 }; 145 146 #endif 147