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