Branch libreoffice-5-0-4
[LibreOffice.git] / sw / inc / unocrsrhelper.hxx
bloba7bd39e0ab40ff06a8cf42e0913b61351a484118
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
19 #ifndef INCLUDED_SW_INC_UNOCRSRHELPER_HXX
20 #define INCLUDED_SW_INC_UNOCRSRHELPER_HXX
22 #include <boost/ptr_container/ptr_map.hpp>
24 #include <com/sun/star/beans/XPropertyState.hpp>
25 #include <com/sun/star/beans/XPropertySet.hpp>
26 #include <com/sun/star/uno/DeploymentException.hpp>
28 #include <swtypes.hxx>
29 #include <flyenum.hxx>
30 #include <pam.hxx>
32 class SfxItemSet;
33 class SfxItemPropertySet;
34 struct SfxItemPropertySimpleEntry;
35 class SdrObject;
36 class SwTextNode;
37 class SwCursor;
38 class SwUnoCrsr;
39 class SwUnoTableCrsr;
40 class SwFormatColl;
41 struct SwSortOptions;
42 class SwDoc;
44 namespace sw { namespace mark { class IMark; } }
46 namespace com{ namespace sun{ namespace star{
47 namespace uno{
48 class Any;
50 namespace beans{
51 struct PropertyValue;
53 namespace text {
54 class XTextContent;
55 class XFlatParagraphIterator;
57 }}}
59 enum SwGetPropertyStatesCaller
61 SW_PROPERTY_STATE_CALLER_DEFAULT,
62 SW_PROPERTY_STATE_CALLER_SWX_TEXT_PORTION,
63 SW_PROPERTY_STATE_CALLER_SINGLE_VALUE_ONLY,
64 SW_PROPERTY_STATE_CALLER_SWX_TEXT_PORTION_TOLERANT
67 namespace SwUnoCursorHelper
69 class SwAnyMapHelper
71 // keep Any's mapped by (WhichId << 16 ) + (MemberId)
72 boost::ptr_map<sal_uInt32,com::sun::star::uno::Any> maMap;
73 public:
74 void SetValue( sal_uInt16 nWhichId, sal_uInt16 nMemberId, const com::sun::star::uno::Any& rAny );
75 bool FillValue( sal_uInt16 nWhichId, sal_uInt16 nMemberId, const com::sun::star::uno::Any*& pAny );
78 ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextContent >
79 GetNestedTextContent(SwTextNode & rTextNode, sal_Int32 const nIndex,
80 bool const bParent);
82 bool getCrsrPropertyValue(const SfxItemPropertySimpleEntry& rEntry
83 , SwPaM& rPam
84 , com::sun::star::uno::Any *pAny
85 , com::sun::star::beans::PropertyState& eState
86 , const SwTextNode* pNode = 0 );
88 void GetCurPageStyle(SwPaM& rPaM, OUString &rString);
90 inline bool IsStartOfPara(SwPaM& rUnoCrsr)
91 { return rUnoCrsr.GetPoint()->nContent == 0;}
92 inline bool IsEndOfPara(SwPaM& rUnoCrsr)
93 { return rUnoCrsr.GetContentNode() &&
94 rUnoCrsr.GetPoint()->nContent == rUnoCrsr.GetContentNode()->Len();}
96 void resetCrsrPropertyValue(const SfxItemPropertySimpleEntry& rEntry, SwPaM& rPam);
97 void InsertFile(SwUnoCrsr* pUnoCrsr,
98 const OUString& rURL,
99 const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& rOptions)
100 throw (com::sun::star::lang::IllegalArgumentException,
101 com::sun::star::io::IOException,
102 com::sun::star::uno::RuntimeException,
103 std::exception);
105 void getNumberingProperty(
106 SwPaM& rPam,
107 com::sun::star::beans::PropertyState& eState,
108 com::sun::star::uno::Any *pAny );
110 void setNumberingProperty(
111 const com::sun::star::uno::Any& rValue,
112 SwPaM& rPam);
114 sal_Int16 IsNodeNumStart(
115 SwPaM& rPam,
116 com::sun::star::beans::PropertyState& eState);
118 bool DocInsertStringSplitCR( SwDoc &rDoc,
119 const SwPaM &rNewCursor, const OUString &rText,
120 const bool bForceExpandHints );
121 void makeRedline( SwPaM& rPaM, const OUString& RedlineType,
122 const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& RedlineProperties )
123 throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
125 void makeTableRowRedline( SwTableLine& rTableLine, const OUString& RedlineType,
126 const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& RedlineProperties )
127 throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
129 void makeTableCellRedline( SwTableBox& rTableBox, const OUString& RedlineType,
130 const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& RedlineProperties )
131 throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
133 /// @param bTableMode: attributes should be applied to a table selection
134 void SetCrsrAttr(SwPaM & rPam, const SfxItemSet & rSet,
135 const SetAttrMode nAttrMode,
136 const bool bTableMode = false);
137 void GetCrsrAttr(SwPaM & rPam, SfxItemSet & rSet,
138 const bool bOnlyTextAttr = false,
139 const bool bGetFromChrFormat = true);
140 void GetTextFromPam(SwPaM & rPam, OUString & rBuffer);
141 SwFormatColl * GetCurTextFormatColl(SwPaM & rPam, const bool bConditional);
143 void SelectPam(SwPaM & rPam, const bool bExpand);
144 void SetString(SwCursor & rCursor, const OUString & rString);
146 ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >
147 CreateSortDescriptor(const bool bFromTable);
148 bool ConvertSortProperties(
149 const ::com::sun::star::uno::Sequence<
150 ::com::sun::star::beans::PropertyValue >& rDescriptor,
151 SwSortOptions & rSortOpt);
153 /// @param bTableMode: attributes should be applied to a table selection
154 void SetPropertyValue(
155 SwPaM& rPaM,
156 const SfxItemPropertySet & rPropSet,
157 const OUString & rPropertyName,
158 const ::com::sun::star::uno::Any & rValue,
159 const SetAttrMode nAttrMode = SetAttrMode::DEFAULT,
160 const bool bTableMode = false)
161 throw (::com::sun::star::beans::UnknownPropertyException,
162 ::com::sun::star::beans::PropertyVetoException,
163 ::com::sun::star::lang::IllegalArgumentException,
164 ::com::sun::star::lang::WrappedTargetException,
165 ::com::sun::star::uno::RuntimeException);
166 /// @param bTableMode: attributes should be applied to a table selection
167 void SetPropertyValues(
168 SwPaM& rPaM,
169 const SfxItemPropertySet & rPropSet,
170 const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > &
171 rPropertyValues,
172 const SetAttrMode nAttrMode = SetAttrMode::DEFAULT,
173 const bool bTableMode = false)
174 throw (::com::sun::star::beans::UnknownPropertyException,
175 ::com::sun::star::beans::PropertyVetoException,
176 ::com::sun::star::lang::IllegalArgumentException,
177 ::com::sun::star::lang::WrappedTargetException,
178 ::com::sun::star::uno::RuntimeException);
179 ::com::sun::star::uno::Any GetPropertyValue(
180 SwPaM& rPaM,
181 const SfxItemPropertySet & rPropSet,
182 const OUString & rPropertyName)
183 throw (::com::sun::star::beans::UnknownPropertyException,
184 ::com::sun::star::lang::WrappedTargetException,
185 ::com::sun::star::uno::RuntimeException);
186 ::com::sun::star::uno::Sequence<
187 ::com::sun::star::beans::PropertyState > GetPropertyStates(
188 SwPaM & rPaM,
189 const SfxItemPropertySet & rPropSet,
190 const ::com::sun::star::uno::Sequence< OUString >&
191 rPropertyNames,
192 const SwGetPropertyStatesCaller eCaller =
193 SW_PROPERTY_STATE_CALLER_DEFAULT)
194 throw (::com::sun::star::beans::UnknownPropertyException,
195 ::com::sun::star::uno::RuntimeException);
196 ::com::sun::star::beans::PropertyState GetPropertyState(
197 SwPaM & rPaM,
198 const SfxItemPropertySet & rPropSet,
199 const OUString & rPropertyName)
200 throw (::com::sun::star::beans::UnknownPropertyException,
201 ::com::sun::star::uno::RuntimeException);
202 void SetPropertyToDefault(
203 SwPaM & rPaM,
204 const SfxItemPropertySet & rPropSet,
205 const OUString & rPropertyName)
206 throw (::com::sun::star::beans::UnknownPropertyException,
207 ::com::sun::star::uno::RuntimeException);
208 ::com::sun::star::uno::Any GetPropertyDefault(
209 SwPaM & rPaM,
210 const SfxItemPropertySet & rPropSet,
211 const OUString & rPropertyName)
212 throw (::com::sun::star::beans::UnknownPropertyException,
213 ::com::sun::star::lang::WrappedTargetException,
214 ::com::sun::star::uno::RuntimeException);
216 bool SetPageDesc(
217 const ::com::sun::star::uno::Any& rValue,
218 SwDoc & rDoc, SfxItemSet & rSet);
219 void SetTextFormatColl(const ::com::sun::star::uno::Any & rAny, SwPaM & rPaM)
220 throw (::com::sun::star::lang::IllegalArgumentException, css::uno::RuntimeException);
221 bool SetCursorPropertyValue(
222 SfxItemPropertySimpleEntry const& rEntry,
223 ::com::sun::star::uno::Any const& rValue,
224 SwPaM & rPam, SfxItemSet & rItemSet)
225 throw (::com::sun::star::lang::IllegalArgumentException, css::uno::RuntimeException, css::uno::DeploymentException);
227 /// try to get something that can be selected out of the XInterface
228 /// at most one of the out parameters gets assigned a non-null value
229 /// o_rpPaM is newly allocated and must be deleted; other parameters not
230 SW_DLLPUBLIC void GetSelectableFromAny(
231 ::com::sun::star::uno::Reference<
232 ::com::sun::star::uno::XInterface> const& xIfc,
233 SwDoc & rTargetDoc,
234 SwPaM *& o_rpPaM, std::pair<OUString, FlyCntType> & o_rFrame,
235 OUString & o_rTableName, SwUnoTableCrsr const*& o_rpTableCursor,
236 ::sw::mark::IMark const*& o_rpMark,
237 std::vector<SdrObject *> & o_rSdrObjects);
239 ::com::sun::star::uno::Reference<
240 ::com::sun::star::text::XFlatParagraphIterator>
241 CreateFlatParagraphIterator(SwDoc &, sal_Int32, bool);
243 } // namespace SwUnoCursorHelper
245 #endif
247 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */