Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / sw / inc / unocrsrhelper.hxx
blob11ae6b366e7972b0f3aee4c9e5d7999ec72cf0b2
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 "swtypes.hxx"
23 #include "flyenum.hxx"
24 #include "pam.hxx"
26 #include <map>
27 #include <string_view>
29 class SfxItemSet;
30 class SfxItemPropertySet;
31 struct SfxItemPropertyMapEntry;
32 class SdrObject;
33 class SwTextNode;
34 class SwCursor;
35 class SwUnoCursor;
36 class SwUnoTableCursor;
37 class SwFormatColl;
38 struct SwSortOptions;
39 class SwDoc;
40 class SwRootFrame;
42 namespace sw::mark { class IMark; }
44 namespace com::sun::star{
45 namespace beans{
46 struct PropertyValue;
47 enum class PropertyState;
49 namespace text {
50 class XTextContent;
51 class XFlatParagraphIterator;
55 enum SwGetPropertyStatesCaller
57 SW_PROPERTY_STATE_CALLER_DEFAULT,
58 SW_PROPERTY_STATE_CALLER_SWX_TEXT_PORTION,
59 SW_PROPERTY_STATE_CALLER_SINGLE_VALUE_ONLY,
60 SW_PROPERTY_STATE_CALLER_SWX_TEXT_PORTION_TOLERANT
63 namespace SwUnoCursorHelper
65 class SwAnyMapHelper
67 private:
68 // keep Any's mapped by (WhichId << 16 ) + (MemberId)
69 std::map<sal_uInt32, css::uno::Any> m_Map;
71 public:
72 void SetValue( sal_uInt16 nWhichId, sal_uInt16 nMemberId, const css::uno::Any& rAny );
73 bool FillValue( sal_uInt16 nWhichId, sal_uInt16 nMemberId, const css::uno::Any*& pAny );
76 css::uno::Reference< css::text::XTextContent >
77 GetNestedTextContent(SwTextNode const & rTextNode, sal_Int32 const nIndex,
78 bool const bParent);
80 bool getCursorPropertyValue(const SfxItemPropertyMapEntry& rEntry
81 , SwPaM& rPam
82 , css::uno::Any *pAny
83 , css::beans::PropertyState& eState
84 , const SwTextNode* pNode = nullptr );
86 void GetCurPageStyle(SwPaM const & rPaM, OUString &rString);
88 inline bool IsStartOfPara(SwPaM& rUnoCursor)
89 { return rUnoCursor.GetPoint()->GetContentIndex() == 0;}
90 inline bool IsEndOfPara(SwPaM& rUnoCursor)
91 { return rUnoCursor.GetPointContentNode() &&
92 rUnoCursor.GetPoint()->GetContentIndex() == rUnoCursor.GetPointContentNode()->Len();}
94 void resetCursorPropertyValue(const SfxItemPropertyMapEntry& rEntry, SwPaM& rPam);
95 /// @throws css::lang::IllegalArgumentException
96 /// @throws css::io::IOException
97 /// @throws css::uno::RuntimeException
98 void InsertFile(SwUnoCursor* pUnoCursor,
99 const OUString& rURL,
100 const css::uno::Sequence< css::beans::PropertyValue >& rOptions);
102 void getNumberingProperty(
103 SwPaM& rPam,
104 css::beans::PropertyState& eState,
105 css::uno::Any *pAny );
107 void setNumberingProperty(
108 const css::uno::Any& rValue,
109 SwPaM& rPam);
111 sal_Int16 IsNodeNumStart(
112 SwPaM const & rPam,
113 css::beans::PropertyState& eState);
115 bool DocInsertStringSplitCR( SwDoc &rDoc,
116 const SwPaM &rNewCursor, std::u16string_view aText,
117 const bool bForceExpandHints );
118 /// @throws css::lang::IllegalArgumentException
119 /// @throws css::uno::RuntimeException
120 void makeRedline( SwPaM const & rPaM, std::u16string_view RedlineType,
121 const css::uno::Sequence< css::beans::PropertyValue >& RedlineProperties );
123 /// @throws css::lang::IllegalArgumentException
124 /// @throws css::uno::RuntimeException
125 void makeTableRowRedline( SwTableLine& rTableLine, std::u16string_view RedlineType,
126 const css::uno::Sequence< css::beans::PropertyValue >& RedlineProperties );
128 /// @throws css::lang::IllegalArgumentException
129 /// @throws css::uno::RuntimeException
130 SW_DLLPUBLIC void makeTableCellRedline( SwTableBox& rTableBox, std::u16string_view RedlineType,
131 const css::uno::Sequence< css::beans::PropertyValue >& RedlineProperties );
133 /// @param bTableMode: attributes should be applied to a table selection
134 void SetCursorAttr(SwPaM & rPam, const SfxItemSet & rSet,
135 const SetAttrMode nAttrMode,
136 const bool bTableMode = false);
137 void GetCursorAttr(SwPaM & rPam, SfxItemSet & rSet,
138 const bool bOnlyTextAttr = false,
139 const bool bGetFromChrFormat = true);
140 void GetTextFromPam(SwPaM & rPam, OUString & rBuffer, SwRootFrame const* pLayout = nullptr);
141 SwFormatColl * GetCurTextFormatColl(SwPaM & rPam, const bool bConditional);
143 void SelectPam(SwPaM & rPam, const bool bExpand);
144 void SetString(SwCursor & rCursor, std::u16string_view aString);
146 css::uno::Sequence< css::beans::PropertyValue >
147 CreateSortDescriptor(const bool bFromTable);
148 bool ConvertSortProperties(
149 const css::uno::Sequence< css::beans::PropertyValue >& rDescriptor,
150 SwSortOptions & rSortOpt);
152 /// @throws css::beans::UnknownPropertyException
153 /// @throws css::beans::PropertyVetoException
154 /// @throws css::lang::IllegalArgumentException
155 /// @throws css::lang::WrappedTargetException
156 /// @throws css::uno::RuntimeException
157 void SetPropertyValue(
158 SwPaM& rPaM,
159 const SfxItemPropertySet & rPropSet,
160 const OUString & rPropertyName,
161 const css::uno::Any & rValue,
162 const SetAttrMode nAttrMode = SetAttrMode::DEFAULT);
163 /// @throws css::beans::UnknownPropertyException
164 /// @throws css::beans::PropertyVetoException
165 /// @throws css::lang::IllegalArgumentException
166 /// @throws css::lang::WrappedTargetException
167 /// @throws css::uno::RuntimeException
168 void SetPropertyValues(
169 SwPaM& rPaM,
170 const SfxItemPropertySet & rPropSet,
171 const css::uno::Sequence< css::beans::PropertyValue > &
172 rPropertyValues,
173 const SetAttrMode nAttrMode = SetAttrMode::DEFAULT);
174 void SetPropertyValues(
175 SwPaM& rPaM,
176 const SfxItemPropertySet & rPropSet,
177 o3tl::span< const css::beans::PropertyValue > aPropertyValues,
178 const SetAttrMode nAttrMode = SetAttrMode::DEFAULT);
179 /// @throws css::beans::UnknownPropertyException
180 /// @throws css::lang::WrappedTargetException
181 /// @throws css::uno::RuntimeException
182 css::uno::Any GetPropertyValue(
183 SwPaM& rPaM,
184 const SfxItemPropertySet & rPropSet,
185 std::u16string_view rPropertyName);
186 /// @throws css::beans::UnknownPropertyException
187 /// @throws css::uno::RuntimeException
188 css::uno::Sequence< css::beans::PropertyState > GetPropertyStates(
189 SwPaM & rPaM,
190 const SfxItemPropertySet & rPropSet,
191 const css::uno::Sequence< OUString >&
192 rPropertyNames,
193 const SwGetPropertyStatesCaller eCaller =
194 SW_PROPERTY_STATE_CALLER_DEFAULT);
195 /// @throws css::beans::UnknownPropertyException
196 /// @throws css::uno::RuntimeException
197 css::beans::PropertyState GetPropertyState(
198 SwPaM & rPaM,
199 const SfxItemPropertySet & rPropSet,
200 const OUString & rPropertyName);
201 /// @throws css::beans::UnknownPropertyException
202 /// @throws css::uno::RuntimeException
203 void SetPropertyToDefault(
204 SwPaM & rPaM,
205 const SfxItemPropertySet & rPropSet,
206 std::u16string_view rPropertyName);
207 /// @throws css::beans::UnknownPropertyException
208 /// @throws css::lang::WrappedTargetException
209 /// @throws css::uno::RuntimeException
210 css::uno::Any GetPropertyDefault(
211 SwPaM const & rPaM,
212 const SfxItemPropertySet & rPropSet,
213 std::u16string_view rPropertyName);
215 bool SetPageDesc(
216 const css::uno::Any& rValue,
217 SwDoc & rDoc, SfxItemSet & rSet);
218 /// @throws css::lang::IllegalArgumentException
219 /// @throws css::uno::RuntimeException
220 void SetTextFormatColl(const css::uno::Any & rAny, SwPaM & rPaM);
221 /// @throws css::lang::IllegalArgumentException
222 /// @throws css::uno::RuntimeException
223 /// @throws css::uno::DeploymentException
224 bool SetCursorPropertyValue(
225 SfxItemPropertyMapEntry const& rEntry,
226 css::uno::Any const& rValue,
227 SwPaM & rPam, SfxItemSet & rItemSet);
229 /// try to get something that can be selected out of the XInterface
230 /// at most one of the out parameters gets assigned a non-null value
231 /// o_rpPaM is newly allocated and must be deleted; other parameters not
232 SW_DLLPUBLIC void GetSelectableFromAny(
233 css::uno::Reference<css::uno::XInterface> const& xIfc,
234 SwDoc & rTargetDoc,
235 SwPaM *& o_rpPaM, std::pair<OUString, FlyCntType> & o_rFrame,
236 OUString & o_rTableName, SwUnoTableCursor const*& o_rpTableCursor,
237 ::sw::mark::IMark const*& o_rpMark,
238 std::vector<SdrObject *> & o_rSdrObjects);
240 css::uno::Reference<css::text::XFlatParagraphIterator>
241 CreateFlatParagraphIterator(SwDoc &, sal_Int32, bool);
243 } // namespace SwUnoCursorHelper
245 #endif
247 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */