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 #ifndef _UNOCRSRHELPER_HXX 28 #define _UNOCRSRHELPER_HXX 29 30 #include <map> 31 32 #include <com/sun/star/beans/XPropertyState.hpp> 33 #include <com/sun/star/beans/XPropertySet.hpp> 34 35 #include <swtypes.hxx> 36 #include <pam.hxx> 37 38 39 class String; 40 class SfxItemSet; 41 class SfxItemPropertySet; 42 struct SfxItemPropertySimpleEntry; 43 class SwTxtNode; 44 class SwPaM; 45 class SwCursor; 46 class SwUnoCrsr; 47 class SwFmtColl; 48 struct SwSortOptions; 49 class SwDoc; 50 51 namespace com{ namespace sun{ namespace star{ 52 namespace uno{ 53 class Any; 54 } 55 namespace beans{ 56 struct PropertyValue; 57 } 58 namespace text { 59 class XTextContent; 60 } 61 }}} 62 63 /* -----------------03.12.98 12:16------------------- 64 * 65 * --------------------------------------------------*/ 66 enum SwGetPropertyStatesCaller 67 { 68 SW_PROPERTY_STATE_CALLER_DEFAULT, 69 SW_PROPERTY_STATE_CALLER_SWX_TEXT_PORTION, 70 SW_PROPERTY_STATE_CALLER_SINGLE_VALUE_ONLY, 71 SW_PROPERTY_STATE_CALLER_SWX_TEXT_PORTION_TOLERANT 72 }; 73 74 /* -----------------------------14.12.00 15:06-------------------------------- 75 76 ---------------------------------------------------------------------------*/ 77 namespace SwUnoCursorHelper 78 { 79 // keep Any's mapped by (WhichId << 16 ) + (MemberId) 80 typedef std::map< sal_uInt32, com::sun::star::uno::Any *> AnyMapHelper_t; 81 class SwAnyMapHelper : public AnyMapHelper_t 82 { 83 public: 84 ~SwAnyMapHelper(); 85 86 void SetValue( sal_uInt16 nWhichId, sal_uInt16 nMemberId, const com::sun::star::uno::Any& rAny ); 87 bool FillValue( sal_uInt16 nWhichId, sal_uInt16 nMemberId, const com::sun::star::uno::Any*& pAny ); 88 }; 89 90 ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextContent > 91 GetNestedTextContent(SwTxtNode & rTextNode, xub_StrLen const nIndex, 92 bool const bParent); 93 94 sal_Bool getCrsrPropertyValue(const SfxItemPropertySimpleEntry& rEntry 95 , SwPaM& rPam 96 , com::sun::star::uno::Any *pAny 97 , com::sun::star::beans::PropertyState& eState 98 , const SwTxtNode* pNode = 0 ); 99 100 void GetCurPageStyle(SwPaM& rPaM, String &rString); 101 102 inline sal_Bool IsStartOfPara(SwPaM& rUnoCrsr) 103 { return rUnoCrsr.GetPoint()->nContent == 0;} 104 inline sal_Bool IsEndOfPara(SwPaM& rUnoCrsr) 105 { return rUnoCrsr.GetCntntNode() && 106 rUnoCrsr.GetPoint()->nContent == rUnoCrsr.GetCntntNode()->Len();} 107 108 void resetCrsrPropertyValue(const SfxItemPropertySimpleEntry& rEntry, SwPaM& rPam); 109 void InsertFile(SwUnoCrsr* pUnoCrsr, 110 const String& rURL, 111 const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& rOptions 112 ) throw( com::sun::star::lang::IllegalArgumentException, com::sun::star::io::IOException, com::sun::star::uno::RuntimeException ); 113 114 void getNumberingProperty( 115 SwPaM& rPam, 116 com::sun::star::beans::PropertyState& eState, 117 com::sun::star::uno::Any *pAny ); 118 119 void setNumberingProperty( 120 const com::sun::star::uno::Any& rValue, 121 SwPaM& rPam); 122 123 sal_Int16 IsNodeNumStart( 124 SwPaM& rPam, 125 com::sun::star::beans::PropertyState& eState); 126 127 sal_Bool DocInsertStringSplitCR( SwDoc &rDoc, 128 const SwPaM &rNewCursor, const String &rText, 129 const bool bForceExpandHints ); 130 void makeRedline( SwPaM& rPaM, const ::rtl::OUString& RedlineType, 131 const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& RedlineProperties ) 132 throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); 133 134 135 /// @param bTableMode: attributes should be applied to a table selection 136 void SetCrsrAttr(SwPaM & rPam, const SfxItemSet & rSet, 137 const SetAttrMode nAttrMode, 138 const bool bTableMode = false); 139 void GetCrsrAttr(SwPaM & rPam, SfxItemSet & rSet, 140 const bool bOnlyTxtAttr = false, 141 const bool bGetFromChrFmt = true); 142 void GetTextFromPam(SwPaM & rPam, ::rtl::OUString & rBuffer); 143 SwFmtColl * GetCurTxtFmtColl(SwPaM & rPam, const bool bConditional); 144 145 void SelectPam(SwPaM & rPam, const bool bExpand); 146 void SetString(SwCursor & rCursor, const ::rtl::OUString & rString); 147 148 ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > 149 CreateSortDescriptor(const bool bFromTable); 150 sal_Bool ConvertSortProperties( 151 const ::com::sun::star::uno::Sequence< 152 ::com::sun::star::beans::PropertyValue >& rDescriptor, 153 SwSortOptions & rSortOpt); 154 155 /// @param bTableMode: attributes should be applied to a table selection 156 void SetPropertyValue( 157 SwPaM& rPaM, 158 const SfxItemPropertySet & rPropSet, 159 const ::rtl::OUString & rPropertyName, 160 const ::com::sun::star::uno::Any & rValue, 161 const SetAttrMode nAttrMode = nsSetAttrMode::SETATTR_DEFAULT, 162 const bool bTableMode = false) 163 throw (::com::sun::star::beans::UnknownPropertyException, 164 ::com::sun::star::beans::PropertyVetoException, 165 ::com::sun::star::lang::IllegalArgumentException, 166 ::com::sun::star::lang::WrappedTargetException, 167 ::com::sun::star::uno::RuntimeException); 168 ::com::sun::star::uno::Any GetPropertyValue( 169 SwPaM& rPaM, 170 const SfxItemPropertySet & rPropSet, 171 const ::rtl::OUString & rPropertyName) 172 throw (::com::sun::star::beans::UnknownPropertyException, 173 ::com::sun::star::lang::WrappedTargetException, 174 ::com::sun::star::uno::RuntimeException); 175 ::com::sun::star::uno::Sequence< 176 ::com::sun::star::beans::PropertyState > GetPropertyStates( 177 SwPaM & rPaM, 178 const SfxItemPropertySet & rPropSet, 179 const ::com::sun::star::uno::Sequence< ::rtl::OUString >& 180 rPropertyNames, 181 const SwGetPropertyStatesCaller eCaller = 182 SW_PROPERTY_STATE_CALLER_DEFAULT) 183 throw (::com::sun::star::beans::UnknownPropertyException, 184 ::com::sun::star::uno::RuntimeException); 185 ::com::sun::star::beans::PropertyState GetPropertyState( 186 SwPaM & rPaM, 187 const SfxItemPropertySet & rPropSet, 188 const ::rtl::OUString & rPropertyName) 189 throw (::com::sun::star::beans::UnknownPropertyException, 190 ::com::sun::star::uno::RuntimeException); 191 void SetPropertyToDefault( 192 SwPaM & rPaM, 193 const SfxItemPropertySet & rPropSet, 194 const ::rtl::OUString & rPropertyName) 195 throw (::com::sun::star::beans::UnknownPropertyException, 196 ::com::sun::star::uno::RuntimeException); 197 ::com::sun::star::uno::Any GetPropertyDefault( 198 SwPaM & rPaM, 199 const SfxItemPropertySet & rPropSet, 200 const ::rtl::OUString & rPropertyName) 201 throw (::com::sun::star::beans::UnknownPropertyException, 202 ::com::sun::star::lang::WrappedTargetException, 203 ::com::sun::star::uno::RuntimeException); 204 205 bool SetPageDesc( 206 const ::com::sun::star::uno::Any& rValue, 207 SwDoc & rDoc, SfxItemSet & rSet); 208 void SetTxtFmtColl(const ::com::sun::star::uno::Any & rAny, SwPaM & rPaM) 209 throw (::com::sun::star::lang::IllegalArgumentException); 210 bool SetCursorPropertyValue( 211 SfxItemPropertySimpleEntry const& rEntry, 212 ::com::sun::star::uno::Any const& rValue, 213 SwPaM & rPam, SfxItemSet & rItemSet) 214 throw (::com::sun::star::lang::IllegalArgumentException); 215 216 } // namespace SwUnoCursorHelper 217 218 #endif 219