1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 #ifndef _UNOCRSRHELPER_HXX 24 #define _UNOCRSRHELPER_HXX 25 26 #include <map> 27 28 #include <com/sun/star/beans/XPropertyState.hpp> 29 #include <com/sun/star/beans/XPropertySet.hpp> 30 31 #include <swtypes.hxx> 32 #include <pam.hxx> 33 34 35 class String; 36 class SfxItemSet; 37 class SfxItemPropertySet; 38 struct SfxItemPropertySimpleEntry; 39 class SwTxtNode; 40 class SwPaM; 41 class SwCursor; 42 class SwUnoCrsr; 43 class SwFmtColl; 44 struct SwSortOptions; 45 class SwDoc; 46 47 namespace com{ namespace sun{ namespace star{ 48 namespace uno{ 49 class Any; 50 } 51 namespace beans{ 52 struct PropertyValue; 53 } 54 namespace text { 55 class XTextContent; 56 } 57 }}} 58 59 /* -----------------03.12.98 12:16------------------- 60 * 61 * --------------------------------------------------*/ 62 enum SwGetPropertyStatesCaller 63 { 64 SW_PROPERTY_STATE_CALLER_DEFAULT, 65 SW_PROPERTY_STATE_CALLER_SWX_TEXT_PORTION, 66 SW_PROPERTY_STATE_CALLER_SINGLE_VALUE_ONLY, 67 SW_PROPERTY_STATE_CALLER_SWX_TEXT_PORTION_TOLERANT 68 }; 69 70 /* -----------------------------14.12.00 15:06-------------------------------- 71 72 ---------------------------------------------------------------------------*/ 73 namespace SwUnoCursorHelper 74 { 75 // keep Any's mapped by (WhichId << 16 ) + (MemberId) 76 typedef std::map< sal_uInt32, com::sun::star::uno::Any *> AnyMapHelper_t; 77 class SwAnyMapHelper : public AnyMapHelper_t 78 { 79 public: 80 ~SwAnyMapHelper(); 81 82 void SetValue( sal_uInt16 nWhichId, sal_uInt16 nMemberId, const com::sun::star::uno::Any& rAny ); 83 bool FillValue( sal_uInt16 nWhichId, sal_uInt16 nMemberId, const com::sun::star::uno::Any*& pAny ); 84 }; 85 86 ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextContent > 87 GetNestedTextContent(SwTxtNode & rTextNode, xub_StrLen const nIndex, 88 bool const bParent); 89 90 sal_Bool getCrsrPropertyValue(const SfxItemPropertySimpleEntry& rEntry 91 , SwPaM& rPam 92 , com::sun::star::uno::Any *pAny 93 , com::sun::star::beans::PropertyState& eState 94 , const SwTxtNode* pNode = 0 ); 95 96 void GetCurPageStyle(SwPaM& rPaM, String &rString); 97 98 inline sal_Bool IsStartOfPara(SwPaM& rUnoCrsr) 99 { return rUnoCrsr.GetPoint()->nContent == 0;} 100 inline sal_Bool IsEndOfPara(SwPaM& rUnoCrsr) 101 { return rUnoCrsr.GetCntntNode() && 102 rUnoCrsr.GetPoint()->nContent == rUnoCrsr.GetCntntNode()->Len();} 103 104 void resetCrsrPropertyValue(const SfxItemPropertySimpleEntry& rEntry, SwPaM& rPam); 105 void InsertFile(SwUnoCrsr* pUnoCrsr, 106 const String& rURL, 107 const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& rOptions 108 ); 109 110 void getNumberingProperty( 111 SwPaM& rPam, 112 com::sun::star::beans::PropertyState& eState, 113 com::sun::star::uno::Any *pAny ); 114 115 void setNumberingProperty( 116 const com::sun::star::uno::Any& rValue, 117 SwPaM& rPam); 118 119 sal_Int16 IsNodeNumStart( 120 SwPaM& rPam, 121 com::sun::star::beans::PropertyState& eState); 122 123 sal_Bool DocInsertStringSplitCR( SwDoc &rDoc, 124 const SwPaM &rNewCursor, const String &rText, 125 const bool bForceExpandHints ); 126 void makeRedline( SwPaM& rPaM, const ::rtl::OUString& RedlineType, 127 const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& RedlineProperties ); 128 129 130 /// @param bTableMode: attributes should be applied to a table selection 131 void SetCrsrAttr(SwPaM & rPam, const SfxItemSet & rSet, 132 const SetAttrMode nAttrMode, 133 const bool bTableMode = false); 134 void GetCrsrAttr(SwPaM & rPam, SfxItemSet & rSet, 135 const bool bOnlyTxtAttr = false, 136 const bool bGetFromChrFmt = true); 137 void GetTextFromPam(SwPaM & rPam, ::rtl::OUString & rBuffer); 138 SwFmtColl * GetCurTxtFmtColl(SwPaM & rPam, const bool bConditional); 139 140 void SelectPam(SwPaM & rPam, const bool bExpand); 141 void SetString(SwCursor & rCursor, const ::rtl::OUString & rString); 142 143 ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > 144 CreateSortDescriptor(const bool bFromTable); 145 sal_Bool ConvertSortProperties( 146 const ::com::sun::star::uno::Sequence< 147 ::com::sun::star::beans::PropertyValue >& rDescriptor, 148 SwSortOptions & rSortOpt); 149 150 /// @param bTableMode: attributes should be applied to a table selection 151 void SetPropertyValue( 152 SwPaM& rPaM, 153 const SfxItemPropertySet & rPropSet, 154 const ::rtl::OUString & rPropertyName, 155 const ::com::sun::star::uno::Any & rValue, 156 const SetAttrMode nAttrMode = nsSetAttrMode::SETATTR_DEFAULT, 157 const bool bTableMode = false); 158 ::com::sun::star::uno::Any GetPropertyValue( 159 SwPaM& rPaM, 160 const SfxItemPropertySet & rPropSet, 161 const ::rtl::OUString & rPropertyName); 162 ::com::sun::star::uno::Sequence< 163 ::com::sun::star::beans::PropertyState > GetPropertyStates( 164 SwPaM & rPaM, 165 const SfxItemPropertySet & rPropSet, 166 const ::com::sun::star::uno::Sequence< ::rtl::OUString >& 167 rPropertyNames, 168 const SwGetPropertyStatesCaller eCaller = 169 SW_PROPERTY_STATE_CALLER_DEFAULT); 170 ::com::sun::star::beans::PropertyState GetPropertyState( 171 SwPaM & rPaM, 172 const SfxItemPropertySet & rPropSet, 173 const ::rtl::OUString & rPropertyName); 174 void SetPropertyToDefault( 175 SwPaM & rPaM, 176 const SfxItemPropertySet & rPropSet, 177 const ::rtl::OUString & rPropertyName); 178 ::com::sun::star::uno::Any GetPropertyDefault( 179 SwPaM & rPaM, 180 const SfxItemPropertySet & rPropSet, 181 const ::rtl::OUString & rPropertyName); 182 183 bool SetPageDesc( 184 const ::com::sun::star::uno::Any& rValue, 185 SwDoc & rDoc, SfxItemSet & rSet); 186 void SetTxtFmtColl(const ::com::sun::star::uno::Any & rAny, SwPaM & rPaM); 187 bool SetCursorPropertyValue( 188 SfxItemPropertySimpleEntry const& rEntry, 189 ::com::sun::star::uno::Any const& rValue, 190 SwPaM & rPam, SfxItemSet & rItemSet); 191 192 } // namespace SwUnoCursorHelper 193 194 #endif 195