1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
20 #include <com/sun/star/embed/Aspects.hpp>
21 #include <com/sun/star/embed/EmbedMisc.hpp>
22 #include <com/sun/star/embed/XEmbeddedObject.hpp>
25 #include <hintids.hxx>
26 #include <bitmaps.hlst>
27 #include <o3tl/safeint.hxx>
28 #include <vcl/mnemonic.hxx>
29 #include <svl/stritem.hxx>
30 #include <sfx2/htmlmode.hxx>
31 #include <editeng/sizeitem.hxx>
32 #include <editeng/opaqitem.hxx>
33 #include <editeng/protitem.hxx>
34 #include <editeng/prntitem.hxx>
35 #include <editeng/brushitem.hxx>
36 #include <editeng/ulspitem.hxx>
37 #include <editeng/frmdiritem.hxx>
38 #include <svx/swframeposstrings.hxx>
39 #include <svx/swframevalidation.hxx>
40 #include <comphelper/classids.hxx>
41 #include <tools/globname.hxx>
42 #include <tools/urlobj.hxx>
44 #include <fmteiro.hxx>
45 #include <fmtcnct.hxx>
46 #include <fmtsrnd.hxx>
49 #include <swmodule.hxx>
52 #include <viewopt.hxx>
55 #include <frmpage.hxx>
58 #include <fmtfollowtextflow.hxx>
59 #include <svx/sdtaitm.hxx>
60 #include <sal/macros.h>
62 #include <strings.hrc>
63 #include <svx/strings.hrc>
64 #include <svx/dialmgr.hxx>
65 #include <sfx2/filedlghelper.hxx>
66 #include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
67 #include <com/sun/star/ui/dialogs/XFilePicker3.hpp>
68 #include <com/sun/star/ui/dialogs/XFilePickerControlAccess.hpp>
69 #include <com/sun/star/ui/dialogs/ExtendedFilePickerElementIds.hpp>
70 #include <vcl/graphicfilter.hxx>
71 #include <svtools/embedhlp.hxx>
72 #include <comphelper/lok.hxx>
75 using namespace ::com::sun::star
;
76 using namespace ::sfx2
;
78 #define SwFPos SvxSwFramePosString
82 struct StringIdPair_Impl
84 SvxSwFramePosString::StringId eHori
;
85 SvxSwFramePosString::StringId eVert
;
90 #define MAX_PERCENT_WIDTH 254
91 #define MAX_PERCENT_HEIGHT 254
97 Frame
= 0x00000001L
, // text region of the paragraph
98 PrintArea
= 0x00000002L
, // text region of the paragraph + indentions
99 VertFrame
= 0x00000004L
, // vertical text region of the paragraph
100 VertPrintArea
= 0x00000008L
, // vertical text region of the paragraph + indentions
101 RelFrameLeft
= 0x00000010L
, // left paragraph edge
102 RelFrameRight
= 0x00000020L
, // right paragraph edge
104 RelPageLeft
= 0x00000040L
, // left page edge
105 RelPageRight
= 0x00000080L
, // right page edge
106 RelPageFrame
= 0x00000100L
, // whole page
107 RelPagePrintArea
= 0x00000200L
, // text region of the page
109 FlyRelPageLeft
= 0x00000400L
, // left frame edge
110 FlyRelPageRight
= 0x00000800L
, // right frame edge
111 FlyRelPageFrame
= 0x00001000L
, // whole frame
112 FlyRelPagePrintArea
= 0x00002000L
, // inside of the frame
114 RelBase
= 0x00010000L
, // character alignment Base
115 RelChar
= 0x00020000L
, // character alignment Character
116 RelRow
= 0x00040000L
, // character alignment Row
118 FlyVertFrame
= 0x00100000L
, // vertical entire frame
119 FlyVertPrintArea
= 0x00200000L
, // vertical frame text area
121 VertLine
= 0x00400000L
, // vertical text line
127 template<> struct typed_flags
<LB
> : is_typed_flags
<LB
, 0x00773fffL
> {};
134 SvxSwFramePosString::StringId eStrId
;
135 SvxSwFramePosString::StringId eMirrorStrId
;
144 SvxSwFramePosString::StringId eStrId
;
145 SvxSwFramePosString::StringId eMirrorStrId
;
151 RelationMap
const aRelationMap
[] =
153 {SwFPos::FRAME
, SwFPos::FRAME
, LB::Frame
, text::RelOrientation::FRAME
},
154 {SwFPos::PRTAREA
, SwFPos::PRTAREA
, LB::PrintArea
, text::RelOrientation::PRINT_AREA
},
155 {SwFPos::REL_PG_LEFT
, SwFPos::MIR_REL_PG_LEFT
, LB::RelPageLeft
, text::RelOrientation::PAGE_LEFT
},
156 {SwFPos::REL_PG_RIGHT
, SwFPos::MIR_REL_PG_RIGHT
, LB::RelPageRight
, text::RelOrientation::PAGE_RIGHT
},
157 {SwFPos::REL_FRM_LEFT
, SwFPos::MIR_REL_FRM_LEFT
, LB::RelFrameLeft
, text::RelOrientation::FRAME_LEFT
},
158 {SwFPos::REL_FRM_RIGHT
, SwFPos::MIR_REL_FRM_RIGHT
, LB::RelFrameRight
, text::RelOrientation::FRAME_RIGHT
},
159 {SwFPos::REL_PG_FRAME
, SwFPos::REL_PG_FRAME
, LB::RelPageFrame
, text::RelOrientation::PAGE_FRAME
},
160 {SwFPos::REL_PG_PRTAREA
, SwFPos::REL_PG_PRTAREA
, LB::RelPagePrintArea
, text::RelOrientation::PAGE_PRINT_AREA
},
161 {SwFPos::REL_CHAR
, SwFPos::REL_CHAR
, LB::RelChar
, text::RelOrientation::CHAR
},
163 {SwFPos::FLY_REL_PG_LEFT
, SwFPos::FLY_MIR_REL_PG_LEFT
, LB::FlyRelPageLeft
, text::RelOrientation::PAGE_LEFT
},
164 {SwFPos::FLY_REL_PG_RIGHT
, SwFPos::FLY_MIR_REL_PG_RIGHT
, LB::FlyRelPageRight
, text::RelOrientation::PAGE_RIGHT
},
165 {SwFPos::FLY_REL_PG_FRAME
, SwFPos::FLY_REL_PG_FRAME
, LB::FlyRelPageFrame
, text::RelOrientation::PAGE_FRAME
},
166 {SwFPos::FLY_REL_PG_PRTAREA
, SwFPos::FLY_REL_PG_PRTAREA
, LB::FlyRelPagePrintArea
, text::RelOrientation::PAGE_PRINT_AREA
},
168 {SwFPos::REL_BORDER
, SwFPos::REL_BORDER
, LB::VertFrame
, text::RelOrientation::FRAME
},
169 {SwFPos::REL_PRTAREA
, SwFPos::REL_PRTAREA
, LB::VertPrintArea
, text::RelOrientation::PRINT_AREA
},
171 {SwFPos::FLY_REL_PG_FRAME
, SwFPos::FLY_REL_PG_FRAME
, LB::FlyVertFrame
, text::RelOrientation::FRAME
},
172 {SwFPos::FLY_REL_PG_PRTAREA
, SwFPos::FLY_REL_PG_PRTAREA
, LB::FlyVertPrintArea
, text::RelOrientation::PRINT_AREA
},
174 {SwFPos::REL_LINE
, SwFPos::REL_LINE
, LB::VertLine
, text::RelOrientation::TEXT_LINE
}
177 RelationMap
const aAsCharRelationMap
[] =
179 {SwFPos::REL_BASE
, SwFPos::REL_BASE
, LB::RelBase
, text::RelOrientation::FRAME
},
180 {SwFPos::REL_CHAR
, SwFPos::REL_CHAR
, LB::RelChar
, text::RelOrientation::FRAME
},
181 {SwFPos::REL_ROW
, SwFPos::REL_ROW
, LB::RelRow
, text::RelOrientation::FRAME
}
185 constexpr auto HORI_PAGE_REL
= LB::RelPageFrame
| LB::RelPagePrintArea
| LB::RelPageLeft
|
188 FrameMap
const aHPageMap
[] =
190 {SwFPos::LEFT
, SwFPos::MIR_LEFT
, text::HoriOrientation::LEFT
, HORI_PAGE_REL
},
191 {SwFPos::RIGHT
, SwFPos::MIR_RIGHT
, text::HoriOrientation::RIGHT
, HORI_PAGE_REL
},
192 {SwFPos::CENTER_HORI
, SwFPos::CENTER_HORI
, text::HoriOrientation::CENTER
, HORI_PAGE_REL
},
193 {SwFPos::FROMLEFT
, SwFPos::MIR_FROMLEFT
, text::HoriOrientation::NONE
, HORI_PAGE_REL
}
196 FrameMap
const aHPageHtmlMap
[] =
198 {SwFPos::FROMLEFT
, SwFPos::MIR_FROMLEFT
, text::HoriOrientation::NONE
, LB::RelPageFrame
}
201 #define VERT_PAGE_REL (LB::RelPageFrame|LB::RelPagePrintArea)
203 FrameMap
const aVPageMap
[] =
205 {SwFPos::TOP
, SwFPos::TOP
, text::VertOrientation::TOP
, VERT_PAGE_REL
},
206 {SwFPos::BOTTOM
, SwFPos::BOTTOM
, text::VertOrientation::BOTTOM
, VERT_PAGE_REL
},
207 {SwFPos::CENTER_VERT
, SwFPos::CENTER_VERT
, text::VertOrientation::CENTER
, VERT_PAGE_REL
},
208 {SwFPos::FROMTOP
, SwFPos::FROMTOP
, text::VertOrientation::NONE
, VERT_PAGE_REL
}
211 FrameMap
const aVPageHtmlMap
[] =
213 {SwFPos::FROMTOP
, SwFPos::FROMTOP
, text::VertOrientation::NONE
, LB::RelPageFrame
}
217 constexpr auto HORI_FRAME_REL
= LB::FlyRelPageFrame
| LB::FlyRelPagePrintArea
|
218 LB::FlyRelPageLeft
| LB::FlyRelPageRight
;
220 FrameMap
const aHFrameMap
[] =
222 {SwFPos::LEFT
, SwFPos::MIR_LEFT
, text::HoriOrientation::LEFT
, HORI_FRAME_REL
},
223 {SwFPos::RIGHT
, SwFPos::MIR_RIGHT
, text::HoriOrientation::RIGHT
, HORI_FRAME_REL
},
224 {SwFPos::CENTER_HORI
, SwFPos::CENTER_HORI
, text::HoriOrientation::CENTER
, HORI_FRAME_REL
},
225 {SwFPos::FROMLEFT
, SwFPos::MIR_FROMLEFT
, text::HoriOrientation::NONE
, HORI_FRAME_REL
}
228 FrameMap
const aHFlyHtmlMap
[] =
230 {SwFPos::LEFT
, SwFPos::MIR_LEFT
, text::HoriOrientation::LEFT
, LB::FlyRelPageFrame
},
231 {SwFPos::FROMLEFT
, SwFPos::MIR_FROMLEFT
, text::HoriOrientation::NONE
, LB::FlyRelPageFrame
}
234 // own vertical alignment map for objects anchored to frame
235 #define VERT_FRAME_REL (LB::FlyVertFrame|LB::FlyVertPrintArea)
237 FrameMap
const aVFrameMap
[] =
239 {SwFPos::TOP
, SwFPos::TOP
, text::VertOrientation::TOP
, VERT_FRAME_REL
},
240 {SwFPos::BOTTOM
, SwFPos::BOTTOM
, text::VertOrientation::BOTTOM
, VERT_FRAME_REL
},
241 {SwFPos::CENTER_VERT
, SwFPos::CENTER_VERT
, text::VertOrientation::CENTER
, VERT_FRAME_REL
},
242 {SwFPos::FROMTOP
, SwFPos::FROMTOP
, text::VertOrientation::NONE
, VERT_FRAME_REL
}
245 FrameMap
const aVFlyHtmlMap
[] =
247 {SwFPos::TOP
, SwFPos::TOP
, text::VertOrientation::TOP
, LB::FlyVertFrame
},
248 {SwFPos::FROMTOP
, SwFPos::FROMTOP
, text::VertOrientation::NONE
, LB::FlyVertFrame
}
251 // paragraph anchored
252 constexpr auto HORI_PARA_REL
= LB::Frame
| LB::PrintArea
| LB::RelPageLeft
| LB::RelPageRight
|
253 LB::RelPageFrame
| LB::RelPagePrintArea
| LB::RelFrameLeft
|
256 FrameMap
const aHParaMap
[] =
258 {SwFPos::LEFT
, SwFPos::MIR_LEFT
, text::HoriOrientation::LEFT
, HORI_PARA_REL
},
259 {SwFPos::RIGHT
, SwFPos::MIR_RIGHT
, text::HoriOrientation::RIGHT
, HORI_PARA_REL
},
260 {SwFPos::CENTER_HORI
, SwFPos::CENTER_HORI
, text::HoriOrientation::CENTER
, HORI_PARA_REL
},
261 {SwFPos::FROMLEFT
, SwFPos::MIR_FROMLEFT
, text::HoriOrientation::NONE
, HORI_PARA_REL
}
264 #define HTML_HORI_PARA_REL (LB::Frame|LB::PrintArea)
266 FrameMap
const aHParaHtmlMap
[] =
268 {SwFPos::LEFT
, SwFPos::LEFT
, text::HoriOrientation::LEFT
, HTML_HORI_PARA_REL
},
269 {SwFPos::RIGHT
, SwFPos::RIGHT
, text::HoriOrientation::RIGHT
, HTML_HORI_PARA_REL
}
272 FrameMap
const aHParaHtmlAbsMap
[] =
274 {SwFPos::LEFT
, SwFPos::MIR_LEFT
, text::HoriOrientation::LEFT
, HTML_HORI_PARA_REL
},
275 {SwFPos::RIGHT
, SwFPos::MIR_RIGHT
, text::HoriOrientation::RIGHT
, HTML_HORI_PARA_REL
}
278 // allow vertical alignment at page areas
279 constexpr auto VERT_PARA_REL
= LB::VertFrame
| LB::VertPrintArea
|
280 LB::RelPageFrame
| LB::RelPagePrintArea
;
282 FrameMap
const aVParaMap
[] =
284 {SwFPos::TOP
, SwFPos::TOP
, text::VertOrientation::TOP
, VERT_PARA_REL
},
285 {SwFPos::BOTTOM
, SwFPos::BOTTOM
, text::VertOrientation::BOTTOM
, VERT_PARA_REL
},
286 {SwFPos::CENTER_VERT
, SwFPos::CENTER_VERT
, text::VertOrientation::CENTER
, VERT_PARA_REL
},
287 {SwFPos::FROMTOP
, SwFPos::FROMTOP
, text::VertOrientation::NONE
, VERT_PARA_REL
}
290 FrameMap
const aVParaHtmlMap
[] =
292 {SwFPos::TOP
, SwFPos::TOP
, text::VertOrientation::TOP
, LB::VertPrintArea
}
295 // anchored relative to the character
296 constexpr auto HORI_CHAR_REL
= LB::Frame
|LB::PrintArea
| LB::RelPageLeft
| LB::RelPageRight
|
297 LB::RelPageFrame
| LB::RelPagePrintArea
| LB::RelFrameLeft
|
298 LB::RelFrameRight
| LB::RelChar
;
300 FrameMap
const aHCharMap
[] =
302 {SwFPos::LEFT
, SwFPos::MIR_LEFT
, text::HoriOrientation::LEFT
, HORI_CHAR_REL
},
303 {SwFPos::RIGHT
, SwFPos::MIR_RIGHT
, text::HoriOrientation::RIGHT
, HORI_CHAR_REL
},
304 {SwFPos::CENTER_HORI
, SwFPos::CENTER_HORI
, text::HoriOrientation::CENTER
, HORI_CHAR_REL
},
305 {SwFPos::FROMLEFT
, SwFPos::MIR_FROMLEFT
, text::HoriOrientation::NONE
, HORI_CHAR_REL
}
308 #define HTML_HORI_CHAR_REL (LB::Frame|LB::PrintArea|LB::RelChar)
310 FrameMap
const aHCharHtmlMap
[] =
312 {SwFPos::LEFT
, SwFPos::LEFT
, text::HoriOrientation::LEFT
, HTML_HORI_CHAR_REL
},
313 {SwFPos::RIGHT
, SwFPos::RIGHT
, text::HoriOrientation::RIGHT
, HTML_HORI_CHAR_REL
}
316 FrameMap
const aHCharHtmlAbsMap
[] =
318 {SwFPos::LEFT
, SwFPos::MIR_LEFT
, text::HoriOrientation::LEFT
, LB::PrintArea
|LB::RelChar
},
319 {SwFPos::RIGHT
, SwFPos::MIR_RIGHT
, text::HoriOrientation::RIGHT
, LB::PrintArea
},
320 {SwFPos::FROMLEFT
, SwFPos::MIR_FROMLEFT
, text::HoriOrientation::NONE
, LB::RelPageFrame
}
323 // allow vertical alignment at page areas
324 constexpr auto VERT_CHAR_REL
= LB::VertFrame
| LB::VertPrintArea
|
325 LB::RelPageFrame
| LB::RelPagePrintArea
;
327 FrameMap
const aVCharMap
[] =
329 // introduce mappings for new vertical alignment at top of line <LB::VertLine>
330 // and correct mapping for vertical alignment at character for position <FROM_BOTTOM>
331 // Note: Because of these adjustments the map becomes ambiguous in its values
332 // <eStrId>/<eMirrorStrId> and <nAlign>. These ambiguities are considered
333 // in the methods <SwFramePage::FillRelLB(..)>, <SwFramePage::GetAlignment(..)>
334 // and <SwFramePage::FillPosLB(..)>
335 {SwFPos::TOP
, SwFPos::TOP
, text::VertOrientation::TOP
, VERT_CHAR_REL
|LB::RelChar
},
336 {SwFPos::BOTTOM
, SwFPos::BOTTOM
, text::VertOrientation::BOTTOM
, VERT_CHAR_REL
|LB::RelChar
},
337 {SwFPos::BELOW
, SwFPos::BELOW
, text::VertOrientation::CHAR_BOTTOM
, LB::RelChar
},
338 {SwFPos::CENTER_VERT
, SwFPos::CENTER_VERT
, text::VertOrientation::CENTER
, VERT_CHAR_REL
|LB::RelChar
},
339 {SwFPos::FROMTOP
, SwFPos::FROMTOP
, text::VertOrientation::NONE
, VERT_CHAR_REL
},
340 {SwFPos::FROMBOTTOM
, SwFPos::FROMBOTTOM
, text::VertOrientation::NONE
, LB::RelChar
|LB::VertLine
},
341 {SwFPos::TOP
, SwFPos::TOP
, text::VertOrientation::LINE_TOP
, LB::VertLine
},
342 {SwFPos::BOTTOM
, SwFPos::BOTTOM
, text::VertOrientation::LINE_BOTTOM
, LB::VertLine
},
343 {SwFPos::CENTER_VERT
, SwFPos::CENTER_VERT
, text::VertOrientation::LINE_CENTER
, LB::VertLine
}
346 FrameMap
const aVCharHtmlMap
[] =
348 {SwFPos::BELOW
, SwFPos::BELOW
, text::VertOrientation::CHAR_BOTTOM
, LB::RelChar
}
351 FrameMap
const aVCharHtmlAbsMap
[] =
353 {SwFPos::TOP
, SwFPos::TOP
, text::VertOrientation::TOP
, LB::RelChar
},
354 {SwFPos::BELOW
, SwFPos::BELOW
, text::VertOrientation::CHAR_BOTTOM
, LB::RelChar
}
357 // anchored as character
358 FrameMap
const aVAsCharMap
[] =
360 {SwFPos::TOP
, SwFPos::TOP
, text::VertOrientation::TOP
, LB::RelBase
},
361 {SwFPos::BOTTOM
, SwFPos::BOTTOM
, text::VertOrientation::BOTTOM
, LB::RelBase
},
362 {SwFPos::CENTER_VERT
, SwFPos::CENTER_VERT
, text::VertOrientation::CENTER
, LB::RelBase
},
364 {SwFPos::TOP
, SwFPos::TOP
, text::VertOrientation::CHAR_TOP
, LB::RelChar
},
365 {SwFPos::BOTTOM
, SwFPos::BOTTOM
, text::VertOrientation::CHAR_BOTTOM
, LB::RelChar
},
366 {SwFPos::CENTER_VERT
, SwFPos::CENTER_VERT
, text::VertOrientation::CHAR_CENTER
, LB::RelChar
},
368 {SwFPos::TOP
, SwFPos::TOP
, text::VertOrientation::LINE_TOP
, LB::RelRow
},
369 {SwFPos::BOTTOM
, SwFPos::BOTTOM
, text::VertOrientation::LINE_BOTTOM
, LB::RelRow
},
370 {SwFPos::CENTER_VERT
, SwFPos::CENTER_VERT
, text::VertOrientation::LINE_CENTER
, LB::RelRow
},
372 {SwFPos::FROMBOTTOM
, SwFPos::FROMBOTTOM
, text::VertOrientation::NONE
, LB::RelBase
}
375 FrameMap
const aVAsCharHtmlMap
[] =
377 {SwFPos::TOP
, SwFPos::TOP
, text::VertOrientation::TOP
, LB::RelBase
},
378 {SwFPos::CENTER_VERT
, SwFPos::CENTER_VERT
, text::VertOrientation::CENTER
, LB::RelBase
},
380 {SwFPos::TOP
, SwFPos::TOP
, text::VertOrientation::CHAR_TOP
, LB::RelChar
},
382 {SwFPos::TOP
, SwFPos::TOP
, text::VertOrientation::LINE_TOP
, LB::RelRow
},
383 {SwFPos::BOTTOM
, SwFPos::BOTTOM
, text::VertOrientation::LINE_BOTTOM
, LB::RelRow
},
384 {SwFPos::CENTER_VERT
, SwFPos::CENTER_VERT
, text::VertOrientation::LINE_CENTER
, LB::RelRow
}
387 const sal_uInt16
SwFramePage::aPageRg
[] = {
388 RES_FRM_SIZE
, RES_FRM_SIZE
,
389 RES_VERT_ORIENT
, RES_ANCHOR
,
391 RES_FOLLOW_TEXT_FLOW
, RES_FOLLOW_TEXT_FLOW
,
394 const sal_uInt16
SwFrameAddPage::aAddPgRg
[] = {
395 RES_PROTECT
, RES_PROTECT
,
396 RES_PRINT
, RES_PRINT
,
397 FN_SET_FRM_NAME
, FN_SET_FRM_NAME
,
398 FN_SET_FRM_ALT_NAME
, FN_SET_FRM_ALT_NAME
,
399 FN_UNO_DESCRIPTION
, FN_UNO_DESCRIPTION
,
403 static size_t lcl_GetFrameMapCount( const FrameMap
* pMap
)
407 if( pMap
== aVParaHtmlMap
)
408 return SAL_N_ELEMENTS(aVParaHtmlMap
);
409 if( pMap
== aVAsCharHtmlMap
)
410 return SAL_N_ELEMENTS(aVAsCharHtmlMap
);
411 if( pMap
== aHParaHtmlMap
)
412 return SAL_N_ELEMENTS(aHParaHtmlMap
);
413 if( pMap
== aHParaHtmlAbsMap
)
414 return SAL_N_ELEMENTS(aHParaHtmlAbsMap
);
415 if ( pMap
== aVPageMap
)
416 return SAL_N_ELEMENTS(aVPageMap
);
417 if ( pMap
== aVPageHtmlMap
)
418 return SAL_N_ELEMENTS(aVPageHtmlMap
);
419 if ( pMap
== aVAsCharMap
)
420 return SAL_N_ELEMENTS(aVAsCharMap
);
421 if ( pMap
== aVParaMap
)
422 return SAL_N_ELEMENTS(aVParaMap
);
423 if ( pMap
== aHParaMap
)
424 return SAL_N_ELEMENTS(aHParaMap
);
425 if ( pMap
== aHFrameMap
)
426 return SAL_N_ELEMENTS(aHFrameMap
);
427 if ( pMap
== aVFrameMap
)
428 return SAL_N_ELEMENTS(aVFrameMap
);
429 if ( pMap
== aHCharMap
)
430 return SAL_N_ELEMENTS(aHCharMap
);
431 if ( pMap
== aHCharHtmlMap
)
432 return SAL_N_ELEMENTS(aHCharHtmlMap
);
433 if ( pMap
== aHCharHtmlAbsMap
)
434 return SAL_N_ELEMENTS(aHCharHtmlAbsMap
);
435 if ( pMap
== aVCharMap
)
436 return SAL_N_ELEMENTS(aVCharMap
);
437 if ( pMap
== aVCharHtmlMap
)
438 return SAL_N_ELEMENTS(aVCharHtmlMap
);
439 if ( pMap
== aVCharHtmlAbsMap
)
440 return SAL_N_ELEMENTS(aVCharHtmlAbsMap
);
441 if ( pMap
== aHPageHtmlMap
)
442 return SAL_N_ELEMENTS(aHPageHtmlMap
);
443 if ( pMap
== aHFlyHtmlMap
)
444 return SAL_N_ELEMENTS(aHFlyHtmlMap
);
445 if ( pMap
== aVFlyHtmlMap
)
446 return SAL_N_ELEMENTS(aVFlyHtmlMap
);
447 return SAL_N_ELEMENTS(aHPageMap
);
452 static void lcl_InsertVectors(weld::ComboBox
& rBox
,
453 const std::vector
< OUString
>& rPrev
, const std::vector
< OUString
>& rThis
,
454 const std::vector
< OUString
>& rNext
, const std::vector
< OUString
>& rRemain
)
456 for(const auto& rItem
: rPrev
)
457 rBox
.append_text(rItem
);
458 for(const auto& rItem
: rThis
)
459 rBox
.append_text(rItem
);
460 for(const auto& rItem
: rNext
)
461 rBox
.append_text(rItem
);
462 rBox
.append_separator("");
463 //now insert all strings sorted
464 const auto nStartPos
= rBox
.get_count();
466 for(const auto& rItem
: rPrev
)
467 ::InsertStringSorted("", rItem
, rBox
, nStartPos
);
468 for(const auto& rItem
: rThis
)
469 ::InsertStringSorted("", rItem
, rBox
, nStartPos
);
470 for(const auto& rItem
: rNext
)
471 ::InsertStringSorted("", rItem
, rBox
, nStartPos
);
472 for(const auto& rItem
: rRemain
)
473 ::InsertStringSorted("", rItem
, rBox
, nStartPos
);
476 // --> OD 2009-08-31 #mongolianlayout#
477 // add input parameter
478 static SvxSwFramePosString::StringId
lcl_ChangeResIdToVerticalOrRTL(SvxSwFramePosString::StringId eStringId
, bool bVertical
, bool bVerticalL2R
, bool bRTL
)
480 //special handling of STR_FROMLEFT
481 if ( SwFPos::FROMLEFT
== eStringId
)
483 eStringId
= bVertical
489 : SwFPos::FROMLEFT
);
492 // --> OD 2009-08-31 #mongolianlayout#
493 // special handling of STR_FROMTOP in case of mongolianlayout (vertical left-to-right)
494 if ( SwFPos::FROMTOP
== eStringId
&&
495 bVertical
&& bVerticalL2R
)
497 eStringId
= SwFPos::FROMLEFT
;
502 //exchange horizontal strings with vertical strings and vice versa
503 static const StringIdPair_Impl aHoriIds
[] =
505 {SwFPos::LEFT
, SwFPos::TOP
},
506 {SwFPos::RIGHT
, SwFPos::BOTTOM
},
507 {SwFPos::CENTER_HORI
, SwFPos::CENTER_VERT
},
508 {SwFPos::FROMTOP
, SwFPos::FROMRIGHT
},
509 {SwFPos::REL_PG_LEFT
, SwFPos::REL_PG_TOP
},
510 {SwFPos::REL_PG_RIGHT
, SwFPos::REL_PG_BOTTOM
} ,
511 {SwFPos::REL_FRM_LEFT
, SwFPos::REL_FRM_TOP
},
512 {SwFPos::REL_FRM_RIGHT
, SwFPos::REL_FRM_BOTTOM
}
514 static const StringIdPair_Impl aVertIds
[] =
516 {SwFPos::TOP
, SwFPos::RIGHT
},
517 {SwFPos::BOTTOM
, SwFPos::LEFT
},
518 {SwFPos::CENTER_VERT
, SwFPos::CENTER_HORI
},
519 {SwFPos::FROMTOP
, SwFPos::FROMRIGHT
},
520 {SwFPos::REL_PG_TOP
, SwFPos::REL_PG_LEFT
},
521 {SwFPos::REL_PG_BOTTOM
, SwFPos::REL_PG_RIGHT
} ,
522 {SwFPos::REL_FRM_TOP
, SwFPos::REL_FRM_LEFT
},
523 {SwFPos::REL_FRM_BOTTOM
, SwFPos::REL_FRM_RIGHT
}
525 // --> OD 2009-08-31 #monglianlayout#
526 static const StringIdPair_Impl aVertL2RIds
[] =
528 {SwFPos::TOP
, SwFPos::LEFT
},
529 {SwFPos::BOTTOM
, SwFPos::RIGHT
},
530 {SwFPos::CENTER_VERT
, SwFPos::CENTER_HORI
},
531 {SwFPos::FROMTOP
, SwFPos::FROMLEFT
},
532 {SwFPos::REL_PG_TOP
, SwFPos::REL_PG_LEFT
},
533 {SwFPos::REL_PG_BOTTOM
, SwFPos::REL_PG_RIGHT
} ,
534 {SwFPos::REL_FRM_TOP
, SwFPos::REL_FRM_LEFT
},
535 {SwFPos::REL_FRM_BOTTOM
, SwFPos::REL_FRM_RIGHT
}
537 for(const StringIdPair_Impl
& rHoriId
: aHoriIds
)
539 if(rHoriId
.eHori
== eStringId
)
541 eStringId
= rHoriId
.eVert
;
545 for(size_t nIndex
= 0; nIndex
< SAL_N_ELEMENTS(aVertIds
); ++nIndex
)
547 // --> OD 2009-08-31 #mongolianlayout#
550 if(aVertIds
[nIndex
].eHori
== eStringId
)
552 eStringId
= aVertIds
[nIndex
].eVert
;
558 if(aVertL2RIds
[nIndex
].eHori
== eStringId
)
560 eStringId
= aVertL2RIds
[nIndex
].eVert
;
569 // helper method in order to determine all possible
570 // listbox relations in a relation map for a given relation
571 static LB
lcl_GetLBRelationsForRelations( const sal_Int16 _nRel
)
573 LB nLBRelations
= LB::NONE
;
575 for (RelationMap
const & i
: aRelationMap
)
577 if ( i
.nRelation
== _nRel
)
579 nLBRelations
|= i
.nLBRelation
;
586 // helper method on order to determine all possible
587 // listbox relations in a relation map for a given string ID
588 static LB
lcl_GetLBRelationsForStrID( const FrameMap
* _pMap
,
589 const SvxSwFramePosString::StringId _eStrId
,
590 const bool _bUseMirrorStr
)
592 LB nLBRelations
= LB::NONE
;
594 size_t nRelMapSize
= lcl_GetFrameMapCount( _pMap
);
595 for ( size_t nRelMapPos
= 0; nRelMapPos
< nRelMapSize
; ++nRelMapPos
)
597 if ( ( !_bUseMirrorStr
&& _pMap
[nRelMapPos
].eStrId
== _eStrId
) ||
598 ( _bUseMirrorStr
&& _pMap
[nRelMapPos
].eMirrorStrId
== _eStrId
) )
600 nLBRelations
|= _pMap
[nRelMapPos
].nLBRelations
;
607 // standard frame TabPage
610 void HandleAutoCB(bool _bChecked
, weld::Label
& _rFT_man
, weld::Label
& _rFT_auto
, weld::MetricSpinButton
& _rPF_Edit
)
612 _rFT_man
.set_visible( !_bChecked
);
613 _rFT_auto
.set_visible( _bChecked
);
614 OUString accName
= _bChecked
? _rFT_auto
.get_label() : _rFT_man
.get_label();
615 _rPF_Edit
.set_accessible_name(accName
);
619 SwFramePage::SwFramePage(weld::Container
* pPage
, weld::DialogController
* pController
, const SfxItemSet
&rSet
)
620 : SfxTabPage(pPage
, pController
, "modules/swriter/ui/frmtypepage.ui", "FrameTypePage", &rSet
)
621 , m_bAtHorzPosModified(false)
622 , m_bAtVertPosModified(false)
625 , m_bNoModifyHdl(true)
626 , m_bIsVerticalFrame(false)
627 , m_bIsVerticalL2R(false)
628 , m_bIsInRightToLeft(false)
633 , m_fWidthHeightRatio(1.0)
634 , mpToCharContentPos(nullptr)
635 , m_nOldH(text::HoriOrientation::CENTER
)
636 , m_nOldHRel(text::RelOrientation::FRAME
)
637 , m_nOldV(text::VertOrientation::TOP
)
638 , m_nOldVRel(text::RelOrientation::PRINT_AREA
)
641 , m_bAllowVertPositioning( true )
642 , m_bIsMathOLE(false)
643 , m_bIsMathBaselineAlignment(true)
644 , m_xWidthFT(m_xBuilder
->weld_label("widthft"))
645 , m_xWidthAutoFT(m_xBuilder
->weld_label("autowidthft"))
646 , m_xRelWidthCB(m_xBuilder
->weld_check_button("relwidth"))
647 , m_xRelWidthRelationLB(m_xBuilder
->weld_combo_box("relwidthrelation"))
648 , m_xAutoWidthCB(m_xBuilder
->weld_check_button("autowidth"))
649 , m_xHeightFT(m_xBuilder
->weld_label("heightft"))
650 , m_xHeightAutoFT(m_xBuilder
->weld_label("autoheightft"))
651 , m_xRelHeightCB(m_xBuilder
->weld_check_button("relheight"))
652 , m_xRelHeightRelationLB(m_xBuilder
->weld_combo_box("relheightrelation"))
653 , m_xAutoHeightCB(m_xBuilder
->weld_check_button("autoheight"))
654 , m_xFixedRatioCB(m_xBuilder
->weld_check_button("ratio"))
655 , m_xRealSizeBT(m_xBuilder
->weld_button("origsize"))
656 , m_xAnchorFrame(m_xBuilder
->weld_widget("anchorframe"))
657 , m_xAnchorAtPageRB(m_xBuilder
->weld_radio_button("topage"))
658 , m_xAnchorAtParaRB(m_xBuilder
->weld_radio_button("topara"))
659 , m_xAnchorAtCharRB(m_xBuilder
->weld_radio_button("tochar"))
660 , m_xAnchorAsCharRB(m_xBuilder
->weld_radio_button("aschar"))
661 , m_xAnchorAtFrameRB(m_xBuilder
->weld_radio_button("toframe"))
662 , m_xHorizontalFT(m_xBuilder
->weld_label("horiposft"))
663 , m_xHorizontalDLB(m_xBuilder
->weld_combo_box("horipos"))
664 , m_xAtHorzPosFT(m_xBuilder
->weld_label("horibyft"))
665 , m_xAtHorzPosED(m_xBuilder
->weld_metric_spin_button("byhori", FieldUnit::CM
))
666 , m_xHoriRelationFT(m_xBuilder
->weld_label("horitoft"))
667 , m_xHoriRelationLB(m_xBuilder
->weld_combo_box("horianchor"))
668 , m_xMirrorPagesCB(m_xBuilder
->weld_check_button("mirror"))
669 , m_xVerticalFT(m_xBuilder
->weld_label("vertposft"))
670 , m_xVerticalDLB(m_xBuilder
->weld_combo_box("vertpos"))
671 , m_xAtVertPosFT(m_xBuilder
->weld_label("vertbyft"))
672 , m_xAtVertPosED(m_xBuilder
->weld_metric_spin_button("byvert", FieldUnit::CM
))
673 , m_xVertRelationFT(m_xBuilder
->weld_label("verttoft"))
674 , m_xVertRelationLB(m_xBuilder
->weld_combo_box("vertanchor"))
675 , m_xFollowTextFlowCB(m_xBuilder
->weld_check_button("followtextflow"))
676 , m_xExampleWN(new weld::CustomWeld(*m_xBuilder
, "preview", m_aExampleWN
))
677 , m_xWidthED(new SwPercentField(m_xBuilder
->weld_metric_spin_button("width", FieldUnit::CM
)))
678 , m_xHeightED(new SwPercentField(m_xBuilder
->weld_metric_spin_button("height", FieldUnit::CM
)))
680 const auto nWidthRequest
= m_xAtHorzPosED
->get_preferred_size().Width();
681 m_xAtHorzPosED
->set_size_request(nWidthRequest
, -1);
682 m_xAtVertPosED
->set_size_request(nWidthRequest
, -1);
684 setOptimalFrameWidth();
685 setOptimalRelWidth();
687 SetExchangeSupport();
689 Link
<weld::MetricSpinButton
&,void> aLk3
= LINK(this, SwFramePage
, ModifyHdl
);
690 m_xWidthED
->connect_value_changed( aLk3
);
691 m_xHeightED
->connect_value_changed( aLk3
);
692 m_xAtHorzPosED
->connect_value_changed( aLk3
);
693 m_xAtVertPosED
->connect_value_changed( aLk3
);
694 m_xFollowTextFlowCB
->connect_toggled(LINK(this, SwFramePage
, RangeModifyClickHdl
));
696 Link
<weld::ToggleButton
&,void> aLk2
= LINK(this, SwFramePage
, AnchorTypeHdl
);
697 m_xAnchorAtPageRB
->connect_toggled( aLk2
);
698 m_xAnchorAtParaRB
->connect_toggled( aLk2
);
699 m_xAnchorAtCharRB
->connect_toggled( aLk2
);
700 m_xAnchorAsCharRB
->connect_toggled( aLk2
);
701 m_xAnchorAtFrameRB
->connect_toggled( aLk2
);
703 m_xHorizontalDLB
->connect_changed(LINK(this, SwFramePage
, PosHdl
));
704 m_xVerticalDLB
->connect_changed(LINK(this, SwFramePage
, PosHdl
));
706 m_xHoriRelationLB
->connect_changed(LINK(this, SwFramePage
, RelHdl
));
707 m_xVertRelationLB
->connect_changed(LINK(this, SwFramePage
, RelHdl
));
709 m_xMirrorPagesCB
->connect_toggled(LINK(this, SwFramePage
, MirrorHdl
));
711 aLk2
= LINK(this, SwFramePage
, RelSizeClickHdl
);
712 m_xRelWidthCB
->connect_toggled(aLk2
);
713 m_xRelHeightCB
->connect_toggled(aLk2
);
715 m_xAutoWidthCB
->connect_toggled(LINK(this, SwFramePage
, AutoWidthClickHdl
));
716 m_xAutoHeightCB
->connect_toggled(LINK(this, SwFramePage
, AutoHeightClickHdl
));
718 if (comphelper::LibreOfficeKit::isActive())
720 m_xAnchorAtPageRB
->hide();
721 m_xAnchorAtParaRB
->hide();
722 m_xAnchorAtFrameRB
->hide();
726 SwFramePage::~SwFramePage()
734 FrameMap
const * pMap
;
739 void SwFramePage::setOptimalFrameWidth()
741 static FrameMaps
const aMaps
[] = {
742 { aHPageMap
, SAL_N_ELEMENTS(aHPageMap
) },
743 { aHPageHtmlMap
, SAL_N_ELEMENTS(aHPageHtmlMap
) },
744 { aVPageMap
, SAL_N_ELEMENTS(aVPageMap
) },
745 { aVPageHtmlMap
, SAL_N_ELEMENTS(aVPageHtmlMap
) },
746 { aHFrameMap
, SAL_N_ELEMENTS(aHFrameMap
) },
747 { aHFlyHtmlMap
, SAL_N_ELEMENTS(aHFlyHtmlMap
) },
748 { aVFrameMap
, SAL_N_ELEMENTS(aVFrameMap
) },
749 { aVFlyHtmlMap
, SAL_N_ELEMENTS(aVFlyHtmlMap
) },
750 { aHParaMap
, SAL_N_ELEMENTS(aHParaMap
) },
751 { aHParaHtmlMap
, SAL_N_ELEMENTS(aHParaHtmlMap
) },
752 { aHParaHtmlAbsMap
, SAL_N_ELEMENTS(aHParaHtmlAbsMap
) },
753 { aVParaMap
, SAL_N_ELEMENTS(aVParaMap
) },
754 { aVParaHtmlMap
, SAL_N_ELEMENTS(aVParaHtmlMap
) },
755 { aHCharMap
, SAL_N_ELEMENTS(aHCharMap
) },
756 { aHCharHtmlMap
, SAL_N_ELEMENTS(aHCharHtmlMap
) },
757 { aHCharHtmlAbsMap
, SAL_N_ELEMENTS(aHCharHtmlAbsMap
) },
758 { aVCharMap
, SAL_N_ELEMENTS(aVCharMap
) },
759 { aVCharHtmlMap
, SAL_N_ELEMENTS(aVCharHtmlMap
) },
760 { aVCharHtmlAbsMap
, SAL_N_ELEMENTS(aVCharHtmlAbsMap
) },
761 { aVAsCharMap
, SAL_N_ELEMENTS(aVAsCharMap
) },
762 { aVAsCharHtmlMap
, SAL_N_ELEMENTS(aVAsCharHtmlMap
) }
765 std::vector
<SvxSwFramePosString::StringId
> aFrames
;
766 for (const FrameMaps
& rMap
: aMaps
)
768 for (size_t j
= 0; j
< rMap
.nCount
; ++j
)
770 aFrames
.push_back(rMap
.pMap
[j
].eStrId
);
771 aFrames
.push_back(rMap
.pMap
[j
].eMirrorStrId
);
775 std::sort(aFrames
.begin(), aFrames
.end());
776 aFrames
.erase(std::unique(aFrames
.begin(), aFrames
.end()), aFrames
.end());
778 for (const auto& rFrame
: aFrames
)
780 m_xHorizontalDLB
->append_text(SvxSwFramePosString::GetString(rFrame
));
783 Size
aBiggest(m_xHorizontalDLB
->get_preferred_size());
784 m_xHorizontalDLB
->set_size_request(aBiggest
.Width(), -1);
785 m_xVerticalDLB
->set_size_request(aBiggest
.Width(), -1);
786 m_xHorizontalDLB
->clear();
793 RelationMap
const * pMap
;
798 void SwFramePage::setOptimalRelWidth()
800 static const RelationMaps aMaps
[] = {
801 { aRelationMap
, SAL_N_ELEMENTS(aRelationMap
) },
802 { aAsCharRelationMap
, SAL_N_ELEMENTS(aAsCharRelationMap
) }
805 std::vector
<SvxSwFramePosString::StringId
> aRels
;
806 for (const RelationMaps
& rMap
: aMaps
)
808 for (size_t j
= 0; j
< rMap
.nCount
; ++j
)
810 aRels
.push_back(rMap
.pMap
[j
].eStrId
);
811 aRels
.push_back(rMap
.pMap
[j
].eMirrorStrId
);
815 std::sort(aRels
.begin(), aRels
.end());
816 aRels
.erase(std::unique(aRels
.begin(), aRels
.end()), aRels
.end());
818 for (const auto& rRel
: aRels
)
820 m_xHoriRelationLB
->append_text(SvxSwFramePosString::GetString(rRel
));
823 Size
aBiggest(m_xHoriRelationLB
->get_preferred_size());
824 m_xHoriRelationLB
->set_size_request(aBiggest
.Width(), -1);
825 m_xVertRelationLB
->set_size_request(aBiggest
.Width(), -1);
826 m_xRelWidthRelationLB
->set_size_request(aBiggest
.Width(), -1);
827 m_xRelHeightRelationLB
->set_size_request(aBiggest
.Width(), -1);
828 m_xHoriRelationLB
->clear();
831 std::unique_ptr
<SfxTabPage
> SwFramePage::Create(weld::Container
* pPage
, weld::DialogController
* pController
, const SfxItemSet
*rSet
)
833 return std::make_unique
<SwFramePage
>(pPage
, pController
, *rSet
);
836 void SwFramePage::EnableGraficMode()
838 // i#39692 - mustn't be called more than once
839 if (!m_xRealSizeBT
->get_visible())
842 m_xWidthAutoFT
->hide();
843 m_xAutoHeightCB
->hide();
846 m_xHeightAutoFT
->hide();
847 m_xAutoWidthCB
->hide();
849 m_xRealSizeBT
->show();
853 SwWrtShell
*SwFramePage::getFrameDlgParentShell()
855 return static_cast<SwFrameDlg
*>(GetDialogController())->GetWrtShell();
858 void SwFramePage::Reset( const SfxItemSet
*rSet
)
860 SwWrtShell
* pSh
= m_bFormat
? ::GetActiveWrtShell() :
861 getFrameDlgParentShell();
863 m_nHtmlMode
= ::GetHtmlMode(pSh
->GetView().GetDocShell());
864 m_bHtmlMode
= (m_nHtmlMode
& HTMLMODE_ON
) != 0;
866 FieldUnit aMetric
= ::GetDfltMetric(m_bHtmlMode
);
867 m_xWidthED
->SetMetric(aMetric
);
868 m_xHeightED
->SetMetric(aMetric
);
869 ::SetFieldUnit(*m_xAtHorzPosED
, aMetric
);
870 ::SetFieldUnit(*m_xAtVertPosED
, aMetric
);
872 const SfxPoolItem
* pItem
= nullptr;
873 const SwFormatAnchor
& rAnchor
= rSet
->Get(RES_ANCHOR
);
875 if (SfxItemState::SET
== rSet
->GetItemState(FN_OLE_IS_MATH
, false, &pItem
))
876 m_bIsMathOLE
= static_cast<const SfxBoolItem
*>(pItem
)->GetValue();
877 if (SfxItemState::SET
== rSet
->GetItemState(FN_MATH_BASELINE_ALIGNMENT
, false, &pItem
))
878 m_bIsMathBaselineAlignment
= static_cast<const SfxBoolItem
*>(pItem
)->GetValue();
879 EnableVerticalPositioning( !(m_bIsMathOLE
&& m_bIsMathBaselineAlignment
880 && RndStdIds::FLY_AS_CHAR
== rAnchor
.GetAnchorId()) );
884 // at formats no anchor editing
885 m_xAnchorFrame
->set_sensitive(false);
886 m_xFixedRatioCB
->set_sensitive(false);
890 if (rAnchor
.GetAnchorId() != RndStdIds::FLY_AT_FLY
&& !pSh
->IsFlyInFly())
891 m_xAnchorAtFrameRB
->hide();
892 if ( pSh
->IsFrameVertical( true, m_bIsInRightToLeft
, m_bIsVerticalL2R
) )
894 OUString sHLabel
= m_xHorizontalFT
->get_label();
895 m_xHorizontalFT
->set_label(m_xVerticalFT
->get_label());
896 m_xVerticalFT
->set_label(sHLabel
);
897 m_bIsVerticalFrame
= true;
901 if ( m_sDlgType
== "PictureDialog" || m_sDlgType
== "ObjectDialog" )
903 OSL_ENSURE(pSh
, "shell not found");
904 //OS: only for the variant Insert/Graphic/Properties
905 if(SfxItemState::SET
== rSet
->GetItemState(FN_PARAM_GRF_REALSIZE
, false, &pItem
))
906 m_aGrfSize
= static_cast<const SvxSizeItem
*>(pItem
)->GetSize();
908 pSh
->GetGrfSize( m_aGrfSize
);
912 m_xRealSizeBT
->connect_clicked(LINK(this, SwFramePage
, RealSizeHdl
));
916 if (m_sDlgType
== "PictureDialog")
917 m_xFixedRatioCB
->set_active(false);
921 SetPageTitle(SwResId(STR_FRMUI_OLE_INSERT
));
923 SetPageTitle(SwResId(STR_FRMUI_OLE_EDIT
));
928 m_aGrfSize
= rSet
->Get(RES_FRM_SIZE
).GetSize();
931 // entering percent value made possible
933 // the available space is not yet known so the RefValue has to be calculated from size and relative size values
934 // this is needed only if relative values are already set
935 const SwFormatFrameSize
& rFrameSize
= rSet
->Get(RES_FRM_SIZE
);
937 m_xRelWidthRelationLB
->append_text(SvxSwFramePosString::GetString(SwFPos::FRAME
));
938 m_xRelWidthRelationLB
->append_text(SvxSwFramePosString::GetString(SwFPos::REL_PG_FRAME
));
939 if (rFrameSize
.GetWidthPercent() != SwFormatFrameSize::SYNCED
&& rFrameSize
.GetWidthPercent() != 0)
941 //calculate the reference value from the width and relative width values
942 sal_Int32 nSpace
= rFrameSize
.GetWidth() * 100 / rFrameSize
.GetWidthPercent();
943 m_xWidthED
->SetRefValue( nSpace
);
945 m_xRelWidthRelationLB
->set_sensitive(true);
948 m_xRelWidthRelationLB
->set_sensitive(false);
950 m_xRelHeightRelationLB
->append_text(SvxSwFramePosString::GetString(SwFPos::FRAME
));
951 m_xRelHeightRelationLB
->append_text(SvxSwFramePosString::GetString(SwFPos::REL_PG_FRAME
));
952 if (rFrameSize
.GetHeightPercent() != SwFormatFrameSize::SYNCED
&& rFrameSize
.GetHeightPercent() != 0)
954 //calculate the reference value from the with and relative width values
955 sal_Int32 nSpace
= rFrameSize
.GetHeight() * 100 / rFrameSize
.GetHeightPercent();
956 m_xHeightED
->SetRefValue( nSpace
);
958 m_xRelHeightRelationLB
->set_sensitive(true);
961 m_xRelHeightRelationLB
->set_sensitive(false);
963 // general initialisation part
964 switch(rAnchor
.GetAnchorId())
966 case RndStdIds::FLY_AT_PAGE
: m_xAnchorAtPageRB
->set_active(true); break;
967 case RndStdIds::FLY_AT_PARA
: m_xAnchorAtParaRB
->set_active(true); break;
968 case RndStdIds::FLY_AT_CHAR
: m_xAnchorAtCharRB
->set_active(true); break;
969 case RndStdIds::FLY_AS_CHAR
: m_xAnchorAsCharRB
->set_active(true); break;
970 case RndStdIds::FLY_AT_FLY
: m_xAnchorAtFrameRB
->set_active(true);break;
971 default:; //prevent warning
974 // i#22341 - determine content position of character
975 // Note: content position can be NULL
976 mpToCharContentPos
= rAnchor
.GetContentAnchor();
978 // i#18732 - init checkbox value
980 const bool bFollowTextFlow
=
981 rSet
->Get(RES_FOLLOW_TEXT_FLOW
).GetValue();
982 m_xFollowTextFlowCB
->set_active(bFollowTextFlow
);
987 m_xAutoHeightCB
->set_sensitive(false);
988 m_xAutoWidthCB
->set_sensitive(false);
989 m_xMirrorPagesCB
->hide();
990 if (m_sDlgType
== "FrameDialog")
991 m_xFixedRatioCB
->set_sensitive(false);
992 // i#18732 hide checkbox in HTML mode
993 m_xFollowTextFlowCB
->hide();
997 // enable/disable of check box 'Mirror on..'
998 m_xMirrorPagesCB
->set_sensitive(!m_xAnchorAsCharRB
->get_active());
1000 // enable/disable check box 'Follow text flow'.
1001 // enable check box 'Follow text
1002 // flow' also for anchor type to-frame.
1003 m_xFollowTextFlowCB
->set_sensitive(m_xAnchorAtParaRB
->get_active() ||
1004 m_xAnchorAtCharRB
->get_active() ||
1005 m_xAnchorAtFrameRB
->get_active());
1009 m_xAtVertPosED
->save_value();
1010 m_xAtHorzPosED
->save_value();
1011 m_xFollowTextFlowCB
->save_state();
1013 m_xWidthED
->save_value();
1014 m_xHeightED
->save_value();
1016 m_bNoModifyHdl
= false;
1017 //lock PercentFields
1018 m_xWidthED
->LockAutoCalculation(true);
1019 m_xHeightED
->LockAutoCalculation(true);
1020 RangeModifyHdl(); // set all maximum values initially
1021 m_xHeightED
->LockAutoCalculation(false);
1022 m_xWidthED
->LockAutoCalculation(false);
1024 m_xAutoHeightCB
->save_state();
1025 m_xAutoWidthCB
->save_state();
1027 SwTwips nWidth
= static_cast< SwTwips
>(m_xWidthED
->DenormalizePercent(m_xWidthED
->get_value(FieldUnit::TWIP
)));
1028 SwTwips nHeight
= static_cast< SwTwips
>(m_xHeightED
->DenormalizePercent(m_xHeightED
->get_value(FieldUnit::TWIP
)));
1029 m_fWidthHeightRatio
= nHeight
? double(nWidth
) / double(nHeight
) : 1.0;
1032 // stuff attributes into the set when OK
1033 bool SwFramePage::FillItemSet(SfxItemSet
*rSet
)
1036 SwWrtShell
* pSh
= m_bFormat
? ::GetActiveWrtShell()
1037 : getFrameDlgParentShell();
1038 OSL_ENSURE( pSh
, "shell not found");
1039 const SfxItemSet
& rOldSet
= GetItemSet();
1040 const SfxPoolItem
* pOldItem
= nullptr;
1042 RndStdIds eAnchorId
= GetAnchor();
1046 pOldItem
= GetOldItem(*rSet
, RES_ANCHOR
);
1047 if (m_bNew
|| !pOldItem
|| eAnchorId
!= static_cast<const SwFormatAnchor
*>(pOldItem
)->GetAnchorId())
1049 SwFormatAnchor
aAnc( eAnchorId
, pSh
->GetPhyPageNum() );
1050 bRet
= nullptr != rSet
->Put( aAnc
);
1056 SwFormatHoriOrient
aHoriOrient( rOldSet
.Get(RES_HORI_ORIENT
) );
1058 const sal_Int32 nMapPos
= GetMapPos(m_pHMap
, *m_xHorizontalDLB
);
1059 const sal_Int16 eHOri
= GetAlignment(m_pHMap
, nMapPos
, *m_xHoriRelationLB
);
1060 const sal_Int16 eRel
= GetRelation(*m_xHoriRelationLB
);
1062 aHoriOrient
.SetHoriOrient( eHOri
);
1063 aHoriOrient
.SetRelationOrient( eRel
);
1064 aHoriOrient
.SetPosToggle(m_xMirrorPagesCB
->get_active());
1066 bool bMod
= m_xAtHorzPosED
->get_value_changed_from_saved();
1067 bMod
|= m_xMirrorPagesCB
->get_state_changed_from_saved();
1069 if ( eHOri
== text::HoriOrientation::NONE
&&
1070 (m_bNew
|| (m_bAtHorzPosModified
|| bMod
) || m_nOldH
!= eHOri
) )
1072 SwTwips nX
= static_cast< SwTwips
>(m_xAtHorzPosED
->denormalize(m_xAtHorzPosED
->get_value(FieldUnit::TWIP
)));
1073 aHoriOrient
.SetPos( nX
);
1076 pOldItem
= GetOldItem(*rSet
, FN_HORI_ORIENT
);
1078 if ((m_bNew
== m_bFormat
) && pOldItem
)
1080 bSame
= aHoriOrient
== static_cast<const SwFormatHoriOrient
&>(*pOldItem
);
1082 if ((m_bNew
&& !m_bFormat
) || ((m_bAtHorzPosModified
|| bMod
) && !bSame
))
1084 bRet
|= nullptr != rSet
->Put( aHoriOrient
);
1090 // alignment vertical
1091 SwFormatVertOrient
aVertOrient( rOldSet
.Get(RES_VERT_ORIENT
) );
1093 const sal_Int32 nMapPos
= GetMapPos(m_pVMap
, *m_xVerticalDLB
);
1094 const sal_Int16 eVOri
= GetAlignment(m_pVMap
, nMapPos
, *m_xVertRelationLB
);
1095 const sal_Int16 eRel
= GetRelation(*m_xVertRelationLB
);
1097 aVertOrient
.SetVertOrient ( eVOri
);
1098 aVertOrient
.SetRelationOrient( eRel
);
1100 bool bMod
= m_xAtVertPosED
->get_value_changed_from_saved();
1102 if ( eVOri
== text::VertOrientation::NONE
&&
1103 ( m_bNew
|| (m_bAtVertPosModified
|| bMod
) || m_nOldV
!= eVOri
) )
1105 // vertical position
1106 // recalculate offset for character bound frames
1107 SwTwips nY
= static_cast< SwTwips
>(m_xAtVertPosED
->denormalize(m_xAtVertPosED
->get_value(FieldUnit::TWIP
)));
1108 if (eAnchorId
== RndStdIds::FLY_AS_CHAR
)
1112 aVertOrient
.SetPos( nY
);
1114 pOldItem
= GetOldItem(*rSet
, FN_VERT_ORIENT
);
1116 if((m_bNew
== m_bFormat
) && pOldItem
)
1119 aVertOrient
.GetVertOrient() == static_cast<const SwFormatVertOrient
*>(pOldItem
)->GetVertOrient() &&
1120 aVertOrient
.GetRelationOrient() == static_cast<const SwFormatVertOrient
*>(pOldItem
)->GetRelationOrient() &&
1121 aVertOrient
.GetPos() == static_cast<const SwFormatVertOrient
*>(pOldItem
)->GetPos()
1122 : aVertOrient
== static_cast<const SwFormatVertOrient
&>(*pOldItem
);
1124 if( ( m_bNew
&& !m_bFormat
) || ((m_bAtVertPosModified
|| bMod
) && !bSame
))
1126 bRet
|= nullptr != rSet
->Put( aVertOrient
);
1131 // new exception: when the size of pMgr(, 0), then the properties
1132 // for a graphic that isn't even loaded, are set. Then no SetSize
1133 // is done here when the size settings were not changed by the
1135 const SwFormatFrameSize
& rOldSize
= rOldSet
.Get(RES_FRM_SIZE
);
1136 SwFormatFrameSize
aSz( rOldSize
);
1138 auto nRelWidthRelation
= m_xRelWidthRelationLB
->get_active();
1139 if (nRelWidthRelation
!= -1)
1141 if (nRelWidthRelation
== 0)
1142 aSz
.SetWidthPercentRelation(text::RelOrientation::FRAME
);
1143 else if (nRelWidthRelation
== 1)
1144 aSz
.SetWidthPercentRelation(text::RelOrientation::PAGE_FRAME
);
1146 auto nRelHeightRelation
= m_xRelHeightRelationLB
->get_active();
1147 if (nRelHeightRelation
!= -1)
1149 if (nRelHeightRelation
== 0)
1150 aSz
.SetHeightPercentRelation(text::RelOrientation::FRAME
);
1151 else if (nRelHeightRelation
== 1)
1152 aSz
.SetHeightPercentRelation(text::RelOrientation::PAGE_FRAME
);
1155 bool bValueModified
= m_xWidthED
->get_value_changed_from_saved() ||
1156 m_xHeightED
->get_value_changed_from_saved();
1157 bool bCheckChanged
= m_xRelWidthCB
->get_state_changed_from_saved() ||
1158 m_xRelHeightCB
->get_state_changed_from_saved();
1160 bool bLegalValue
= !(!rOldSize
.GetWidth () && !rOldSize
.GetHeight() &&
1161 m_xWidthED
->get_value() == m_xWidthED
->get_min() &&
1162 m_xHeightED
->get_value() == m_xHeightED
->get_min());
1164 if ((m_bNew
&& !m_bFormat
) || ((bValueModified
|| bCheckChanged
) && bLegalValue
))
1166 sal_Int64 nNewWidth
= m_xWidthED
->DenormalizePercent(m_xWidthED
->GetRealValue(FieldUnit::TWIP
));
1167 sal_Int64 nNewHeight
= m_xHeightED
->DenormalizePercent(m_xHeightED
->GetRealValue(FieldUnit::TWIP
));
1168 aSz
.SetWidth (static_cast< SwTwips
>(nNewWidth
));
1169 aSz
.SetHeight(static_cast< SwTwips
>(nNewHeight
));
1171 if (m_xRelWidthCB
->get_active())
1173 aSz
.SetWidthPercent(static_cast<sal_uInt8
>(std::min(MAX_PERCENT_WIDTH
, m_xWidthED
->Convert(m_xWidthED
->NormalizePercent(nNewWidth
), FieldUnit::TWIP
, FieldUnit::PERCENT
))));
1176 aSz
.SetWidthPercent(0);
1177 if (m_xRelHeightCB
->get_active())
1178 aSz
.SetHeightPercent(static_cast<sal_uInt8
>(std::min(MAX_PERCENT_HEIGHT
, m_xHeightED
->Convert(m_xHeightED
->NormalizePercent(nNewHeight
), FieldUnit::TWIP
, FieldUnit::PERCENT
))));
1180 aSz
.SetHeightPercent(0);
1182 if (m_xFixedRatioCB
->get_active() && (m_xRelWidthCB
->get_active() != m_xRelHeightCB
->get_active()))
1184 if (m_xRelWidthCB
->get_active())
1185 aSz
.SetHeightPercent(SwFormatFrameSize::SYNCED
);
1187 aSz
.SetWidthPercent(SwFormatFrameSize::SYNCED
);
1190 if( !IsInGraficMode() )
1192 if (m_xAutoHeightCB
->get_state_changed_from_saved())
1194 SwFrameSize eFrameSize
= m_xAutoHeightCB
->get_active()? SwFrameSize::Minimum
: SwFrameSize::Fixed
;
1195 if( eFrameSize
!= aSz
.GetHeightSizeType() )
1196 aSz
.SetHeightSizeType(eFrameSize
);
1198 if (m_xAutoWidthCB
->get_state_changed_from_saved())
1200 SwFrameSize eFrameSize
= m_xAutoWidthCB
->get_active()? SwFrameSize::Minimum
: SwFrameSize::Fixed
;
1201 if( eFrameSize
!= aSz
.GetWidthSizeType() )
1202 aSz
.SetWidthSizeType( eFrameSize
);
1205 if (!m_bFormat
&& m_xFixedRatioCB
->get_state_changed_from_saved())
1206 bRet
|= nullptr != rSet
->Put(SfxBoolItem(FN_KEEP_ASPECT_RATIO
, m_xFixedRatioCB
->get_active()));
1208 pOldItem
= GetOldItem(*rSet
, RES_FRM_SIZE
);
1210 if ((pOldItem
&& aSz
!= *pOldItem
) || (!pOldItem
&& !m_bFormat
) ||
1212 (aSz
.GetWidth() > 0 || aSz
.GetWidthPercent() > 0) &&
1213 (aSz
.GetHeight() > 0 || aSz
.GetHeightPercent() > 0)))
1215 if (aSz
.GetHeightSizeType() == SwFrameSize::Variable
) // there is no VAR_SIZE in frames
1216 aSz
.SetHeightSizeType(SwFrameSize::Minimum
);
1218 bRet
|= nullptr != rSet
->Put( aSz
);
1220 if (m_xFollowTextFlowCB
->get_state_changed_from_saved())
1222 bRet
|= nullptr != rSet
->Put(SwFormatFollowTextFlow(m_xFollowTextFlowCB
->get_active()));
1227 // initialise horizontal and vertical Pos
1228 void SwFramePage::InitPos(RndStdIds eId
,
1236 auto nPos
= m_xVerticalDLB
->get_active();
1237 if (nPos
!= -1 && m_pVMap
)
1239 m_nOldV
= m_pVMap
[nPos
].nAlign
;
1241 nPos
= m_xVertRelationLB
->get_active();
1243 m_nOldVRel
= reinterpret_cast<RelationMap
*>(m_xVertRelationLB
->get_id(nPos
).toInt64())->nRelation
;
1246 nPos
= m_xHorizontalDLB
->get_active();
1247 if (nPos
!= -1 && m_pHMap
)
1249 m_nOldH
= m_pHMap
[nPos
].nAlign
;
1251 nPos
= m_xHoriRelationLB
->get_active();
1253 m_nOldHRel
= reinterpret_cast<RelationMap
*>(m_xHoriRelationLB
->get_id(nPos
).toInt64())->nRelation
;
1256 bool bEnable
= true;
1257 if ( eId
== RndStdIds::FLY_AT_PAGE
)
1259 m_pVMap
= m_bHtmlMode
? aVPageHtmlMap
: aVPageMap
;
1260 m_pHMap
= m_bHtmlMode
? aHPageHtmlMap
: aHPageMap
;
1262 else if ( eId
== RndStdIds::FLY_AT_FLY
)
1264 // own vertical alignment map for to frame
1265 // anchored objects.
1266 m_pVMap
= m_bHtmlMode
? aVFlyHtmlMap
: aVFrameMap
;
1267 m_pHMap
= m_bHtmlMode
? aHFlyHtmlMap
: aHFrameMap
;
1269 else if ( eId
== RndStdIds::FLY_AT_PARA
)
1273 m_pVMap
= aVParaHtmlMap
;
1274 m_pHMap
= aHParaHtmlAbsMap
;
1278 m_pVMap
= aVParaMap
;
1279 m_pHMap
= aHParaMap
;
1282 else if ( eId
== RndStdIds::FLY_AT_CHAR
)
1286 m_pVMap
= aVCharHtmlAbsMap
;
1287 m_pHMap
= aHCharHtmlAbsMap
;
1291 m_pVMap
= aVCharMap
;
1292 m_pHMap
= aHCharMap
;
1295 else if ( eId
== RndStdIds::FLY_AS_CHAR
)
1297 m_pVMap
= m_bHtmlMode
? aVAsCharHtmlMap
: aVAsCharMap
;
1301 m_xHorizontalDLB
->set_sensitive( bEnable
);
1302 m_xHorizontalFT
->set_sensitive( bEnable
);
1304 // select current Pos
1311 sal_Int32 nMapPos
= FillPosLB(m_pHMap
, nH
, nHRel
, *m_xHorizontalDLB
);
1312 FillRelLB(m_pHMap
, nMapPos
, nH
, nHRel
, *m_xHoriRelationLB
, *m_xHoriRelationFT
);
1320 nMapPos
= FillPosLB(m_pVMap
, nV
, nVRel
, *m_xVerticalDLB
);
1321 FillRelLB(m_pVMap
, nMapPos
, nV
, nVRel
, *m_xVertRelationLB
, *m_xVertRelationFT
);
1323 bEnable
= nH
== text::HoriOrientation::NONE
&& eId
!= RndStdIds::FLY_AS_CHAR
;
1325 m_xAtHorzPosED
->set_value(0, FieldUnit::TWIP
);
1329 m_xAtHorzPosED
->set_value(m_xAtHorzPosED
->normalize(nX
), FieldUnit::TWIP
);
1331 m_xAtHorzPosFT
->set_sensitive( bEnable
);
1332 m_xAtHorzPosED
->set_sensitive( bEnable
);
1334 bEnable
= nV
== text::VertOrientation::NONE
;
1336 m_xAtVertPosED
->set_value(0, FieldUnit::TWIP
);
1339 if (eId
== RndStdIds::FLY_AS_CHAR
)
1341 if ( nY
== LONG_MAX
)
1346 if ( nY
!= LONG_MAX
)
1347 m_xAtVertPosED
->set_value(m_xAtVertPosED
->normalize(nY
), FieldUnit::TWIP
);
1349 m_xAtVertPosFT
->set_sensitive( bEnable
&& m_bAllowVertPositioning
);
1350 m_xAtVertPosED
->set_sensitive( bEnable
&& m_bAllowVertPositioning
);
1354 sal_Int32
SwFramePage::FillPosLB(const FrameMap
* _pMap
,
1355 const sal_Int16 _nAlign
,
1356 const sal_Int16 _nRel
,
1357 weld::ComboBox
& _rLB
)
1360 const OUString sOldEntry
= _rLB
.get_active_text();
1364 // i#22341 determine all possible listbox relations for
1365 // given relation for map <aVCharMap>
1366 const LB nLBRelations
= (_pMap
!= aVCharMap
)
1368 : ::lcl_GetLBRelationsForRelations( _nRel
);
1371 size_t nCount
= ::lcl_GetFrameMapCount(_pMap
);
1372 for (size_t i
= 0; _pMap
&& i
< nCount
; ++i
)
1374 // Why not from the left/from inside or from above?
1375 SvxSwFramePosString::StringId eStrId
= m_xMirrorPagesCB
->get_active() ? _pMap
[i
].eMirrorStrId
: _pMap
[i
].eStrId
;
1376 // --> OD 2009-08-31 #mongolianlayout#
1377 eStrId
= lcl_ChangeResIdToVerticalOrRTL( eStrId
,
1380 m_bIsInRightToLeft
);
1381 OUString
sEntry(SvxSwFramePosString::GetString(eStrId
));
1382 if (_rLB
.find_text(sEntry
) == -1)
1384 // don't insert entries when frames are character bound
1385 _rLB
.append_text(sEntry
);
1387 // i#22341 - add condition to handle map <aVCharMap>
1388 // that is ambiguous in the alignment.
1389 if ( _pMap
[i
].nAlign
== _nAlign
&&
1390 ( (_pMap
!= aVCharMap
) || _pMap
[i
].nLBRelations
& nLBRelations
) )
1396 _rLB
.set_active_text(sSelEntry
);
1397 if (_rLB
.get_active() == -1)
1398 _rLB
.set_active_text(sOldEntry
);
1400 if (_rLB
.get_active() == -1)
1405 return GetMapPos(_pMap
, _rLB
);
1408 void SwFramePage::FillRelLB(const FrameMap
* _pMap
,
1409 const sal_uInt16 _nLBSelPos
,
1410 const sal_Int16 _nAlign
,
1411 const sal_Int16 _nRel
,
1412 weld::ComboBox
& _rLB
,
1416 LB nLBRelations
= LB::NONE
;
1417 size_t nMapCount
= ::lcl_GetFrameMapCount(_pMap
);
1421 if (_nLBSelPos
< nMapCount
)
1423 if (_pMap
== aVAsCharHtmlMap
|| _pMap
== aVAsCharMap
)
1425 const OUString
sOldEntry(_rLB
.get_active_text());
1426 SvxSwFramePosString::StringId eStrId
= _pMap
[_nLBSelPos
].eStrId
;
1428 for (size_t nMapPos
= 0; nMapPos
< nMapCount
; nMapPos
++)
1430 if (_pMap
[nMapPos
].eStrId
== eStrId
)
1432 nLBRelations
= _pMap
[nMapPos
].nLBRelations
;
1433 for (RelationMap
const & rCharMap
: aAsCharRelationMap
)
1435 if (nLBRelations
& rCharMap
.nLBRelation
)
1437 // --> OD 2009-08-31 #mongolianlayout#
1438 SvxSwFramePosString::StringId sStrId1
=
1439 lcl_ChangeResIdToVerticalOrRTL( rCharMap
.eStrId
,
1442 m_bIsInRightToLeft
);
1443 const OUString sEntry
= SvxSwFramePosString::GetString(sStrId1
);
1444 _rLB
.append(OUString::number(reinterpret_cast<sal_Int64
>(&rCharMap
)), sEntry
);
1445 if (_pMap
[nMapPos
].nAlign
== _nAlign
)
1452 if (!sSelEntry
.isEmpty())
1453 _rLB
.set_active_text(sSelEntry
);
1456 _rLB
.set_active_text(sOldEntry
);
1458 if (_rLB
.get_active() == -1)
1460 for (int i
= 0; i
< _rLB
.get_count(); i
++)
1462 RelationMap
*pEntry
= reinterpret_cast<RelationMap
*>(_rLB
.get_id(i
).toInt64());
1463 if (pEntry
->nLBRelation
== LB::RelChar
) // default
1474 // special handling for map <aVCharMap>,
1475 // because its ambiguous in its <eStrId>/<eMirrorStrId>.
1476 if ( _pMap
== aVCharMap
)
1478 nLBRelations
= ::lcl_GetLBRelationsForStrID( _pMap
,
1479 ( m_xMirrorPagesCB
->get_active()
1480 ? _pMap
[_nLBSelPos
].eMirrorStrId
1481 : _pMap
[_nLBSelPos
].eStrId
),
1482 m_xMirrorPagesCB
->get_active() );
1486 nLBRelations
= _pMap
[_nLBSelPos
].nLBRelations
;
1489 for (sal_uLong nBit
= 1; nBit
< 0x80000000; nBit
<<= 1)
1491 if (nLBRelations
& static_cast<LB
>(nBit
))
1493 for (RelationMap
const & rMap
: aRelationMap
)
1495 if (rMap
.nLBRelation
== static_cast<LB
>(nBit
))
1497 SvxSwFramePosString::StringId eStrId1
= m_xMirrorPagesCB
->get_active() ?
1498 rMap
.eMirrorStrId
: rMap
.eStrId
;
1499 // --> OD 2009-08-31 #mongolianlayout#
1501 lcl_ChangeResIdToVerticalOrRTL( eStrId1
,
1504 m_bIsInRightToLeft
);
1505 const OUString sEntry
= SvxSwFramePosString::GetString(eStrId1
);
1506 _rLB
.append(OUString::number(reinterpret_cast<sal_Int64
>(&rMap
)), sEntry
);
1507 if (sSelEntry
.isEmpty() && rMap
.nRelation
== _nRel
)
1513 if (!sSelEntry
.isEmpty())
1514 _rLB
.set_active_text(sSelEntry
);
1517 // Probably anchor switch. So look for similar relation
1518 sal_Int16 nSimRel
= -1;
1521 case text::RelOrientation::FRAME
:
1522 nSimRel
= text::RelOrientation::PAGE_FRAME
;
1524 case text::RelOrientation::PRINT_AREA
:
1525 nSimRel
= text::RelOrientation::PAGE_PRINT_AREA
;
1527 case text::RelOrientation::PAGE_LEFT
:
1528 nSimRel
= text::RelOrientation::FRAME_LEFT
;
1530 case text::RelOrientation::PAGE_RIGHT
:
1531 nSimRel
= text::RelOrientation::FRAME_RIGHT
;
1533 case text::RelOrientation::FRAME_LEFT
:
1534 nSimRel
= text::RelOrientation::PAGE_LEFT
;
1536 case text::RelOrientation::FRAME_RIGHT
:
1537 nSimRel
= text::RelOrientation::PAGE_RIGHT
;
1539 case text::RelOrientation::PAGE_FRAME
:
1540 nSimRel
= text::RelOrientation::FRAME
;
1542 case text::RelOrientation::PAGE_PRINT_AREA
:
1543 nSimRel
= text::RelOrientation::PRINT_AREA
;
1547 if (_rLB
.get_active() != -1)
1549 RelationMap
*pEntry
= reinterpret_cast<RelationMap
*>(_rLB
.get_id(_rLB
.get_count() - 1).toInt64());
1550 nSimRel
= pEntry
->nRelation
;
1555 for (int i
= 0; i
< _rLB
.get_count(); i
++)
1557 RelationMap
*pEntry
= reinterpret_cast<RelationMap
*>(_rLB
.get_id(i
).toInt64());
1558 if (pEntry
->nRelation
== nSimRel
)
1565 if (_rLB
.get_active() == -1)
1571 const bool bEnable
= _rLB
.get_count() != 0
1572 && (&_rLB
!= m_xVertRelationLB
.get() || m_bAllowVertPositioning
);
1573 _rLB
.set_sensitive( bEnable
);
1574 _rFT
.set_sensitive( bEnable
);
1579 sal_Int16
SwFramePage::GetRelation(const weld::ComboBox
& rRelationLB
)
1581 const auto nPos
= rRelationLB
.get_active();
1584 RelationMap
*pEntry
= reinterpret_cast<RelationMap
*>(rRelationLB
.get_id(nPos
).toInt64());
1585 return pEntry
->nRelation
;
1591 sal_Int16
SwFramePage::GetAlignment(FrameMap
const *pMap
, sal_Int32 nMapPos
,
1592 const weld::ComboBox
& rRelationLB
)
1594 if (!pMap
|| nMapPos
< 0)
1597 const size_t nMapCount
= ::lcl_GetFrameMapCount(pMap
);
1599 if (o3tl::make_unsigned(nMapPos
) >= nMapCount
)
1602 // i#22341 special handling also for map <aVCharMap>,
1603 // because it contains ambiguous items for alignment
1604 if ( pMap
!= aVAsCharHtmlMap
&& pMap
!= aVAsCharMap
&& pMap
!= aVCharMap
)
1605 return pMap
[nMapPos
].nAlign
;
1607 if (rRelationLB
.get_active() == -1)
1610 const RelationMap
*const pRelationMap
= reinterpret_cast<const RelationMap
*>(
1611 rRelationLB
.get_active_id().toInt64());
1612 const LB nRel
= pRelationMap
->nLBRelation
;
1613 const SvxSwFramePosString::StringId eStrId
= pMap
[nMapPos
].eStrId
;
1615 for (size_t i
= 0; i
< nMapCount
; ++i
)
1617 if (pMap
[i
].eStrId
== eStrId
&& (pMap
[i
].nLBRelations
& nRel
))
1618 return pMap
[i
].nAlign
;
1624 sal_Int32
SwFramePage::GetMapPos(const FrameMap
*pMap
, const weld::ComboBox
& rAlignLB
)
1626 sal_Int32 nMapPos
= 0;
1627 auto nLBSelPos
= rAlignLB
.get_active();
1629 if (nLBSelPos
!= -1)
1631 if (pMap
== aVAsCharHtmlMap
|| pMap
== aVAsCharMap
)
1633 const size_t nMapCount
= ::lcl_GetFrameMapCount(pMap
);
1634 const OUString
sSelEntry(rAlignLB
.get_active_text());
1636 for (size_t i
= 0; i
< nMapCount
; i
++)
1638 SvxSwFramePosString::StringId eResId
= pMap
[i
].eStrId
;
1640 OUString sEntry
= SvxSwFramePosString::GetString(eResId
);
1641 sEntry
= MnemonicGenerator::EraseAllMnemonicChars( sEntry
);
1643 if (sEntry
== sSelEntry
)
1645 nMapPos
= static_cast< sal_Int32
>(i
);
1651 nMapPos
= nLBSelPos
;
1657 RndStdIds
SwFramePage::GetAnchor() const
1659 RndStdIds nRet
= RndStdIds::FLY_AT_PAGE
;
1660 if (m_xAnchorAtParaRB
->get_active())
1662 nRet
= RndStdIds::FLY_AT_PARA
;
1664 else if (m_xAnchorAtCharRB
->get_active())
1666 nRet
= RndStdIds::FLY_AT_CHAR
;
1668 else if (m_xAnchorAsCharRB
->get_active())
1670 nRet
= RndStdIds::FLY_AS_CHAR
;
1672 else if (m_xAnchorAtFrameRB
->get_active())
1674 nRet
= RndStdIds::FLY_AT_FLY
;
1680 void SwFramePage::ActivatePage(const SfxItemSet
& rSet
)
1682 m_bNoModifyHdl
= true;
1684 m_bNoModifyHdl
= false;
1685 //lock PercentFields
1686 m_xWidthED
->LockAutoCalculation(true);
1687 m_xHeightED
->LockAutoCalculation(true);
1688 RangeModifyHdl(); // set all maximum values initially
1689 m_xHeightED
->LockAutoCalculation(false);
1690 m_xWidthED
->LockAutoCalculation(false);
1691 m_xFollowTextFlowCB
->save_state();
1694 DeactivateRC
SwFramePage::DeactivatePage(SfxItemSet
* _pSet
)
1698 FillItemSet( _pSet
);
1700 if (!m_bFormat
) // tdf#112574 no anchor in styles
1702 //FillItemSet doesn't set the anchor into the set when it matches
1703 //the original. But for the other pages we need the current anchor.
1704 SwWrtShell
* pSh
= m_bFormat
? ::GetActiveWrtShell()
1705 : getFrameDlgParentShell();
1706 RndStdIds eAnchorId
= GetAnchor();
1707 SwFormatAnchor
aAnc( eAnchorId
, pSh
->GetPhyPageNum() );
1712 return DeactivateRC::LeavePage
;
1715 // swap left/right with inside/outside
1716 IMPL_LINK_NOARG(SwFramePage
, MirrorHdl
, weld::ToggleButton
&, void)
1718 RndStdIds eId
= GetAnchor();
1719 InitPos(eId
, -1, 0, -1, 0, LONG_MAX
, LONG_MAX
);
1722 IMPL_LINK( SwFramePage
, RelSizeClickHdl
, weld::ToggleButton
&, rBtn
, void )
1724 if (&rBtn
== m_xRelWidthCB
.get())
1726 m_xWidthED
->ShowPercent(rBtn
.get_active());
1727 m_xRelWidthRelationLB
->set_sensitive(rBtn
.get_active());
1728 if (rBtn
.get_active())
1729 m_xWidthED
->get()->set_max(MAX_PERCENT_WIDTH
, FieldUnit::NONE
);
1731 else // rBtn == m_xRelHeightCB.get()
1733 m_xHeightED
->ShowPercent(rBtn
.get_active());
1734 m_xRelHeightRelationLB
->set_sensitive(rBtn
.get_active());
1735 if (rBtn
.get_active())
1736 m_xHeightED
->get()->set_max(MAX_PERCENT_HEIGHT
, FieldUnit::NONE
);
1739 RangeModifyHdl(); // correct the values again
1741 if (&rBtn
== m_xRelWidthCB
.get())
1742 ModifyHdl(*m_xWidthED
->get());
1743 else // rBtn == m_xRelHeightCB.get()
1744 ModifyHdl(*m_xHeightED
->get());
1748 IMPL_LINK_NOARG(SwFramePage
, RangeModifyClickHdl
, weld::ToggleButton
&, void)
1753 void SwFramePage::RangeModifyHdl()
1758 SwWrtShell
* pSh
= m_bFormat
? ::GetActiveWrtShell()
1759 : getFrameDlgParentShell();
1760 OSL_ENSURE(pSh
, "shell not found");
1761 SwFlyFrameAttrMgr
aMgr( m_bNew
, pSh
, GetItemSet() );
1762 SvxSwFrameValidation aVal
;
1764 aVal
.nAnchorType
= GetAnchor();
1765 aVal
.bAutoHeight
= m_xAutoHeightCB
->get_active();
1766 aVal
.bMirror
= m_xMirrorPagesCB
->get_active();
1767 aVal
.bFollowTextFlow
= m_xFollowTextFlowCB
->get_active();
1771 // alignment horizontal
1772 const sal_Int32 nMapPos
= GetMapPos(m_pHMap
, *m_xHorizontalDLB
);
1773 aVal
.nHoriOrient
= GetAlignment(m_pHMap
, nMapPos
, *m_xHoriRelationLB
);
1774 aVal
.nHRelOrient
= GetRelation(*m_xHoriRelationLB
);
1777 aVal
.nHoriOrient
= text::HoriOrientation::NONE
;
1781 // alignment vertical
1782 const sal_Int32 nMapPos
= GetMapPos(m_pVMap
, *m_xVerticalDLB
);
1783 aVal
.nVertOrient
= GetAlignment(m_pVMap
, nMapPos
, *m_xVertRelationLB
);
1784 aVal
.nVRelOrient
= GetRelation(*m_xVertRelationLB
);
1787 aVal
.nVertOrient
= text::VertOrientation::NONE
;
1789 const tools::Long nAtHorzPosVal
= static_cast< tools::Long
>(
1790 m_xAtHorzPosED
->denormalize(m_xAtHorzPosED
->get_value(FieldUnit::TWIP
)) );
1791 const tools::Long nAtVertPosVal
= static_cast< tools::Long
>(
1792 m_xAtVertPosED
->denormalize(m_xAtVertPosED
->get_value(FieldUnit::TWIP
)) );
1794 aVal
.nHPos
= nAtHorzPosVal
;
1795 aVal
.nVPos
= nAtVertPosVal
;
1797 aMgr
.ValidateMetrics(aVal
, mpToCharContentPos
, true); // one time, to get reference values for percental values
1799 // set reference values for percental values (100%) ...
1800 m_xWidthED
->SetRefValue(aVal
.aPercentSize
.Width());
1801 m_xHeightED
->SetRefValue(aVal
.aPercentSize
.Height());
1803 // ... and correctly convert width and height with it
1804 SwTwips nWidth
= static_cast< SwTwips
>(m_xWidthED
->DenormalizePercent(m_xWidthED
->get_value(FieldUnit::TWIP
)));
1805 SwTwips nHeight
= static_cast< SwTwips
>(m_xHeightED
->DenormalizePercent(m_xHeightED
->get_value(FieldUnit::TWIP
)));
1806 aVal
.nWidth
= nWidth
;
1807 aVal
.nHeight
= nHeight
;
1809 aMgr
.ValidateMetrics(aVal
, mpToCharContentPos
); // one more time, to determine all remaining values with correct width and height.
1811 // all columns have to be correct
1812 const SfxItemSet
* pExampleSet
= GetDialogExampleSet();
1813 if (pExampleSet
&& SfxItemState::DEFAULT
<= pExampleSet
->GetItemState(RES_COL
))
1815 const SwFormatCol
& rCol
= pExampleSet
->Get(RES_COL
);
1816 if ( rCol
.GetColumns().size() > 1 )
1818 for (const SwColumn
& i
: rCol
.GetColumns())
1820 aVal
.nMinWidth
+= i
.GetLeft() +
1824 aVal
.nMinWidth
-= MINFLY
;//one was already in there!
1828 nWidth
= aVal
.nWidth
;
1829 nHeight
= aVal
.nHeight
;
1831 // minimum range also for template
1832 m_xHeightED
->set_min(m_xHeightED
->NormalizePercent(aVal
.nMinHeight
), FieldUnit::TWIP
);
1833 m_xWidthED
->set_min(m_xWidthED
->NormalizePercent(aVal
.nMinWidth
), FieldUnit::TWIP
);
1835 SwTwips
nMaxWidth(aVal
.nMaxWidth
);
1836 SwTwips
nMaxHeight(aVal
.nMaxHeight
);
1838 if (aVal
.bAutoHeight
&& (m_sDlgType
== "PictureDialog" || m_sDlgType
== "ObjectDialog"))
1840 SwTwips nTmp
= std::min(nWidth
* nMaxHeight
/ std::max(nHeight
, SwTwips(1)), nMaxHeight
);
1841 m_xWidthED
->set_max(m_xWidthED
->NormalizePercent(nTmp
), FieldUnit::TWIP
);
1843 nTmp
= std::min(nHeight
* nMaxWidth
/ std::max(nWidth
, SwTwips(1)), nMaxWidth
);
1844 m_xHeightED
->set_max(m_xWidthED
->NormalizePercent(nTmp
), FieldUnit::TWIP
);
1848 SwTwips nTmp
= static_cast< SwTwips
>(m_xHeightED
->NormalizePercent(nMaxHeight
));
1849 m_xHeightED
->set_max(nTmp
, FieldUnit::TWIP
);
1851 nTmp
= static_cast< SwTwips
>(m_xWidthED
->NormalizePercent(nMaxWidth
));
1852 m_xWidthED
->set_max(nTmp
, FieldUnit::TWIP
);
1855 m_xAtHorzPosED
->set_range(m_xAtHorzPosED
->normalize(aVal
.nMinHPos
),
1856 m_xAtHorzPosED
->normalize(aVal
.nMaxHPos
),
1858 if (aVal
.nHPos
!= nAtHorzPosVal
)
1859 m_xAtHorzPosED
->set_value(m_xAtHorzPosED
->normalize(aVal
.nHPos
), FieldUnit::TWIP
);
1861 const SwTwips nUpperOffset
= (aVal
.nAnchorType
== RndStdIds::FLY_AS_CHAR
)
1862 ? m_nUpperBorder
: 0;
1863 const SwTwips nLowerOffset
= (aVal
.nAnchorType
== RndStdIds::FLY_AS_CHAR
)
1864 ? m_nLowerBorder
: 0;
1866 m_xAtVertPosED
->set_range(m_xAtVertPosED
->normalize(aVal
.nMinVPos
+ nLowerOffset
+ nUpperOffset
),
1867 m_xAtVertPosED
->normalize(aVal
.nMaxVPos
),
1869 if (aVal
.nVPos
!= nAtVertPosVal
)
1870 m_xAtVertPosED
->set_value(m_xAtVertPosED
->normalize(aVal
.nVPos
), FieldUnit::TWIP
);
1873 IMPL_LINK_NOARG(SwFramePage
, AnchorTypeHdl
, weld::ToggleButton
&, void)
1875 m_xMirrorPagesCB
->set_sensitive(!m_xAnchorAsCharRB
->get_active());
1877 // i#18732 - enable check box 'Follow text flow' for anchor
1878 // type to-paragraph' and to-character
1879 // i#22305 - enable check box 'Follow text
1880 // flow' also for anchor type to-frame.
1881 m_xFollowTextFlowCB
->set_sensitive(m_xAnchorAtParaRB
->get_active() ||
1882 m_xAnchorAtCharRB
->get_active() ||
1883 m_xAnchorAtFrameRB
->get_active());
1885 RndStdIds eId
= GetAnchor();
1887 InitPos( eId
, -1, 0, -1, 0, LONG_MAX
, LONG_MAX
);
1892 PosHdl(*m_xHorizontalDLB
);
1893 PosHdl(*m_xVerticalDLB
);
1896 EnableVerticalPositioning( !(m_bIsMathOLE
&& m_bIsMathBaselineAlignment
1897 && RndStdIds::FLY_AS_CHAR
== eId
) );
1900 IMPL_LINK( SwFramePage
, PosHdl
, weld::ComboBox
&, rLB
, void )
1902 bool bHori
= &rLB
== m_xHorizontalDLB
.get();
1903 weld::ComboBox
*pRelLB
= bHori
? m_xHoriRelationLB
.get() : m_xVertRelationLB
.get();
1904 weld::Label
*pRelFT
= bHori
? m_xHoriRelationFT
.get() : m_xVertRelationFT
.get();
1905 FrameMap
const *pMap
= bHori
? m_pHMap
: m_pVMap
;
1907 const sal_Int32 nMapPos
= GetMapPos(pMap
, rLB
);
1908 const sal_Int16 nAlign
= GetAlignment(pMap
, nMapPos
, *pRelLB
);
1912 bool bEnable
= text::HoriOrientation::NONE
== nAlign
;
1913 m_xAtHorzPosED
->set_sensitive( bEnable
);
1914 m_xAtHorzPosFT
->set_sensitive( bEnable
);
1918 bool bEnable
= text::VertOrientation::NONE
== nAlign
&& m_bAllowVertPositioning
;
1919 m_xAtVertPosED
->set_sensitive( bEnable
);
1920 m_xAtVertPosFT
->set_sensitive( bEnable
);
1926 if (rLB
.get_active() != -1)
1928 if (pRelLB
->get_active() != -1)
1929 nRel
= reinterpret_cast<RelationMap
*>(pRelLB
->get_active_id().toInt64())->nRelation
;
1930 FillRelLB(pMap
, nMapPos
, nAlign
, nRel
, *pRelLB
, *pRelFT
);
1938 m_bAtHorzPosModified
= true;
1940 m_bAtVertPosModified
= true;
1942 // special treatment for HTML-Mode with horizontal-vertical-dependencies
1943 if(!(m_bHtmlMode
&& (RndStdIds::FLY_AT_CHAR
== GetAnchor())))
1949 // right is allowed only above - from the left only above
1950 // from the left at character -> below
1951 if((text::HoriOrientation::LEFT
== nAlign
|| text::HoriOrientation::RIGHT
== nAlign
) &&
1952 0 == m_xVerticalDLB
->get_active())
1954 if(text::RelOrientation::FRAME
== nRel
)
1955 m_xVerticalDLB
->set_active(1);
1957 m_xVerticalDLB
->set_active(0);
1960 else if(text::HoriOrientation::LEFT
== nAlign
&& 1 == m_xVerticalDLB
->get_active())
1962 m_xVerticalDLB
->set_active(0);
1965 else if(text::HoriOrientation::NONE
== nAlign
&& 1 == m_xVerticalDLB
->get_active())
1967 m_xVerticalDLB
->set_active(0);
1971 PosHdl(*m_xVerticalDLB
);
1975 if(text::VertOrientation::TOP
== nAlign
)
1977 if (1 == m_xHorizontalDLB
->get_active())
1979 m_xHorizontalDLB
->set_active(0);
1982 m_xHoriRelationLB
->set_active(1);
1984 else if(text::VertOrientation::CHAR_BOTTOM
== nAlign
)
1986 if (2 == m_xHorizontalDLB
->get_active())
1988 m_xHorizontalDLB
->set_active(0);
1991 m_xHoriRelationLB
->set_active(0) ;
1994 PosHdl(*m_xHorizontalDLB
);
1999 IMPL_LINK( SwFramePage
, RelHdl
, weld::ComboBox
&, rLB
, void )
2001 bool bHori
= &rLB
== m_xHoriRelationLB
.get();
2006 m_bAtHorzPosModified
= true;
2008 m_bAtVertPosModified
= true;
2010 if (m_bHtmlMode
&& (RndStdIds::FLY_AT_CHAR
== GetAnchor()))
2014 const sal_Int16 nRel
= GetRelation(*m_xHoriRelationLB
);
2015 if(text::RelOrientation::PRINT_AREA
== nRel
&& 0 == m_xVerticalDLB
->get_active())
2017 m_xVerticalDLB
->set_active(1);
2019 else if(text::RelOrientation::CHAR
== nRel
&& 1 == m_xVerticalDLB
->get_active())
2021 m_xVerticalDLB
->set_active(0);
2028 IMPL_LINK_NOARG(SwFramePage
, RealSizeHdl
, weld::Button
&, void)
2030 m_xWidthED
->set_value(m_xWidthED
->NormalizePercent(m_aGrfSize
.Width()), FieldUnit::TWIP
);
2031 m_xHeightED
->set_value(m_xHeightED
->NormalizePercent(m_aGrfSize
.Height()), FieldUnit::TWIP
);
2032 m_fWidthHeightRatio
= m_aGrfSize
.Height() ? double(m_aGrfSize
.Width()) / double(m_aGrfSize
.Height()) : 1.0;
2036 IMPL_LINK_NOARG(SwFramePage
, AutoWidthClickHdl
, weld::ToggleButton
&, void)
2038 if( !IsInGraficMode() )
2039 HandleAutoCB( m_xAutoWidthCB
->get_active(), *m_xWidthFT
, *m_xWidthAutoFT
, *m_xWidthED
->get() );
2042 IMPL_LINK_NOARG(SwFramePage
, AutoHeightClickHdl
, weld::ToggleButton
&, void)
2044 if (!IsInGraficMode())
2045 HandleAutoCB(m_xAutoHeightCB
->get_active(), *m_xHeightFT
, *m_xHeightAutoFT
, *m_xWidthED
->get());
2048 IMPL_LINK( SwFramePage
, ModifyHdl
, weld::MetricSpinButton
&, rEdit
, void )
2050 SwTwips nWidth
= static_cast< SwTwips
>(m_xWidthED
->DenormalizePercent(m_xWidthED
->get_value(FieldUnit::TWIP
)));
2051 SwTwips nHeight
= static_cast< SwTwips
>(m_xHeightED
->DenormalizePercent(m_xHeightED
->get_value(FieldUnit::TWIP
)));
2052 if (m_xFixedRatioCB
->get_active())
2054 if (&rEdit
== m_xWidthED
->get())
2056 nHeight
= SwTwips(static_cast<double>(nWidth
) / m_fWidthHeightRatio
);
2057 m_xHeightED
->set_value(m_xHeightED
->NormalizePercent(nHeight
), FieldUnit::TWIP
);
2059 else if (&rEdit
== m_xHeightED
->get())
2061 nWidth
= SwTwips(static_cast<double>(nHeight
) * m_fWidthHeightRatio
);
2062 m_xWidthED
->set_value(m_xWidthED
->NormalizePercent(nWidth
), FieldUnit::TWIP
);
2065 m_fWidthHeightRatio
= nHeight
? double(nWidth
) / double(nHeight
) : 1.0;
2069 void SwFramePage::UpdateExample()
2071 auto nPos
= m_xHorizontalDLB
->get_active();
2072 if (m_pHMap
&& nPos
!= -1)
2074 const sal_Int32 nMapPos
= GetMapPos(m_pHMap
, *m_xHorizontalDLB
);
2075 m_aExampleWN
.SetHAlign(GetAlignment(m_pHMap
, nMapPos
, *m_xHoriRelationLB
));
2076 m_aExampleWN
.SetHoriRel(GetRelation(*m_xHoriRelationLB
));
2079 nPos
= m_xVerticalDLB
->get_active();
2080 if (m_pVMap
&& nPos
!= -1)
2082 const sal_Int32 nMapPos
= GetMapPos(m_pVMap
, *m_xVerticalDLB
);
2083 m_aExampleWN
.SetVAlign(GetAlignment(m_pVMap
, nMapPos
, *m_xVertRelationLB
));
2084 m_aExampleWN
.SetVertRel(GetRelation(*m_xVertRelationLB
));
2088 auto nXPos
= m_xAtHorzPosED
->denormalize(m_xAtHorzPosED
->get_value(FieldUnit::TWIP
));
2089 auto nYPos
= m_xAtVertPosED
->denormalize(m_xAtVertPosED
->get_value(FieldUnit::TWIP
));
2090 m_aExampleWN
.SetRelPos(Point(nXPos
, nYPos
));
2092 m_aExampleWN
.SetAnchor(GetAnchor());
2093 m_aExampleWN
.Invalidate();
2096 void SwFramePage::Init(const SfxItemSet
& rSet
)
2100 SwWrtShell
* pSh
= getFrameDlgParentShell();
2103 const bool bSizeFixed
= pSh
->IsSelObjProtected( FlyProtectFlags::Fixed
) != FlyProtectFlags::NONE
;
2105 m_xWidthED
->set_sensitive( !bSizeFixed
);
2106 m_xHeightED
->set_sensitive( !bSizeFixed
);
2108 // size controls for math OLE objects
2109 if ( m_sDlgType
== "ObjectDialog" && ! m_bNew
)
2111 // disable width and height for math objects
2112 const SvGlobalName
& rFactNm( pSh
->GetOLEObject()->getClassID() );
2114 static struct GlobalNameId
{
2117 sal_uInt8 b8
, b9
, b10
, b11
, b12
, b13
, b14
, b15
;
2118 } const aGlbNmIds
[] = { { SO3_SM_CLASSID_60
}, { SO3_SM_CLASSID_50
},
2119 { SO3_SM_CLASSID_40
}, { SO3_SM_CLASSID_30
} };
2121 for (const GlobalNameId
& rId
: aGlbNmIds
) {
2122 SvGlobalName
aGlbNm( rId
.n1
, rId
.n2
, rId
.n3
,
2123 rId
.b8
, rId
.b9
, rId
.b10
, rId
.b11
,
2124 rId
.b12
, rId
.b13
, rId
.b14
, rId
.b15
);
2126 if( rFactNm
== aGlbNm
)
2128 // disable size controls for math OLE objects
2129 m_xWidthFT
->set_sensitive(false);
2130 m_xWidthED
->set_sensitive(false);
2131 m_xRelWidthCB
->set_sensitive(false);
2132 m_xHeightFT
->set_sensitive(false);
2133 m_xHeightED
->set_sensitive(false);
2134 m_xRelHeightCB
->set_sensitive(false);
2135 m_xFixedRatioCB
->set_sensitive(false);
2136 m_xRealSizeBT
->set_sensitive(false);
2141 // TODO/LATER: get correct aspect
2142 if(0 != (pSh
->GetOLEObject()->getStatus( embed::Aspects::MSOLE_CONTENT
) & embed::EmbedMisc::MS_EMBED_RECOMPOSEONRESIZE
) )
2143 m_xRealSizeBT
->set_sensitive(false);
2147 const SwFormatFrameSize
& rSize
= rSet
.Get(RES_FRM_SIZE
);
2148 sal_Int64 nWidth
= m_xWidthED
->NormalizePercent(rSize
.GetWidth());
2149 sal_Int64 nHeight
= m_xHeightED
->NormalizePercent(rSize
.GetHeight());
2151 if (nWidth
!= m_xWidthED
->get_value(FieldUnit::TWIP
))
2152 m_xWidthED
->set_value(nWidth
, FieldUnit::TWIP
);
2154 if (nHeight
!= m_xHeightED
->get_value(FieldUnit::TWIP
))
2155 m_xHeightED
->set_value(nHeight
, FieldUnit::TWIP
);
2157 if (!IsInGraficMode())
2159 SwFrameSize eSize
= rSize
.GetHeightSizeType();
2160 bool bCheck
= eSize
!= SwFrameSize::Fixed
;
2161 m_xAutoHeightCB
->set_active(bCheck
);
2162 HandleAutoCB( bCheck
, *m_xHeightFT
, *m_xHeightAutoFT
, *m_xWidthED
->get() );
2163 if( eSize
== SwFrameSize::Variable
)
2164 m_xHeightED
->set_value(m_xHeightED
->get_min());
2166 eSize
= rSize
.GetWidthSizeType();
2167 bCheck
= eSize
!= SwFrameSize::Fixed
;
2168 m_xAutoWidthCB
->set_active(bCheck
);
2169 HandleAutoCB( bCheck
, *m_xWidthFT
, *m_xWidthAutoFT
, *m_xWidthED
->get() );
2170 if( eSize
== SwFrameSize::Variable
)
2171 m_xWidthED
->set_value(m_xWidthED
->get_min());
2175 SwWrtShell
* pSh
= getFrameDlgParentShell();
2176 const SwFrameFormat
* pFormat
= pSh
->GetFlyFrameFormat();
2177 if( pFormat
&& pFormat
->GetChain().GetNext() )
2178 m_xAutoHeightCB
->set_sensitive( false );
2182 m_xAutoHeightCB
->hide();
2184 // organise circulation-gap for character bound frames
2185 const SvxULSpaceItem
&rUL
= rSet
.Get(RES_UL_SPACE
);
2186 m_nUpperBorder
= rUL
.GetUpper();
2187 m_nLowerBorder
= rUL
.GetLower();
2189 if(SfxItemState::SET
== rSet
.GetItemState(FN_KEEP_ASPECT_RATIO
))
2191 m_xFixedRatioCB
->set_active(static_cast<const SfxBoolItem
&>(rSet
.Get(FN_KEEP_ASPECT_RATIO
)).GetValue());
2192 m_xFixedRatioCB
->save_state();
2196 SwFormatCol
aCol( rSet
.Get(RES_COL
) );
2197 ::FitToActualSize( aCol
, static_cast<sal_uInt16
>(rSize
.GetWidth()) );
2199 RndStdIds eAnchorId
= GetAnchor();
2201 if ( m_bNew
&& !m_bFormat
)
2202 InitPos(eAnchorId
, -1, 0, -1, 0, LONG_MAX
, LONG_MAX
);
2205 const SwFormatHoriOrient
& rHori
= rSet
.Get(RES_HORI_ORIENT
);
2206 const SwFormatVertOrient
& rVert
= rSet
.Get(RES_VERT_ORIENT
);
2207 m_nOldH
= rHori
.GetHoriOrient();
2208 m_nOldHRel
= rHori
.GetRelationOrient();
2209 m_nOldV
= rVert
.GetVertOrient();
2210 m_nOldVRel
= rVert
.GetRelationOrient();
2212 if (eAnchorId
== RndStdIds::FLY_AT_PAGE
)
2214 if (m_nOldHRel
== text::RelOrientation::FRAME
)
2215 m_nOldHRel
= text::RelOrientation::PAGE_FRAME
;
2216 else if (m_nOldHRel
== text::RelOrientation::PRINT_AREA
)
2217 m_nOldHRel
= text::RelOrientation::PAGE_PRINT_AREA
;
2218 if (m_nOldVRel
== text::RelOrientation::FRAME
)
2219 m_nOldVRel
= text::RelOrientation::PAGE_FRAME
;
2220 else if (m_nOldVRel
== text::RelOrientation::PRINT_AREA
)
2221 m_nOldVRel
= text::RelOrientation::PAGE_PRINT_AREA
;
2224 m_xMirrorPagesCB
->set_active(rHori
.IsPosToggle());
2225 m_xMirrorPagesCB
->save_state();
2236 // transparent for example
2237 // circulation for example
2238 const SwFormatSurround
& rSurround
= rSet
.Get(RES_SURROUND
);
2239 m_aExampleWN
.SetWrap( rSurround
.GetSurround() );
2241 if ( rSurround
.GetSurround() == css::text::WrapTextMode_THROUGH
)
2243 const SvxOpaqueItem
& rOpaque
= rSet
.Get(RES_OPAQUE
);
2244 m_aExampleWN
.SetTransparent(!rOpaque
.GetValue());
2247 // switch to percent if applicable
2248 RangeModifyHdl(); // set reference values (for 100%)
2250 if (rSize
.GetWidthPercent() == SwFormatFrameSize::SYNCED
|| rSize
.GetHeightPercent() == SwFormatFrameSize::SYNCED
)
2251 m_xFixedRatioCB
->set_active(true);
2252 if (rSize
.GetWidthPercent() && rSize
.GetWidthPercent() != SwFormatFrameSize::SYNCED
&&
2253 !m_xRelWidthCB
->get_active())
2255 m_xRelWidthCB
->set_active(true);
2256 RelSizeClickHdl(*m_xRelWidthCB
);
2257 m_xWidthED
->set_value(rSize
.GetWidthPercent(), FieldUnit::PERCENT
);
2259 if (rSize
.GetHeightPercent() && rSize
.GetHeightPercent() != SwFormatFrameSize::SYNCED
&&
2260 !m_xRelHeightCB
->get_active())
2262 m_xRelHeightCB
->set_active(true);
2263 RelSizeClickHdl(*m_xRelHeightCB
);
2264 m_xHeightED
->set_value(rSize
.GetHeightPercent(), FieldUnit::PERCENT
);
2266 m_xRelWidthCB
->save_state();
2267 m_xRelHeightCB
->save_state();
2269 if (rSize
.GetWidthPercentRelation() == text::RelOrientation::PAGE_FRAME
)
2270 m_xRelWidthRelationLB
->set_active(1);
2272 m_xRelWidthRelationLB
->set_active(0);
2274 if (rSize
.GetHeightPercentRelation() == text::RelOrientation::PAGE_FRAME
)
2275 m_xRelHeightRelationLB
->set_active(1);
2277 m_xRelHeightRelationLB
->set_active(0);
2280 void SwFramePage::SetFormatUsed(bool bFormatUsed
)
2282 m_bFormat
= bFormatUsed
;
2284 m_xAnchorFrame
->hide();
2287 void SwFramePage::EnableVerticalPositioning( bool bEnable
)
2289 m_bAllowVertPositioning
= bEnable
;
2290 m_xVerticalFT
->set_sensitive( bEnable
);
2291 m_xVerticalDLB
->set_sensitive( bEnable
);
2292 m_xAtVertPosFT
->set_sensitive( bEnable
);
2293 m_xAtVertPosED
->set_sensitive( bEnable
);
2294 m_xVertRelationFT
->set_sensitive( bEnable
);
2295 m_xVertRelationLB
->set_sensitive( bEnable
);
2298 SwGrfExtPage::SwGrfExtPage(weld::Container
* pPage
, weld::DialogController
* pController
, const SfxItemSet
&rSet
)
2299 : SfxTabPage(pPage
, pController
, "modules/swriter/ui/picturepage.ui", "PicturePage", &rSet
)
2300 , m_bHtmlMode(false)
2301 , m_xMirror(m_xBuilder
->weld_widget("flipframe"))
2302 , m_xMirrorVertBox(m_xBuilder
->weld_check_button("vert"))
2303 , m_xMirrorHorzBox(m_xBuilder
->weld_check_button("hori"))
2304 , m_xAllPagesRB(m_xBuilder
->weld_radio_button("allpages"))
2305 , m_xLeftPagesRB(m_xBuilder
->weld_radio_button("leftpages"))
2306 , m_xRightPagesRB(m_xBuilder
->weld_radio_button("rightpages"))
2307 , m_xConnectED(m_xBuilder
->weld_entry("entry"))
2308 , m_xBrowseBT(m_xBuilder
->weld_button("browse"))
2309 , m_xLinkFrame(m_xBuilder
->weld_frame("linkframe"))
2310 // RotGrfFlyFrame: Need Angle and RotateControls now
2311 , m_xFlAngle(m_xBuilder
->weld_frame("FL_ANGLE"))
2312 , m_xNfAngle(m_xBuilder
->weld_metric_spin_button("NF_ANGLE", FieldUnit::DEGREE
))
2313 , m_xCtlAngle(new svx::DialControl
)
2314 , m_xCtlAngleWin(new weld::CustomWeld(*m_xBuilder
, "CTL_ANGLE", *m_xCtlAngle
))
2315 , m_xBmpWin(new weld::CustomWeld(*m_xBuilder
, "preview", m_aBmpWin
))
2317 m_aBmpWin
.SetBitmapEx(BitmapEx(RID_BMP_PREVIEW_FALLBACK
));
2319 m_xCtlAngle
->SetLinkedField(m_xNfAngle
.get(), 2);
2321 SetExchangeSupport();
2322 m_xMirrorHorzBox
->connect_toggled(LINK(this, SwGrfExtPage
, MirrorHdl
));
2323 m_xMirrorVertBox
->connect_toggled(LINK(this, SwGrfExtPage
, MirrorHdl
));
2324 m_xBrowseBT
->connect_clicked(LINK(this, SwGrfExtPage
, BrowseHdl
));
2327 SwGrfExtPage::~SwGrfExtPage()
2330 m_xCtlAngleWin
.reset();
2331 m_xCtlAngle
.reset();
2335 std::unique_ptr
<SfxTabPage
> SwGrfExtPage::Create(weld::Container
* pPage
, weld::DialogController
* pController
, const SfxItemSet
*rSet
)
2337 return std::make_unique
<SwGrfExtPage
>(pPage
, pController
, *rSet
);
2340 void SwGrfExtPage::Reset(const SfxItemSet
*rSet
)
2342 const SfxPoolItem
* pItem
;
2343 const sal_uInt16 nHtmlMode
= ::GetHtmlMode(static_cast<const SwDocShell
*>(SfxObjectShell::Current()));
2344 m_bHtmlMode
= (nHtmlMode
& HTMLMODE_ON
) != 0;
2346 if( SfxItemState::SET
== rSet
->GetItemState( FN_PARAM_GRF_CONNECT
, true, &pItem
)
2347 && static_cast<const SfxBoolItem
*>(pItem
)->GetValue() )
2349 m_xBrowseBT
->set_sensitive(true);
2350 m_xConnectED
->set_editable(true);
2353 // RotGrfFlyFrame: Get RotationAngle and set at control
2354 if(SfxItemState::SET
== rSet
->GetItemState( SID_ATTR_TRANSFORM_ANGLE
, false, &pItem
))
2356 m_xCtlAngle
->SetRotation(static_cast<const SfxInt32Item
*>(pItem
)->GetValue());
2360 m_xCtlAngle
->SetRotation(0);
2362 m_xCtlAngle
->SaveValue();
2364 ActivatePage(*rSet
);
2367 void SwGrfExtPage::ActivatePage(const SfxItemSet
& rSet
)
2369 const SvxProtectItem
& rProt
= rSet
.Get(RES_PROTECT
);
2370 bool bProtContent
= rProt
.IsContentProtected();
2372 const SfxPoolItem
* pItem
= nullptr;
2373 bool bEnable
= false;
2374 bool bEnableMirrorRB
= false;
2376 SfxItemState eState
= rSet
.GetItemState(RES_GRFATR_MIRRORGRF
, true, &pItem
);
2377 if (SfxItemState::UNKNOWN
!= eState
&& !bProtContent
&& !m_bHtmlMode
)
2379 if( SfxItemState::SET
!= eState
)
2380 pItem
= &rSet
.Get( RES_GRFATR_MIRRORGRF
);
2384 MirrorGraph eMirror
= static_cast<const SwMirrorGrf
* >(pItem
)->GetValue();
2387 case MirrorGraph::Dont
: break;
2388 case MirrorGraph::Vertical
: m_xMirrorHorzBox
->set_active(true); break;
2389 case MirrorGraph::Horizontal
: m_xMirrorVertBox
->set_active(true); break;
2390 case MirrorGraph::Both
: m_xMirrorHorzBox
->set_active(true);
2391 m_xMirrorVertBox
->set_active(true);
2397 const int nPos
= (static_cast<const SwMirrorGrf
* >(pItem
)->IsGrfToggle() ? 1 : 0)
2398 + ((eMirror
== MirrorGraph::Vertical
|| eMirror
== MirrorGraph::Both
) ? 2 : 0);
2400 bEnableMirrorRB
= nPos
!= 0;
2404 case 1: // mirror at left / even pages
2405 m_xLeftPagesRB
->set_active(true);
2406 m_xMirrorHorzBox
->set_active(true);
2408 case 2: // mirror on all pages
2409 m_xAllPagesRB
->set_active(true);
2411 case 3: // mirror on right / odd pages
2412 m_xRightPagesRB
->set_active(true);
2415 m_xAllPagesRB
->set_active(true);
2420 if( SfxItemState::SET
== rSet
.GetItemState( SID_ATTR_GRAF_GRAPHIC
, false, &pItem
) )
2422 const SvxBrushItem
& rBrush
= *static_cast<const SvxBrushItem
*>(pItem
);
2423 if( !rBrush
.GetGraphicLink().isEmpty() )
2425 aGrfName
= aNewGrfName
= rBrush
.GetGraphicLink();
2426 m_xConnectED
->set_text(aNewGrfName
);
2429 SfxStringItem
const * it
= static_cast<SfxStringItem
const *>(
2430 rSet
.GetItem(SID_REFERER
));
2431 if (it
!= nullptr) {
2432 referer
= it
->GetValue();
2434 const Graphic
* pGrf
= rBrush
.GetGraphic(referer
);
2436 m_aBmpWin
.SetGraphic( *pGrf
);
2439 m_xConnectED
->save_value();
2441 m_xMirror
->set_sensitive(bEnable
);
2442 m_xAllPagesRB
->set_sensitive(bEnableMirrorRB
);
2443 m_xLeftPagesRB
->set_sensitive(bEnableMirrorRB
);
2444 m_xRightPagesRB
->set_sensitive(bEnableMirrorRB
);
2446 m_xAllPagesRB
->save_state();
2447 m_xLeftPagesRB
->save_state();
2448 m_xRightPagesRB
->save_state();
2449 m_xMirrorHorzBox
->save_state();
2450 m_xMirrorVertBox
->save_state();
2452 m_aBmpWin
.MirrorHorz( m_xMirrorVertBox
->get_active() );
2453 m_aBmpWin
.MirrorVert( m_xMirrorHorzBox
->get_active() );
2454 m_aBmpWin
.Invalidate();
2457 bool SwGrfExtPage::FillItemSet( SfxItemSet
*rSet
)
2459 bool bModified
= false;
2460 if ( m_xMirrorHorzBox
->get_state_changed_from_saved() ||
2461 m_xMirrorVertBox
->get_state_changed_from_saved() ||
2462 m_xAllPagesRB
->get_state_changed_from_saved() ||
2463 m_xLeftPagesRB
->get_state_changed_from_saved() ||
2464 m_xRightPagesRB
->get_state_changed_from_saved() )
2470 if (m_xMirrorHorzBox
->get_active() &&
2471 !m_xLeftPagesRB
->get_active())
2474 MirrorGraph eMirror
;
2475 eMirror
= m_xMirrorVertBox
->get_active() && bHori
?
2476 MirrorGraph::Both
: bHori
?
2477 MirrorGraph::Vertical
: m_xMirrorVertBox
->get_active() ?
2478 MirrorGraph::Horizontal
: MirrorGraph::Dont
;
2480 bool bMirror
= !m_xAllPagesRB
->get_active();
2481 SwMirrorGrf
aMirror( eMirror
);
2482 aMirror
.SetGrfToggle(bMirror
);
2483 rSet
->Put( aMirror
);
2486 if (aGrfName
!= aNewGrfName
|| m_xConnectED
->get_value_changed_from_saved())
2489 aGrfName
= m_xConnectED
->get_text();
2490 rSet
->Put( SvxBrushItem( aGrfName
, aFilterName
, GPOS_LT
,
2491 SID_ATTR_GRAF_GRAPHIC
));
2494 // RotGrfFlyFrame: Safe rotation if modified
2495 if(m_xCtlAngle
->IsValueModified())
2497 rSet
->Put(SfxInt32Item(GetWhich(SID_ATTR_TRANSFORM_ANGLE
), m_xCtlAngle
->GetRotation()));
2504 DeactivateRC
SwGrfExtPage::DeactivatePage(SfxItemSet
*_pSet
)
2507 FillItemSet( _pSet
);
2508 return DeactivateRC::LeavePage
;
2511 IMPL_LINK_NOARG(SwGrfExtPage
, BrowseHdl
, weld::Button
&, void)
2515 m_xGrfDlg
.reset(new FileDialogHelper(
2516 ui::dialogs::TemplateDescription::FILEOPEN_LINK_PREVIEW
,
2517 FileDialogFlags::Graphic
, GetFrameWeld()));
2518 m_xGrfDlg
->SetTitle(m_xLinkFrame
->get_label());
2520 m_xGrfDlg
->SetDisplayDirectory(m_xConnectED
->get_text());
2521 uno::Reference
< ui::dialogs::XFilePicker3
> xFP
= m_xGrfDlg
->GetFilePicker();
2522 uno::Reference
< ui::dialogs::XFilePickerControlAccess
> xCtrlAcc(xFP
, uno::UNO_QUERY
);
2523 xCtrlAcc
->setValue( ui::dialogs::ExtendedFilePickerElementIds::CHECKBOX_LINK
, 0, uno::makeAny(true) );
2525 if ( m_xGrfDlg
->Execute() != ERRCODE_NONE
)
2528 // remember selected filter
2529 aFilterName
= m_xGrfDlg
->GetCurrentFilter();
2530 aNewGrfName
= INetURLObject::decode( m_xGrfDlg
->GetPath(),
2531 INetURLObject::DecodeMechanism::Unambiguous
);
2532 m_xConnectED
->set_text(aNewGrfName
);
2533 //reset mirrors because maybe a Bitmap was swapped with
2534 //another type of graphic that cannot be mirrored.
2535 m_xMirrorVertBox
->set_active(false);
2536 m_xMirrorHorzBox
->set_active(false);
2537 m_xAllPagesRB
->set_sensitive(false);
2538 m_xLeftPagesRB
->set_sensitive(false);
2539 m_xRightPagesRB
->set_sensitive(false);
2540 m_aBmpWin
.MirrorHorz(false);
2541 m_aBmpWin
.MirrorVert(false);
2544 (void)GraphicFilter::LoadGraphic(m_xGrfDlg
->GetPath(), OUString(), aGraphic
);
2545 m_aBmpWin
.SetGraphic(aGraphic
);
2547 bool bEnable
= GraphicType::Bitmap
== aGraphic
.GetType() ||
2548 GraphicType::GdiMetafile
== aGraphic
.GetType();
2549 m_xMirrorVertBox
->set_sensitive(bEnable
);
2550 m_xMirrorHorzBox
->set_sensitive(bEnable
);
2551 m_xAllPagesRB
->set_sensitive(bEnable
);
2552 m_xLeftPagesRB
->set_sensitive(bEnable
);
2553 m_xRightPagesRB
->set_sensitive(bEnable
);
2557 IMPL_LINK_NOARG(SwGrfExtPage
, MirrorHdl
, weld::ToggleButton
&, void)
2559 bool bEnable
= m_xMirrorHorzBox
->get_active();
2561 m_aBmpWin
.MirrorHorz( m_xMirrorVertBox
->get_active() );
2562 m_aBmpWin
.MirrorVert( bEnable
);
2564 m_xAllPagesRB
->set_sensitive(bEnable
);
2565 m_xLeftPagesRB
->set_sensitive(bEnable
);
2566 m_xRightPagesRB
->set_sensitive(bEnable
);
2568 if (!m_xAllPagesRB
->get_active() && !m_xLeftPagesRB
->get_active() && !m_xRightPagesRB
->get_active())
2569 m_xAllPagesRB
->set_active(true);
2573 BmpWindow::BmpWindow()
2580 void BmpWindow::SetDrawingArea(weld::DrawingArea
* pDrawingArea
)
2582 CustomWidgetController::SetDrawingArea(pDrawingArea
);
2583 Size aSize
= pDrawingArea
->get_ref_device().LogicToPixel(Size(127 , 66), MapMode(MapUnit::MapAppFont
));
2584 set_size_request(aSize
.Width(), aSize
.Height());
2585 SetOutputSizePixel(aSize
);
2588 void BmpWindow::Paint(vcl::RenderContext
& rRenderContext
, const tools::Rectangle
&)
2591 rRenderContext
.SetBackground();
2592 // #i119307# the graphic might have transparency, set up white as the color
2593 // to use when drawing a rectangle under the image
2594 rRenderContext
.SetLineColor(COL_WHITE
);
2595 rRenderContext
.SetFillColor(COL_WHITE
);
2599 Size
aPntSz(GetOutputSizePixel());
2602 aGrfSize
= ::GetGraphicSizeTwip(aGraphic
, &rRenderContext
);
2603 //it should show the default bitmap also if no graphic can be found
2604 if (!aGrfSize
.Width() && !aGrfSize
.Height())
2605 aGrfSize
= rRenderContext
.PixelToLogic(aBmp
.GetSizePixel());
2607 tools::Long nRelGrf
= aGrfSize
.Width() * 100 / aGrfSize
.Height();
2608 tools::Long nRelWin
= aPntSz
.Width() * 100 / aPntSz
.Height();
2609 if (nRelGrf
< nRelWin
)
2611 const tools::Long nWidth
= aPntSz
.Width();
2612 // if we use a replacement preview, try to draw at original size
2613 if (!bGraphic
&& (aGrfSize
.Width() <= aPntSz
.Width())
2614 && (aGrfSize
.Height() <= aPntSz
.Height()))
2616 const tools::Long nHeight
= aPntSz
.Height();
2617 aPntSz
.setWidth( aGrfSize
.Width() );
2618 aPntSz
.setHeight( aGrfSize
.Height() );
2619 aPntPos
.AdjustY((nHeight
- aPntSz
.Height()) / 2 );
2622 aPntSz
.setWidth( aPntSz
.Height() * nRelGrf
/100 );
2624 aPntPos
.AdjustX(nWidth
- aPntSz
.Width() ) ;
2627 // #i119307# clear window background, the graphic might have transparency
2628 rRenderContext
.DrawRect(tools::Rectangle(aPntPos
, aPntSz
));
2632 BitmapEx
aTmpBmp(bGraphic
? aGraphic
.GetBitmapEx() : aBmp
);
2633 BmpMirrorFlags
nMirrorFlags(BmpMirrorFlags::NONE
);
2635 nMirrorFlags
|= BmpMirrorFlags::Vertical
;
2637 nMirrorFlags
|= BmpMirrorFlags::Horizontal
;
2638 aTmpBmp
.Mirror(nMirrorFlags
);
2639 rRenderContext
.DrawBitmapEx(aPntPos
, aPntSz
, aTmpBmp
);
2641 else if (bGraphic
) //draw unmirrored preview graphic
2643 aGraphic
.Draw(&rRenderContext
, aPntPos
, aPntSz
);
2645 else //draw unmirrored stock sample image
2647 rRenderContext
.DrawBitmapEx(aPntPos
, aPntSz
, aBmp
);
2651 BmpWindow::~BmpWindow()
2655 void BmpWindow::SetGraphic(const Graphic
& rGraphic
)
2657 aGraphic
= rGraphic
;
2658 Size aSize
= aGraphic
.GetPrefSize();
2659 bGraphic
= aSize
.Width() && aSize
.Height();
2663 void BmpWindow::SetBitmapEx(const BitmapEx
& rBmp
)
2669 // set URL and ImageMap at frames
2670 SwFrameURLPage::SwFrameURLPage(weld::Container
* pPage
, weld::DialogController
* pController
, const SfxItemSet
&rSet
)
2671 : SfxTabPage(pPage
, pController
, "modules/swriter/ui/frmurlpage.ui", "FrameURLPage", &rSet
)
2672 , m_xURLED(m_xBuilder
->weld_entry("url"))
2673 , m_xSearchPB(m_xBuilder
->weld_button("search"))
2674 , m_xNameED(m_xBuilder
->weld_entry("name"))
2675 , m_xFrameCB(m_xBuilder
->weld_combo_box("frame"))
2676 , m_xServerCB(m_xBuilder
->weld_check_button("server"))
2677 , m_xClientCB(m_xBuilder
->weld_check_button("client"))
2679 m_xSearchPB
->connect_clicked(LINK(this, SwFrameURLPage
, InsertFileHdl
));
2682 SwFrameURLPage::~SwFrameURLPage()
2686 void SwFrameURLPage::Reset( const SfxItemSet
*rSet
)
2688 const SfxPoolItem
* pItem
;
2689 if ( SfxItemState::SET
== rSet
->GetItemState( SID_DOCFRAME
, true, &pItem
))
2691 std::unique_ptr
<TargetList
> pList(new TargetList
);
2692 SfxFrame::GetDefaultTargetList(*pList
);
2693 size_t nCount
= pList
->size();
2694 for (size_t i
= 0; i
< nCount
; ++i
)
2696 m_xFrameCB
->append_text(pList
->at(i
));
2700 if ( SfxItemState::SET
== rSet
->GetItemState( RES_URL
, true, &pItem
) )
2702 const SwFormatURL
* pFormatURL
= static_cast<const SwFormatURL
*>(pItem
);
2703 m_xURLED
->set_text(INetURLObject::decode(pFormatURL
->GetURL(),
2704 INetURLObject::DecodeMechanism::Unambiguous
));
2705 m_xNameED
->set_text(pFormatURL
->GetName());
2707 m_xClientCB
->set_sensitive(pFormatURL
->GetMap() != nullptr);
2708 m_xClientCB
->set_active(pFormatURL
->GetMap() != nullptr);
2709 m_xServerCB
->set_active(pFormatURL
->IsServerMap());
2711 m_xFrameCB
->set_entry_text(pFormatURL
->GetTargetFrameName());
2712 m_xFrameCB
->save_value();
2715 m_xClientCB
->set_sensitive(false);
2717 m_xServerCB
->save_state();
2718 m_xClientCB
->save_state();
2721 bool SwFrameURLPage::FillItemSet(SfxItemSet
*rSet
)
2723 bool bModified
= false;
2724 const SwFormatURL
* pOldURL
= GetOldItem(*rSet
, RES_URL
);
2725 std::unique_ptr
<SwFormatURL
> pFormatURL
;
2727 pFormatURL
.reset(pOldURL
->Clone());
2729 pFormatURL
.reset(new SwFormatURL());
2732 const OUString sText
= m_xURLED
->get_text();
2734 if( pFormatURL
->GetURL() != sText
||
2735 pFormatURL
->GetName() != m_xNameED
->get_text() ||
2736 m_xServerCB
->get_active() != pFormatURL
->IsServerMap() )
2738 pFormatURL
->SetURL(sText
, m_xServerCB
->get_active());
2739 pFormatURL
->SetName(m_xNameED
->get_text());
2744 if (!m_xClientCB
->get_active() && pFormatURL
->GetMap() != nullptr)
2746 pFormatURL
->SetMap(nullptr);
2750 if(pFormatURL
->GetTargetFrameName() != m_xFrameCB
->get_active_text())
2752 pFormatURL
->SetTargetFrameName(m_xFrameCB
->get_active_text());
2755 rSet
->Put(*pFormatURL
);
2759 std::unique_ptr
<SfxTabPage
> SwFrameURLPage::Create(weld::Container
* pPage
, weld::DialogController
* pController
, const SfxItemSet
*rSet
)
2761 return std::make_unique
<SwFrameURLPage
>(pPage
, pController
, *rSet
);
2764 IMPL_LINK_NOARG(SwFrameURLPage
, InsertFileHdl
, weld::Button
&, void)
2766 FileDialogHelper
aDlgHelper(ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE
,
2767 FileDialogFlags::NONE
, GetFrameWeld());
2768 uno::Reference
< ui::dialogs::XFilePicker3
> xFP
= aDlgHelper
.GetFilePicker();
2772 const OUString
sTemp(m_xURLED
->get_text());
2773 if(!sTemp
.isEmpty())
2774 xFP
->setDisplayDirectory(sTemp
);
2776 catch( const uno::Exception
& ) {}
2777 if( aDlgHelper
.Execute() == ERRCODE_NONE
)
2779 m_xURLED
->set_text(xFP
->getSelectedFiles().getConstArray()[0]);
2783 SwFrameAddPage::SwFrameAddPage(weld::Container
* pPage
, weld::DialogController
* pController
, const SfxItemSet
&rSet
)
2784 : SfxTabPage(pPage
, pController
, "modules/swriter/ui/frmaddpage.ui", "FrameAddPage", &rSet
)
2786 , m_bHtmlMode(false)
2789 , m_xNameFrame(m_xBuilder
->weld_widget("nameframe"))
2790 , m_xNameFT(m_xBuilder
->weld_label("name_label"))
2791 , m_xNameED(m_xBuilder
->weld_entry("name"))
2792 , m_xAltNameFT(m_xBuilder
->weld_label("altname_label"))
2793 , m_xAltNameED(m_xBuilder
->weld_entry("altname"))
2794 , m_xDescriptionFT(m_xBuilder
->weld_label("description_label"))
2795 , m_xDescriptionED(m_xBuilder
->weld_text_view("description"))
2796 , m_xPrevFT(m_xBuilder
->weld_label("prev_label"))
2797 , m_xPrevLB(m_xBuilder
->weld_combo_box("prev"))
2798 , m_xNextFT(m_xBuilder
->weld_label("next_label"))
2799 , m_xNextLB(m_xBuilder
->weld_combo_box("next"))
2800 , m_xProtectFrame(m_xBuilder
->weld_widget("protect"))
2801 , m_xProtectContentCB(m_xBuilder
->weld_check_button("protectcontent"))
2802 , m_xProtectFrameCB(m_xBuilder
->weld_check_button("protectframe"))
2803 , m_xProtectSizeCB(m_xBuilder
->weld_check_button("protectsize"))
2804 , m_xContentAlignFrame(m_xBuilder
->weld_widget("contentalign"))
2805 , m_xVertAlignLB(m_xBuilder
->weld_combo_box("vertalign"))
2806 , m_xPropertiesFrame(m_xBuilder
->weld_widget("properties"))
2807 , m_xEditInReadonlyCB(m_xBuilder
->weld_check_button("editinreadonly"))
2808 , m_xPrintFrameCB(m_xBuilder
->weld_check_button("printframe"))
2809 , m_xTextFlowFT(m_xBuilder
->weld_label("textflow_label"))
2810 , m_xTextFlowLB(new svx::FrameDirectionListBox(m_xBuilder
->weld_combo_box("textflow")))
2812 m_xTextFlowLB
->append(SvxFrameDirection::Horizontal_LR_TB
, SvxResId(RID_SVXSTR_FRAMEDIR_LTR
));
2813 m_xTextFlowLB
->append(SvxFrameDirection::Horizontal_RL_TB
, SvxResId(RID_SVXSTR_FRAMEDIR_RTL
));
2814 m_xTextFlowLB
->append(SvxFrameDirection::Vertical_RL_TB
, SvxResId(RID_SVXSTR_PAGEDIR_RTL_VERT
));
2815 m_xTextFlowLB
->append(SvxFrameDirection::Vertical_LR_TB
, SvxResId(RID_SVXSTR_PAGEDIR_LTR_VERT
));
2816 m_xTextFlowLB
->append(SvxFrameDirection::Vertical_LR_BT
, SvxResId(RID_SVXSTR_PAGEDIR_LTR_BTT_VERT
));
2817 m_xTextFlowLB
->append(SvxFrameDirection::Environment
, SvxResId(RID_SVXSTR_FRAMEDIR_SUPER
));
2818 m_xDescriptionED
->set_size_request(-1, m_xDescriptionED
->get_preferred_size().Height());
2821 SwFrameAddPage::~SwFrameAddPage()
2823 m_xTextFlowLB
.reset();
2826 std::unique_ptr
<SfxTabPage
> SwFrameAddPage::Create(weld::Container
* pPage
, weld::DialogController
* pController
, const SfxItemSet
*rSet
)
2828 return std::make_unique
<SwFrameAddPage
>(pPage
, pController
, *rSet
);
2831 void SwFrameAddPage::Reset(const SfxItemSet
*rSet
)
2833 const SfxPoolItem
* pItem
;
2834 sal_uInt16 nHtmlMode
= ::GetHtmlMode(static_cast<const SwDocShell
*>(SfxObjectShell::Current()));
2835 m_bHtmlMode
= (nHtmlMode
& HTMLMODE_ON
) != 0;
2838 m_xProtectFrame
->hide();
2839 m_xEditInReadonlyCB
->hide();
2840 m_xPrintFrameCB
->hide();
2842 if (m_sDlgType
== "PictureDialog" || m_sDlgType
== "ObjectDialog")
2844 m_xEditInReadonlyCB
->hide();
2847 m_xPropertiesFrame
->hide();
2849 m_xContentAlignFrame
->hide();
2852 if(SfxItemState::SET
== rSet
->GetItemState(FN_SET_FRM_ALT_NAME
, false, &pItem
))
2854 m_xAltNameED
->set_text(static_cast<const SfxStringItem
*>(pItem
)->GetValue());
2855 m_xAltNameED
->save_value();
2858 if(SfxItemState::SET
== rSet
->GetItemState(FN_UNO_DESCRIPTION
, false, &pItem
))
2860 m_xDescriptionED
->set_text(static_cast<const SfxStringItem
*>(pItem
)->GetValue());
2861 m_xDescriptionED
->save_value();
2866 // insert graphic - properties
2867 // bNew is not set, so recognise by selection
2869 if(SfxItemState::SET
== rSet
->GetItemState(FN_SET_FRM_NAME
, false, &pItem
))
2871 aTmpName1
= static_cast<const SfxStringItem
*>(pItem
)->GetValue();
2874 OSL_ENSURE(m_pWrtSh
, "no Shell?");
2875 if( m_bNew
|| aTmpName1
.isEmpty() )
2877 if (m_sDlgType
== "PictureDialog")
2878 aTmpName1
= m_pWrtSh
->GetUniqueGrfName();
2879 else if (m_sDlgType
== "ObjectDialog")
2880 aTmpName1
= m_pWrtSh
->GetUniqueOLEName();
2882 aTmpName1
= m_pWrtSh
->GetUniqueFrameName();
2884 m_pWrtSh
->SetFlyName(aTmpName1
);
2887 m_xNameED
->set_text( aTmpName1
);
2888 m_xNameED
->save_value();
2892 m_xNameED
->set_sensitive( false );
2893 m_xAltNameED
->set_sensitive(false);
2894 m_xNameFT
->set_sensitive( false );
2895 m_xAltNameFT
->set_sensitive(false);
2897 if (m_sDlgType
== "FrameDialog" && m_xAltNameFT
->get_visible())
2899 m_xAltNameFT
->hide();
2900 m_xAltNameED
->hide();
2904 m_xNameED
->connect_changed(LINK(this, SwFrameAddPage
, EditModifyHdl
));
2909 SwFrameFormat
* pFormat
= m_pWrtSh
->GetFlyFrameFormat();
2913 const SwFormatChain
&rChain
= pFormat
->GetChain();
2914 const SwFlyFrameFormat
* pFlyFormat
;
2915 OUString sNextChain
, sPrevChain
;
2916 pFlyFormat
= rChain
.GetPrev();
2917 if (pFlyFormat
!= nullptr)
2919 sPrevChain
= pFlyFormat
->GetName();
2922 pFlyFormat
= rChain
.GetNext();
2923 if (pFlyFormat
!= nullptr)
2925 sNextChain
= pFlyFormat
->GetName();
2927 //determine chainable frames
2928 std::vector
< OUString
> aPrevPageFrames
;
2929 std::vector
< OUString
> aThisPageFrames
;
2930 std::vector
< OUString
> aNextPageFrames
;
2931 std::vector
< OUString
> aRemainFrames
;
2932 m_pWrtSh
->GetConnectableFrameFormats(*pFormat
, sNextChain
, false,
2933 aPrevPageFrames
, aThisPageFrames
, aNextPageFrames
, aRemainFrames
);
2934 for (sal_Int32 nEntry
= m_xPrevLB
->get_count(); nEntry
> 1; nEntry
--)
2935 m_xPrevLB
->remove(nEntry
- 1);
2936 lcl_InsertVectors(*m_xPrevLB
, aPrevPageFrames
, aThisPageFrames
, aNextPageFrames
, aRemainFrames
);
2937 if(!sPrevChain
.isEmpty())
2939 if (m_xPrevLB
->find_text(sPrevChain
) == -1)
2940 m_xPrevLB
->insert_text(1, sPrevChain
);
2941 m_xPrevLB
->set_active_text(sPrevChain
);
2944 m_xPrevLB
->set_active(0);
2945 aPrevPageFrames
.clear();
2946 aNextPageFrames
.clear();
2947 aThisPageFrames
.clear();
2948 aRemainFrames
.clear();
2950 m_pWrtSh
->GetConnectableFrameFormats(*pFormat
, sPrevChain
, true,
2951 aPrevPageFrames
, aThisPageFrames
, aNextPageFrames
, aRemainFrames
);
2952 for (sal_Int32 nEntry
= m_xNextLB
->get_count(); nEntry
> 1; nEntry
--)
2953 m_xNextLB
->remove(nEntry
- 1);
2954 lcl_InsertVectors(*m_xNextLB
, aPrevPageFrames
, aThisPageFrames
, aNextPageFrames
, aRemainFrames
);
2955 if(!sNextChain
.isEmpty())
2957 if (m_xNextLB
->find_text(sNextChain
) == -1)
2958 m_xNextLB
->insert_text(1, sNextChain
);
2959 m_xNextLB
->set_active_text(sNextChain
);
2962 m_xNextLB
->set_active(0);
2963 Link
<weld::ComboBox
&,void> aLink(LINK(this, SwFrameAddPage
, ChainModifyHdl
));
2964 m_xPrevLB
->connect_changed(aLink
);
2965 m_xNextLB
->connect_changed(aLink
);
2969 const SvxProtectItem
& rProt
= rSet
->Get(RES_PROTECT
);
2970 m_xProtectFrameCB
->set_active(rProt
.IsPosProtected());
2971 m_xProtectContentCB
->set_active(rProt
.IsContentProtected());
2972 m_xProtectSizeCB
->set_active(rProt
.IsSizeProtected());
2974 const SwFormatEditInReadonly
& rEdit
= rSet
->Get(RES_EDIT_IN_READONLY
);
2975 m_xEditInReadonlyCB
->set_active(rEdit
.GetValue());
2976 m_xEditInReadonlyCB
->save_state();
2979 const SvxPrintItem
& rPrt
= rSet
->Get(RES_PRINT
);
2980 m_xPrintFrameCB
->set_active(rPrt
.GetValue());
2981 m_xPrintFrameCB
->save_state();
2984 if( (!m_bHtmlMode
|| (0 != (nHtmlMode
&HTMLMODE_SOME_STYLES
)))
2985 && m_sDlgType
!= "PictureDialog" && m_sDlgType
!= "ObjectDialog"
2986 && SfxItemState::UNKNOWN
!= rSet
->GetItemState( RES_FRAMEDIR
) )
2988 m_xTextFlowFT
->show();
2989 m_xTextFlowLB
->show();
2991 //vertical text flow is not possible in HTML
2994 m_xTextFlowLB
->remove_id(SvxFrameDirection::Vertical_RL_TB
);
2996 SvxFrameDirection nVal
= rSet
->Get(RES_FRAMEDIR
).GetValue();
2997 m_xTextFlowLB
->set_active_id(nVal
);
2998 m_xTextFlowLB
->save_value();
3002 m_xTextFlowFT
->hide();
3003 m_xTextFlowLB
->hide();
3006 // Content alignment
3007 if ( rSet
->GetItemState(RES_TEXT_VERT_ADJUST
) > SfxItemState::DEFAULT
)
3009 SdrTextVertAdjust nAdjust
= rSet
->Get(RES_TEXT_VERT_ADJUST
).GetValue();
3013 case SDRTEXTVERTADJUST_TOP
: nPos
= 0; break;
3014 case SDRTEXTVERTADJUST_CENTER
:
3015 case SDRTEXTVERTADJUST_BLOCK
: nPos
= 1; break;
3016 case SDRTEXTVERTADJUST_BOTTOM
: nPos
= 2; break;
3018 m_xVertAlignLB
->set_active(nPos
);
3020 m_xVertAlignLB
->save_value();
3023 bool SwFrameAddPage::FillItemSet(SfxItemSet
*rSet
)
3026 if (m_xNameED
->get_value_changed_from_saved())
3027 bRet
|= nullptr != rSet
->Put(SfxStringItem(FN_SET_FRM_NAME
, m_xNameED
->get_text()));
3028 if (m_xAltNameED
->get_value_changed_from_saved())
3029 bRet
|= nullptr != rSet
->Put(SfxStringItem(FN_SET_FRM_ALT_NAME
, m_xAltNameED
->get_text()));
3030 if (m_xDescriptionED
->get_value_changed_from_saved())
3031 bRet
|= nullptr != rSet
->Put(SfxStringItem(FN_UNO_DESCRIPTION
, m_xDescriptionED
->get_text()));
3033 const SfxPoolItem
* pOldItem
;
3034 SvxProtectItem
aProt ( GetItemSet().Get(RES_PROTECT
) );
3035 aProt
.SetContentProtect( m_xProtectContentCB
->get_active() );
3036 aProt
.SetSizeProtect ( m_xProtectSizeCB
->get_active() );
3037 aProt
.SetPosProtect ( m_xProtectFrameCB
->get_active() );
3038 if ( nullptr == (pOldItem
= GetOldItem(*rSet
, FN_SET_PROTECT
)) ||
3039 aProt
!= *pOldItem
)
3040 bRet
|= nullptr != rSet
->Put( aProt
);
3042 if ( m_xEditInReadonlyCB
->get_state_changed_from_saved() )
3043 bRet
|= nullptr != rSet
->Put( SwFormatEditInReadonly( RES_EDIT_IN_READONLY
, m_xEditInReadonlyCB
->get_active()));
3045 if ( m_xPrintFrameCB
->get_state_changed_from_saved() )
3046 bRet
|= nullptr != rSet
->Put( SvxPrintItem( RES_PRINT
, m_xPrintFrameCB
->get_active()));
3049 if (m_xTextFlowLB
->get_visible() && m_xTextFlowLB
->get_value_changed_from_saved())
3051 SvxFrameDirection eDirection
= m_xTextFlowLB
->get_active_id();
3052 bRet
|= nullptr != rSet
->Put( SvxFrameDirectionItem(eDirection
, RES_FRAMEDIR
));
3056 const SwFrameFormat
* pFormat
= m_pWrtSh
->GetFlyFrameFormat();
3059 OUString sCurrentPrevChain
, sCurrentNextChain
;
3060 if (m_xPrevLB
->get_active())
3061 sCurrentPrevChain
= m_xPrevLB
->get_active_text();
3062 if (m_xNextLB
->get_active())
3063 sCurrentNextChain
= m_xNextLB
->get_active_text();
3064 const SwFormatChain
&rChain
= pFormat
->GetChain();
3065 const SwFlyFrameFormat
* pFlyFormat
;
3066 OUString sNextChain
, sPrevChain
;
3067 pFlyFormat
= rChain
.GetPrev();
3068 if (pFlyFormat
!= nullptr)
3069 sPrevChain
= pFlyFormat
->GetName();
3071 pFlyFormat
= rChain
.GetNext();
3072 if (pFlyFormat
!= nullptr)
3073 sNextChain
= pFlyFormat
->GetName();
3074 if(sPrevChain
!= sCurrentPrevChain
)
3075 bRet
|= nullptr != rSet
->Put(SfxStringItem(FN_PARAM_CHAIN_PREVIOUS
, sCurrentPrevChain
));
3076 if(sNextChain
!= sCurrentNextChain
)
3077 bRet
|= nullptr != rSet
->Put(SfxStringItem(FN_PARAM_CHAIN_NEXT
, sCurrentNextChain
));
3081 if (m_xVertAlignLB
->get_value_changed_from_saved())
3083 SdrTextVertAdjust nAdjust
;
3084 switch (m_xVertAlignLB
->get_active())
3087 case 0 : nAdjust
= SDRTEXTVERTADJUST_TOP
; break;
3088 case 1 : nAdjust
= SDRTEXTVERTADJUST_CENTER
; break;
3089 case 2 : nAdjust
= SDRTEXTVERTADJUST_BOTTOM
; break;
3091 bRet
|= nullptr != rSet
->Put(SdrTextVertAdjustItem(nAdjust
, RES_TEXT_VERT_ADJUST
));
3097 IMPL_LINK_NOARG(SwFrameAddPage
, EditModifyHdl
, weld::Entry
&, void)
3099 bool bEnable
= !m_xNameED
->get_text().isEmpty();
3100 m_xAltNameED
->set_sensitive(bEnable
);
3101 m_xAltNameFT
->set_sensitive(bEnable
);
3104 void SwFrameAddPage::SetFormatUsed(bool bFormatUsed
)
3106 m_bFormat
= bFormatUsed
;
3109 m_xNameFrame
->hide();
3113 IMPL_LINK(SwFrameAddPage
, ChainModifyHdl
, weld::ComboBox
&, rBox
, void)
3115 OUString sCurrentPrevChain
, sCurrentNextChain
;
3116 if (m_xPrevLB
->get_active())
3117 sCurrentPrevChain
= m_xPrevLB
->get_active_text();
3118 if (m_xNextLB
->get_active())
3119 sCurrentNextChain
= m_xNextLB
->get_active_text();
3120 SwFrameFormat
* pFormat
= m_pWrtSh
->GetFlyFrameFormat();
3124 bool bNextBox
= m_xNextLB
.get() == &rBox
;
3125 weld::ComboBox
& rChangeLB
= bNextBox
? *m_xPrevLB
: *m_xNextLB
;
3126 for (sal_Int32 nEntry
= rChangeLB
.get_count(); nEntry
> 1; nEntry
--)
3127 rChangeLB
.remove(nEntry
- 1);
3128 //determine chainable frames
3129 std::vector
< OUString
> aPrevPageFrames
;
3130 std::vector
< OUString
> aThisPageFrames
;
3131 std::vector
< OUString
> aNextPageFrames
;
3132 std::vector
< OUString
> aRemainFrames
;
3133 m_pWrtSh
->GetConnectableFrameFormats(*pFormat
, bNextBox
? sCurrentNextChain
: sCurrentPrevChain
, !bNextBox
,
3134 aPrevPageFrames
, aThisPageFrames
, aNextPageFrames
, aRemainFrames
);
3135 lcl_InsertVectors(rChangeLB
,
3136 aPrevPageFrames
, aThisPageFrames
, aNextPageFrames
, aRemainFrames
);
3137 const OUString sToSelect
= bNextBox
? sCurrentPrevChain
: sCurrentNextChain
;
3138 if (rChangeLB
.find_text(sToSelect
) != -1)
3139 rChangeLB
.set_active_text(sToSelect
);
3141 rChangeLB
.set_active(0);
3145 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */