android: Update app-specific/MIME type icons
[LibreOffice.git] / sw / source / ui / frmdlg / frmpage.cxx
blobf9cb766718b1589a5211b77636ef8996a910633c
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <com/sun/star/embed/Aspects.hpp>
21 #include <com/sun/star/embed/EmbedMisc.hpp>
22 #include <com/sun/star/embed/XEmbeddedObject.hpp>
24 #include <cmdid.h>
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/opaqitem.hxx>
32 #include <editeng/protitem.hxx>
33 #include <editeng/prntitem.hxx>
34 #include <editeng/brushitem.hxx>
35 #include <editeng/ulspitem.hxx>
36 #include <editeng/frmdiritem.hxx>
37 #include <svx/swframeposstrings.hxx>
38 #include <svx/swframevalidation.hxx>
39 #include <svx/sdangitm.hxx>
40 #include <comphelper/classids.hxx>
41 #include <tools/globname.hxx>
42 #include <tools/urlobj.hxx>
43 #include <fmturl.hxx>
44 #include <fmteiro.hxx>
45 #include <fmtcnct.hxx>
46 #include <fmtsrnd.hxx>
47 #include <view.hxx>
48 #include <wrtsh.hxx>
49 #include <swmodule.hxx>
50 #include <uitool.hxx>
51 #include <docsh.hxx>
52 #include <viewopt.hxx>
53 #include <frmdlg.hxx>
54 #include <frmmgr.hxx>
55 #include <frmpage.hxx>
56 #include <colmgr.hxx>
57 #include <grfatr.hxx>
58 #include <fmtfollowtextflow.hxx>
59 #include <svx/sdtaitm.hxx>
60 #include <sal/macros.h>
61 #include <osl/diagnose.h>
63 #include <strings.hrc>
64 #include <formatflysplit.hxx>
65 #include <fmtcntnt.hxx>
66 #include <svx/strings.hrc>
67 #include <svx/dialmgr.hxx>
68 #include <svx/graphichelper.hxx>
69 #include <sfx2/filedlghelper.hxx>
70 #include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
71 #include <com/sun/star/ui/dialogs/XFilePicker3.hpp>
72 #include <com/sun/star/ui/dialogs/XFilePickerControlAccess.hpp>
73 #include <com/sun/star/ui/dialogs/ExtendedFilePickerElementIds.hpp>
74 #include <vcl/graphicfilter.hxx>
75 #include <svtools/embedhlp.hxx>
76 #include <comphelper/lok.hxx>
77 #include <memory>
79 using namespace ::com::sun::star;
80 using namespace ::sfx2;
82 #define SwFPos SvxSwFramePosString
84 namespace {
86 struct StringIdPair_Impl
88 SvxSwFramePosString::StringId eHori;
89 SvxSwFramePosString::StringId eVert;
94 #define MAX_PERCENT_WIDTH SAL_CONST_INT64(254)
95 #define MAX_PERCENT_HEIGHT SAL_CONST_INT64(254)
97 namespace {
99 enum class LB {
100 NONE = 0x00000000L,
101 Frame = 0x00000001L, // text region of the paragraph
102 PrintArea = 0x00000002L, // text region of the paragraph + indentions
103 VertFrame = 0x00000004L, // vertical text region of the paragraph
104 VertPrintArea = 0x00000008L, // vertical text region of the paragraph + indentions
105 RelFrameLeft = 0x00000010L, // left paragraph edge
106 RelFrameRight = 0x00000020L, // right paragraph edge
108 RelPageLeft = 0x00000040L, // left page edge
109 RelPageRight = 0x00000080L, // right page edge
110 RelPageFrame = 0x00000100L, // whole page
111 RelPagePrintArea = 0x00000200L, // text region of the page
113 FlyRelPageLeft = 0x00000400L, // left frame edge
114 FlyRelPageRight = 0x00000800L, // right frame edge
115 FlyRelPageFrame = 0x00001000L, // whole frame
116 FlyRelPagePrintArea = 0x00002000L, // inside of the frame
118 RelBase = 0x00010000L, // character alignment Base
119 RelChar = 0x00020000L, // character alignment Character
120 RelRow = 0x00040000L, // character alignment Row
122 FlyVertFrame = 0x00100000L, // vertical entire frame
123 FlyVertPrintArea = 0x00200000L, // vertical frame text area
125 VertLine = 0x00400000L, // vertical text line
130 namespace o3tl {
131 template<> struct typed_flags<LB> : is_typed_flags<LB, 0x00773fffL> {};
134 namespace {
136 struct RelationMap
138 SvxSwFramePosString::StringId eStrId;
139 SvxSwFramePosString::StringId eMirrorStrId;
140 LB nLBRelation;
141 sal_Int16 nRelation;
146 struct FrameMap
148 SvxSwFramePosString::StringId eStrId;
149 SvxSwFramePosString::StringId eMirrorStrId;
150 sal_Int16 nAlign;
151 LB nLBRelations;
155 RelationMap const aRelationMap[] =
157 {SwFPos::FRAME, SwFPos::FRAME, LB::Frame, text::RelOrientation::FRAME},
158 {SwFPos::PRTAREA, SwFPos::PRTAREA, LB::PrintArea, text::RelOrientation::PRINT_AREA},
159 {SwFPos::REL_PG_LEFT, SwFPos::MIR_REL_PG_LEFT, LB::RelPageLeft, text::RelOrientation::PAGE_LEFT},
160 {SwFPos::REL_PG_RIGHT, SwFPos::MIR_REL_PG_RIGHT, LB::RelPageRight, text::RelOrientation::PAGE_RIGHT},
161 {SwFPos::REL_FRM_LEFT, SwFPos::MIR_REL_FRM_LEFT, LB::RelFrameLeft, text::RelOrientation::FRAME_LEFT},
162 {SwFPos::REL_FRM_RIGHT, SwFPos::MIR_REL_FRM_RIGHT, LB::RelFrameRight, text::RelOrientation::FRAME_RIGHT},
163 {SwFPos::REL_PG_FRAME, SwFPos::REL_PG_FRAME, LB::RelPageFrame, text::RelOrientation::PAGE_FRAME},
164 {SwFPos::REL_PG_PRTAREA, SwFPos::REL_PG_PRTAREA, LB::RelPagePrintArea, text::RelOrientation::PAGE_PRINT_AREA},
165 {SwFPos::REL_CHAR, SwFPos::REL_CHAR, LB::RelChar, text::RelOrientation::CHAR},
167 {SwFPos::FLY_REL_PG_LEFT, SwFPos::FLY_MIR_REL_PG_LEFT, LB::FlyRelPageLeft, text::RelOrientation::PAGE_LEFT},
168 {SwFPos::FLY_REL_PG_RIGHT, SwFPos::FLY_MIR_REL_PG_RIGHT, LB::FlyRelPageRight, text::RelOrientation::PAGE_RIGHT},
169 {SwFPos::FLY_REL_PG_FRAME, SwFPos::FLY_REL_PG_FRAME, LB::FlyRelPageFrame, text::RelOrientation::PAGE_FRAME},
170 {SwFPos::FLY_REL_PG_PRTAREA, SwFPos::FLY_REL_PG_PRTAREA, LB::FlyRelPagePrintArea, text::RelOrientation::PAGE_PRINT_AREA},
172 {SwFPos::REL_BORDER, SwFPos::REL_BORDER, LB::VertFrame, text::RelOrientation::FRAME},
173 {SwFPos::REL_PRTAREA, SwFPos::REL_PRTAREA, LB::VertPrintArea, text::RelOrientation::PRINT_AREA},
175 {SwFPos::FLY_REL_PG_FRAME, SwFPos::FLY_REL_PG_FRAME, LB::FlyVertFrame, text::RelOrientation::FRAME},
176 {SwFPos::FLY_REL_PG_PRTAREA, SwFPos::FLY_REL_PG_PRTAREA, LB::FlyVertPrintArea, text::RelOrientation::PRINT_AREA},
178 {SwFPos::REL_LINE, SwFPos::REL_LINE, LB::VertLine, text::RelOrientation::TEXT_LINE}
181 RelationMap const aAsCharRelationMap[] =
183 {SwFPos::REL_BASE, SwFPos::REL_BASE, LB::RelBase, text::RelOrientation::FRAME},
184 {SwFPos::REL_CHAR, SwFPos::REL_CHAR, LB::RelChar, text::RelOrientation::FRAME},
185 {SwFPos::REL_ROW, SwFPos::REL_ROW, LB::RelRow, text::RelOrientation::FRAME}
188 // site anchored
189 constexpr auto HORI_PAGE_REL = LB::RelPageFrame | LB::RelPagePrintArea | LB::RelPageLeft |
190 LB::RelPageRight;
192 FrameMap const aHPageMap[] =
194 {SwFPos::LEFT, SwFPos::MIR_LEFT, text::HoriOrientation::LEFT, HORI_PAGE_REL},
195 {SwFPos::RIGHT, SwFPos::MIR_RIGHT, text::HoriOrientation::RIGHT, HORI_PAGE_REL},
196 {SwFPos::CENTER_HORI, SwFPos::CENTER_HORI, text::HoriOrientation::CENTER, HORI_PAGE_REL},
197 {SwFPos::FROMLEFT, SwFPos::MIR_FROMLEFT, text::HoriOrientation::NONE, HORI_PAGE_REL}
200 FrameMap const aHPageHtmlMap[] =
202 {SwFPos::FROMLEFT, SwFPos::MIR_FROMLEFT, text::HoriOrientation::NONE, LB::RelPageFrame}
205 #define VERT_PAGE_REL (LB::RelPageFrame|LB::RelPagePrintArea)
207 FrameMap const aVPageMap[] =
209 {SwFPos::TOP, SwFPos::TOP, text::VertOrientation::TOP, VERT_PAGE_REL},
210 {SwFPos::BOTTOM, SwFPos::BOTTOM, text::VertOrientation::BOTTOM, VERT_PAGE_REL},
211 {SwFPos::CENTER_VERT, SwFPos::CENTER_VERT, text::VertOrientation::CENTER, VERT_PAGE_REL},
212 {SwFPos::FROMTOP, SwFPos::FROMTOP, text::VertOrientation::NONE, VERT_PAGE_REL}
215 FrameMap const aVPageHtmlMap[] =
217 {SwFPos::FROMTOP, SwFPos::FROMTOP, text::VertOrientation::NONE, LB::RelPageFrame}
220 // frame anchored
221 constexpr auto HORI_FRAME_REL = LB::FlyRelPageFrame | LB::FlyRelPagePrintArea |
222 LB::FlyRelPageLeft | LB::FlyRelPageRight;
224 FrameMap const aHFrameMap[] =
226 {SwFPos::LEFT, SwFPos::MIR_LEFT, text::HoriOrientation::LEFT, HORI_FRAME_REL},
227 {SwFPos::RIGHT, SwFPos::MIR_RIGHT, text::HoriOrientation::RIGHT, HORI_FRAME_REL},
228 {SwFPos::CENTER_HORI, SwFPos::CENTER_HORI, text::HoriOrientation::CENTER, HORI_FRAME_REL},
229 {SwFPos::FROMLEFT, SwFPos::MIR_FROMLEFT, text::HoriOrientation::NONE, HORI_FRAME_REL}
232 FrameMap const aHFlyHtmlMap[] =
234 {SwFPos::LEFT, SwFPos::MIR_LEFT, text::HoriOrientation::LEFT, LB::FlyRelPageFrame},
235 {SwFPos::FROMLEFT, SwFPos::MIR_FROMLEFT, text::HoriOrientation::NONE, LB::FlyRelPageFrame}
238 // own vertical alignment map for objects anchored to frame
239 #define VERT_FRAME_REL (LB::FlyVertFrame|LB::FlyVertPrintArea)
241 FrameMap const aVFrameMap[] =
243 {SwFPos::TOP, SwFPos::TOP, text::VertOrientation::TOP, VERT_FRAME_REL},
244 {SwFPos::BOTTOM, SwFPos::BOTTOM, text::VertOrientation::BOTTOM, VERT_FRAME_REL},
245 {SwFPos::CENTER_VERT, SwFPos::CENTER_VERT, text::VertOrientation::CENTER, VERT_FRAME_REL},
246 {SwFPos::FROMTOP, SwFPos::FROMTOP, text::VertOrientation::NONE, VERT_FRAME_REL}
249 FrameMap const aVFlyHtmlMap[] =
251 {SwFPos::TOP, SwFPos::TOP, text::VertOrientation::TOP, LB::FlyVertFrame},
252 {SwFPos::FROMTOP, SwFPos::FROMTOP, text::VertOrientation::NONE, LB::FlyVertFrame}
255 // paragraph anchored
256 constexpr auto HORI_PARA_REL = LB::Frame | LB::PrintArea | LB::RelPageLeft | LB::RelPageRight |
257 LB::RelPageFrame | LB::RelPagePrintArea | LB::RelFrameLeft |
258 LB::RelFrameRight;
260 FrameMap const aHParaMap[] =
262 {SwFPos::LEFT, SwFPos::MIR_LEFT, text::HoriOrientation::LEFT, HORI_PARA_REL},
263 {SwFPos::RIGHT, SwFPos::MIR_RIGHT, text::HoriOrientation::RIGHT, HORI_PARA_REL},
264 {SwFPos::CENTER_HORI, SwFPos::CENTER_HORI, text::HoriOrientation::CENTER, HORI_PARA_REL},
265 {SwFPos::FROMLEFT, SwFPos::MIR_FROMLEFT, text::HoriOrientation::NONE, HORI_PARA_REL}
268 #define HTML_HORI_PARA_REL (LB::Frame|LB::PrintArea)
270 FrameMap const aHParaHtmlMap[] =
272 {SwFPos::LEFT, SwFPos::LEFT, text::HoriOrientation::LEFT, HTML_HORI_PARA_REL},
273 {SwFPos::RIGHT, SwFPos::RIGHT, text::HoriOrientation::RIGHT, HTML_HORI_PARA_REL}
276 FrameMap const aHParaHtmlAbsMap[] =
278 {SwFPos::LEFT, SwFPos::MIR_LEFT, text::HoriOrientation::LEFT, HTML_HORI_PARA_REL},
279 {SwFPos::RIGHT, SwFPos::MIR_RIGHT, text::HoriOrientation::RIGHT, HTML_HORI_PARA_REL}
282 // allow vertical alignment at page areas
283 constexpr auto VERT_PARA_REL = LB::VertFrame | LB::VertPrintArea |
284 LB::RelPageFrame | LB::RelPagePrintArea;
286 FrameMap const aVParaMap[] =
288 {SwFPos::TOP, SwFPos::TOP, text::VertOrientation::TOP, VERT_PARA_REL},
289 {SwFPos::BOTTOM, SwFPos::BOTTOM, text::VertOrientation::BOTTOM, VERT_PARA_REL},
290 {SwFPos::CENTER_VERT, SwFPos::CENTER_VERT, text::VertOrientation::CENTER, VERT_PARA_REL},
291 {SwFPos::FROMTOP, SwFPos::FROMTOP, text::VertOrientation::NONE, VERT_PARA_REL}
294 FrameMap const aVParaHtmlMap[] =
296 {SwFPos::TOP, SwFPos::TOP, text::VertOrientation::TOP, LB::VertPrintArea}
299 // anchored relative to the character
300 constexpr auto HORI_CHAR_REL = LB::Frame|LB::PrintArea | LB::RelPageLeft | LB::RelPageRight |
301 LB::RelPageFrame | LB::RelPagePrintArea | LB::RelFrameLeft |
302 LB::RelFrameRight | LB::RelChar;
304 FrameMap const aHCharMap[] =
306 {SwFPos::LEFT, SwFPos::MIR_LEFT, text::HoriOrientation::LEFT, HORI_CHAR_REL},
307 {SwFPos::RIGHT, SwFPos::MIR_RIGHT, text::HoriOrientation::RIGHT, HORI_CHAR_REL},
308 {SwFPos::CENTER_HORI, SwFPos::CENTER_HORI, text::HoriOrientation::CENTER, HORI_CHAR_REL},
309 {SwFPos::FROMLEFT, SwFPos::MIR_FROMLEFT, text::HoriOrientation::NONE, HORI_CHAR_REL}
312 #define HTML_HORI_CHAR_REL (LB::Frame|LB::PrintArea|LB::RelChar)
314 FrameMap const aHCharHtmlMap[] =
316 {SwFPos::LEFT, SwFPos::LEFT, text::HoriOrientation::LEFT, HTML_HORI_CHAR_REL},
317 {SwFPos::RIGHT, SwFPos::RIGHT, text::HoriOrientation::RIGHT, HTML_HORI_CHAR_REL}
320 FrameMap const aHCharHtmlAbsMap[] =
322 {SwFPos::LEFT, SwFPos::MIR_LEFT, text::HoriOrientation::LEFT, LB::PrintArea|LB::RelChar},
323 {SwFPos::RIGHT, SwFPos::MIR_RIGHT, text::HoriOrientation::RIGHT, LB::PrintArea},
324 {SwFPos::FROMLEFT, SwFPos::MIR_FROMLEFT, text::HoriOrientation::NONE, LB::RelPageFrame}
327 // allow vertical alignment at page areas
328 constexpr auto VERT_CHAR_REL = LB::VertFrame | LB::VertPrintArea |
329 LB::RelPageFrame | LB::RelPagePrintArea;
331 FrameMap const aVCharMap[] =
333 // introduce mappings for new vertical alignment at top of line <LB::VertLine>
334 // and correct mapping for vertical alignment at character for position <FROM_BOTTOM>
335 // Note: Because of these adjustments the map becomes ambiguous in its values
336 // <eStrId>/<eMirrorStrId> and <nAlign>. These ambiguities are considered
337 // in the methods <SwFramePage::FillRelLB(..)>, <SwFramePage::GetAlignment(..)>
338 // and <SwFramePage::FillPosLB(..)>
339 {SwFPos::TOP, SwFPos::TOP, text::VertOrientation::TOP, VERT_CHAR_REL|LB::RelChar},
340 {SwFPos::BOTTOM, SwFPos::BOTTOM, text::VertOrientation::BOTTOM, VERT_CHAR_REL|LB::RelChar},
341 {SwFPos::BELOW, SwFPos::BELOW, text::VertOrientation::CHAR_BOTTOM, LB::RelChar},
342 {SwFPos::CENTER_VERT, SwFPos::CENTER_VERT, text::VertOrientation::CENTER, VERT_CHAR_REL|LB::RelChar},
343 {SwFPos::FROMTOP, SwFPos::FROMTOP, text::VertOrientation::NONE, VERT_CHAR_REL},
344 {SwFPos::FROMBOTTOM, SwFPos::FROMBOTTOM, text::VertOrientation::NONE, LB::RelChar|LB::VertLine},
345 {SwFPos::TOP, SwFPos::TOP, text::VertOrientation::LINE_TOP, LB::VertLine},
346 {SwFPos::BOTTOM, SwFPos::BOTTOM, text::VertOrientation::LINE_BOTTOM, LB::VertLine},
347 {SwFPos::CENTER_VERT, SwFPos::CENTER_VERT, text::VertOrientation::LINE_CENTER, LB::VertLine}
350 FrameMap const aVCharHtmlMap[] =
352 {SwFPos::BELOW, SwFPos::BELOW, text::VertOrientation::CHAR_BOTTOM, LB::RelChar}
355 FrameMap const aVCharHtmlAbsMap[] =
357 {SwFPos::TOP, SwFPos::TOP, text::VertOrientation::TOP, LB::RelChar},
358 {SwFPos::BELOW, SwFPos::BELOW, text::VertOrientation::CHAR_BOTTOM, LB::RelChar}
361 // anchored as character
362 FrameMap const aVAsCharMap[] =
364 {SwFPos::TOP, SwFPos::TOP, text::VertOrientation::TOP, LB::RelBase},
365 {SwFPos::BOTTOM, SwFPos::BOTTOM, text::VertOrientation::BOTTOM, LB::RelBase},
366 {SwFPos::CENTER_VERT, SwFPos::CENTER_VERT, text::VertOrientation::CENTER, LB::RelBase},
368 {SwFPos::TOP, SwFPos::TOP, text::VertOrientation::CHAR_TOP, LB::RelChar},
369 {SwFPos::BOTTOM, SwFPos::BOTTOM, text::VertOrientation::CHAR_BOTTOM, LB::RelChar},
370 {SwFPos::CENTER_VERT, SwFPos::CENTER_VERT, text::VertOrientation::CHAR_CENTER, LB::RelChar},
372 {SwFPos::TOP, SwFPos::TOP, text::VertOrientation::LINE_TOP, LB::RelRow},
373 {SwFPos::BOTTOM, SwFPos::BOTTOM, text::VertOrientation::LINE_BOTTOM, LB::RelRow},
374 {SwFPos::CENTER_VERT, SwFPos::CENTER_VERT, text::VertOrientation::LINE_CENTER, LB::RelRow},
376 {SwFPos::FROMBOTTOM, SwFPos::FROMBOTTOM, text::VertOrientation::NONE, LB::RelBase}
379 FrameMap const aVAsCharHtmlMap[] =
381 {SwFPos::TOP, SwFPos::TOP, text::VertOrientation::TOP, LB::RelBase},
382 {SwFPos::CENTER_VERT, SwFPos::CENTER_VERT, text::VertOrientation::CENTER, LB::RelBase},
384 {SwFPos::TOP, SwFPos::TOP, text::VertOrientation::CHAR_TOP, LB::RelChar},
386 {SwFPos::TOP, SwFPos::TOP, text::VertOrientation::LINE_TOP, LB::RelRow},
387 {SwFPos::BOTTOM, SwFPos::BOTTOM, text::VertOrientation::LINE_BOTTOM, LB::RelRow},
388 {SwFPos::CENTER_VERT, SwFPos::CENTER_VERT, text::VertOrientation::LINE_CENTER, LB::RelRow}
391 const WhichRangesContainer SwFramePage::s_aPageRg(svl::Items<
392 RES_FRM_SIZE, RES_FRM_SIZE,
393 RES_VERT_ORIENT, RES_ANCHOR,
394 RES_COL, RES_COL,
395 RES_FOLLOW_TEXT_FLOW, RES_FOLLOW_TEXT_FLOW
397 const WhichRangesContainer SwFrameAddPage::s_aAddPgRg(svl::Items<
398 RES_PRINT, RES_PRINT,
399 RES_PROTECT, RES_PROTECT,
400 FN_SET_FRM_NAME, FN_SET_FRM_NAME,
401 FN_SET_FRM_ALT_NAME, FN_SET_FRM_ALT_NAME,
402 FN_UNO_DESCRIPTION, FN_UNO_DESCRIPTION
405 static size_t lcl_GetFrameMapCount( const FrameMap* pMap)
407 if ( pMap )
409 if( pMap == aVParaHtmlMap)
410 return SAL_N_ELEMENTS(aVParaHtmlMap);
411 if( pMap == aVAsCharHtmlMap)
412 return SAL_N_ELEMENTS(aVAsCharHtmlMap);
413 if( pMap == aHParaHtmlMap)
414 return SAL_N_ELEMENTS(aHParaHtmlMap);
415 if( pMap == aHParaHtmlAbsMap)
416 return SAL_N_ELEMENTS(aHParaHtmlAbsMap);
417 if ( pMap == aVPageMap )
418 return SAL_N_ELEMENTS(aVPageMap);
419 if ( pMap == aVPageHtmlMap )
420 return SAL_N_ELEMENTS(aVPageHtmlMap);
421 if ( pMap == aVAsCharMap )
422 return SAL_N_ELEMENTS(aVAsCharMap);
423 if ( pMap == aVParaMap )
424 return SAL_N_ELEMENTS(aVParaMap);
425 if ( pMap == aHParaMap )
426 return SAL_N_ELEMENTS(aHParaMap);
427 if ( pMap == aHFrameMap )
428 return SAL_N_ELEMENTS(aHFrameMap);
429 if ( pMap == aVFrameMap )
430 return SAL_N_ELEMENTS(aVFrameMap);
431 if ( pMap == aHCharMap )
432 return SAL_N_ELEMENTS(aHCharMap);
433 if ( pMap == aHCharHtmlMap )
434 return SAL_N_ELEMENTS(aHCharHtmlMap);
435 if ( pMap == aHCharHtmlAbsMap )
436 return SAL_N_ELEMENTS(aHCharHtmlAbsMap);
437 if ( pMap == aVCharMap )
438 return SAL_N_ELEMENTS(aVCharMap);
439 if ( pMap == aVCharHtmlMap )
440 return SAL_N_ELEMENTS(aVCharHtmlMap);
441 if ( pMap == aVCharHtmlAbsMap )
442 return SAL_N_ELEMENTS(aVCharHtmlAbsMap);
443 if ( pMap == aHPageHtmlMap )
444 return SAL_N_ELEMENTS(aHPageHtmlMap);
445 if ( pMap == aHFlyHtmlMap )
446 return SAL_N_ELEMENTS(aHFlyHtmlMap);
447 if ( pMap == aVFlyHtmlMap )
448 return SAL_N_ELEMENTS(aVFlyHtmlMap);
449 return SAL_N_ELEMENTS(aHPageMap);
451 return 0;
454 static void lcl_InsertVectors(weld::ComboBox& rBox,
455 const std::vector< OUString >& rPrev, const std::vector< OUString >& rThis,
456 const std::vector< OUString >& rNext, const std::vector< OUString >& rRemain)
458 for(const auto& rItem : rPrev)
459 rBox.append_text(rItem);
460 for(const auto& rItem : rThis)
461 rBox.append_text(rItem);
462 for(const auto& rItem : rNext)
463 rBox.append_text(rItem);
464 rBox.append_separator("");
465 //now insert all strings sorted
466 const auto nStartPos = rBox.get_count();
468 for(const auto& rItem : rPrev)
469 ::InsertStringSorted("", rItem, rBox, nStartPos );
470 for(const auto& rItem : rThis)
471 ::InsertStringSorted("", rItem, rBox, nStartPos );
472 for(const auto& rItem : rNext)
473 ::InsertStringSorted("", rItem, rBox, nStartPos );
474 for(const auto& rItem : rRemain)
475 ::InsertStringSorted("", rItem, rBox, nStartPos );
478 // --> OD 2009-08-31 #mongolianlayout#
479 // add input parameter
480 static SvxSwFramePosString::StringId lcl_ChangeResIdToVerticalOrRTL(SvxSwFramePosString::StringId eStringId, bool bVertical, bool bVerticalL2R, bool bRTL)
482 //special handling of STR_FROMLEFT
483 if ( SwFPos::FROMLEFT == eStringId )
485 eStringId = bVertical
486 ? ( bRTL
487 ? SwFPos::FROMBOTTOM
488 : SwFPos::FROMTOP )
489 : ( bRTL
490 ? SwFPos::FROMRIGHT
491 : SwFPos::FROMLEFT );
492 return eStringId;
494 // --> OD 2009-08-31 #mongolianlayout#
495 // special handling of STR_FROMTOP in case of mongolianlayout (vertical left-to-right)
496 if ( SwFPos::FROMTOP == eStringId &&
497 bVertical && bVerticalL2R )
499 eStringId = SwFPos::FROMLEFT;
500 return eStringId;
502 if ( bVertical )
504 //exchange horizontal strings with vertical strings and vice versa
505 static const StringIdPair_Impl aHoriIds[] =
507 {SwFPos::LEFT, SwFPos::TOP},
508 {SwFPos::RIGHT, SwFPos::BOTTOM},
509 {SwFPos::CENTER_HORI, SwFPos::CENTER_VERT},
510 {SwFPos::FROMTOP, SwFPos::FROMRIGHT},
511 {SwFPos::REL_PG_LEFT, SwFPos::REL_PG_TOP},
512 {SwFPos::REL_PG_RIGHT, SwFPos::REL_PG_BOTTOM} ,
513 {SwFPos::REL_FRM_LEFT, SwFPos::REL_FRM_TOP},
514 {SwFPos::REL_FRM_RIGHT, SwFPos::REL_FRM_BOTTOM}
516 static const StringIdPair_Impl aVertIds[] =
518 {SwFPos::TOP, SwFPos::RIGHT},
519 {SwFPos::BOTTOM, SwFPos::LEFT },
520 {SwFPos::CENTER_VERT, SwFPos::CENTER_HORI},
521 {SwFPos::FROMTOP, SwFPos::FROMRIGHT },
522 {SwFPos::REL_PG_TOP, SwFPos::REL_PG_LEFT },
523 {SwFPos::REL_PG_BOTTOM, SwFPos::REL_PG_RIGHT } ,
524 {SwFPos::REL_FRM_TOP, SwFPos::REL_FRM_LEFT },
525 {SwFPos::REL_FRM_BOTTOM, SwFPos::REL_FRM_RIGHT }
527 // --> OD 2009-08-31 #monglianlayout#
528 static const StringIdPair_Impl aVertL2RIds[] =
530 {SwFPos::TOP, SwFPos::LEFT },
531 {SwFPos::BOTTOM, SwFPos::RIGHT },
532 {SwFPos::CENTER_VERT, SwFPos::CENTER_HORI },
533 {SwFPos::FROMTOP, SwFPos::FROMLEFT },
534 {SwFPos::REL_PG_TOP, SwFPos::REL_PG_LEFT },
535 {SwFPos::REL_PG_BOTTOM, SwFPos::REL_PG_RIGHT } ,
536 {SwFPos::REL_FRM_TOP, SwFPos::REL_FRM_LEFT },
537 {SwFPos::REL_FRM_BOTTOM, SwFPos::REL_FRM_RIGHT }
539 for(const StringIdPair_Impl & rHoriId : aHoriIds)
541 if(rHoriId.eHori == eStringId)
543 eStringId = rHoriId.eVert;
544 return eStringId;
547 for(size_t nIndex = 0; nIndex < SAL_N_ELEMENTS(aVertIds); ++nIndex)
549 // --> OD 2009-08-31 #mongolianlayout#
550 if ( !bVerticalL2R )
552 if(aVertIds[nIndex].eHori == eStringId)
554 eStringId = aVertIds[nIndex].eVert;
555 break;
558 else
560 if(aVertL2RIds[nIndex].eHori == eStringId)
562 eStringId = aVertL2RIds[nIndex].eVert;
563 break;
568 return eStringId;
571 // helper method in order to determine all possible
572 // listbox relations in a relation map for a given relation
573 static LB lcl_GetLBRelationsForRelations( const sal_Int16 _nRel )
575 LB nLBRelations = LB::NONE;
577 for (RelationMap const & i : aRelationMap)
579 if ( i.nRelation == _nRel )
581 nLBRelations |= i.nLBRelation;
585 return nLBRelations;
588 // helper method on order to determine all possible
589 // listbox relations in a relation map for a given string ID
590 static LB lcl_GetLBRelationsForStrID( const FrameMap* _pMap,
591 const SvxSwFramePosString::StringId _eStrId,
592 const bool _bUseMirrorStr )
594 LB nLBRelations = LB::NONE;
596 size_t nRelMapSize = lcl_GetFrameMapCount( _pMap );
597 for ( size_t nRelMapPos = 0; nRelMapPos < nRelMapSize; ++nRelMapPos )
599 if ( ( !_bUseMirrorStr && _pMap[nRelMapPos].eStrId == _eStrId ) ||
600 ( _bUseMirrorStr && _pMap[nRelMapPos].eMirrorStrId == _eStrId ) )
602 nLBRelations |= _pMap[nRelMapPos].nLBRelations;
606 return nLBRelations;
609 // standard frame TabPage
610 namespace
612 void HandleAutoCB(bool _bChecked, weld::Label& _rFT_man, weld::Label& _rFT_auto, weld::MetricSpinButton& _rPF_Edit)
614 _rFT_man.set_visible( !_bChecked );
615 _rFT_auto.set_visible( _bChecked );
616 OUString accName = _bChecked ? _rFT_auto.get_label() : _rFT_man.get_label();
617 _rPF_Edit.set_accessible_name(accName);
621 SwFramePage::SwFramePage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet &rSet)
622 : SfxTabPage(pPage, pController, "modules/swriter/ui/frmtypepage.ui", "FrameTypePage", &rSet)
623 , m_bAtHorzPosModified(false)
624 , m_bAtVertPosModified(false)
625 , m_bFormat(false)
626 , m_bNew(true)
627 , m_bNoModifyHdl(true)
628 , m_bIsVerticalFrame(false)
629 , m_bIsVerticalL2R(false)
630 , m_bIsInRightToLeft(false)
631 , m_bHtmlMode(false)
632 , m_nHtmlMode(0)
633 , m_nUpperBorder(0)
634 , m_nLowerBorder(0)
635 , m_fWidthHeightRatio(1.0)
636 , mpToCharContentPos(nullptr)
637 , m_nOldH(text::HoriOrientation::CENTER)
638 , m_nOldHRel(text::RelOrientation::FRAME)
639 , m_nOldV(text::VertOrientation::TOP)
640 , m_nOldVRel(text::RelOrientation::PRINT_AREA)
641 , m_pVMap(nullptr)
642 , m_pHMap(nullptr)
643 , m_bAllowVertPositioning( true )
644 , m_bIsMathOLE(false)
645 , m_bIsMathBaselineAlignment(true)
646 , m_xWidthFT(m_xBuilder->weld_label("widthft"))
647 , m_xWidthAutoFT(m_xBuilder->weld_label("autowidthft"))
648 , m_xRelWidthCB(m_xBuilder->weld_check_button("relwidth"))
649 , m_xRelWidthRelationLB(m_xBuilder->weld_combo_box("relwidthrelation"))
650 , m_xAutoWidthCB(m_xBuilder->weld_check_button("autowidth"))
651 , m_xHeightFT(m_xBuilder->weld_label("heightft"))
652 , m_xHeightAutoFT(m_xBuilder->weld_label("autoheightft"))
653 , m_xRelHeightCB(m_xBuilder->weld_check_button("relheight"))
654 , m_xRelHeightRelationLB(m_xBuilder->weld_combo_box("relheightrelation"))
655 , m_xAutoHeightCB(m_xBuilder->weld_check_button("autoheight"))
656 , m_xFixedRatioCB(m_xBuilder->weld_check_button("ratio"))
657 , m_xRealSizeBT(m_xBuilder->weld_button("origsize"))
658 , m_xAnchorFrame(m_xBuilder->weld_widget("anchorframe"))
659 , m_xAnchorAtPageRB(m_xBuilder->weld_radio_button("topage"))
660 , m_xAnchorAtParaRB(m_xBuilder->weld_radio_button("topara"))
661 , m_xAnchorAtCharRB(m_xBuilder->weld_radio_button("tochar"))
662 , m_xAnchorAsCharRB(m_xBuilder->weld_radio_button("aschar"))
663 , m_xAnchorAtFrameRB(m_xBuilder->weld_radio_button("toframe"))
664 , m_xHorizontalFT(m_xBuilder->weld_label("horiposft"))
665 , m_xHorizontalDLB(m_xBuilder->weld_combo_box("horipos"))
666 , m_xAtHorzPosFT(m_xBuilder->weld_label("horibyft"))
667 , m_xAtHorzPosED(m_xBuilder->weld_metric_spin_button("byhori", FieldUnit::CM))
668 , m_xHoriRelationFT(m_xBuilder->weld_label("horitoft"))
669 , m_xHoriRelationLB(m_xBuilder->weld_combo_box("horianchor"))
670 , m_xMirrorPagesCB(m_xBuilder->weld_check_button("mirror"))
671 , m_xVerticalFT(m_xBuilder->weld_label("vertposft"))
672 , m_xVerticalDLB(m_xBuilder->weld_combo_box("vertpos"))
673 , m_xAtVertPosFT(m_xBuilder->weld_label("vertbyft"))
674 , m_xAtVertPosED(m_xBuilder->weld_metric_spin_button("byvert", FieldUnit::CM))
675 , m_xVertRelationFT(m_xBuilder->weld_label("verttoft"))
676 , m_xVertRelationLB(m_xBuilder->weld_combo_box("vertanchor"))
677 , m_xFollowTextFlowCB(m_xBuilder->weld_check_button("followtextflow"))
678 , m_xFlySplitCB(m_xBuilder->weld_check_button("flysplit"))
679 , m_xExampleWN(new weld::CustomWeld(*m_xBuilder, "preview", m_aExampleWN))
680 , m_xWidthED(new SwPercentField(m_xBuilder->weld_metric_spin_button("width", FieldUnit::CM)))
681 , m_xHeightED(new SwPercentField(m_xBuilder->weld_metric_spin_button("height", FieldUnit::CM)))
683 const auto nWidthRequest = m_xAtHorzPosED->get_preferred_size().Width();
684 m_xAtHorzPosED->set_size_request(nWidthRequest, -1);
685 m_xAtVertPosED->set_size_request(nWidthRequest, -1);
687 setOptimalFrameWidth();
688 setOptimalRelWidth();
690 SetExchangeSupport();
692 Link<weld::MetricSpinButton&,void> aLk3 = LINK(this, SwFramePage, ModifyHdl);
693 m_xWidthED->connect_value_changed( aLk3 );
694 m_xHeightED->connect_value_changed( aLk3 );
695 m_xAtHorzPosED->connect_value_changed( aLk3 );
696 m_xAtVertPosED->connect_value_changed( aLk3 );
697 m_xFollowTextFlowCB->connect_toggled(LINK(this, SwFramePage, RangeModifyClickHdl));
699 Link<weld::Toggleable&,void> aLk2 = LINK(this, SwFramePage, AnchorTypeHdl);
700 m_xAnchorAtPageRB->connect_toggled( aLk2 );
701 m_xAnchorAtParaRB->connect_toggled( aLk2 );
702 m_xAnchorAtCharRB->connect_toggled( aLk2 );
703 m_xAnchorAsCharRB->connect_toggled( aLk2 );
704 m_xAnchorAtFrameRB->connect_toggled( aLk2 );
706 m_xHorizontalDLB->connect_changed(LINK(this, SwFramePage, PosHdl));
707 m_xVerticalDLB->connect_changed(LINK(this, SwFramePage, PosHdl));
709 m_xHoriRelationLB->connect_changed(LINK(this, SwFramePage, RelHdl));
710 m_xVertRelationLB->connect_changed(LINK(this, SwFramePage, RelHdl));
712 m_xMirrorPagesCB->connect_toggled(LINK(this, SwFramePage, MirrorHdl));
714 aLk2 = LINK(this, SwFramePage, RelSizeClickHdl);
715 m_xRelWidthCB->connect_toggled(aLk2);
716 m_xRelHeightCB->connect_toggled(aLk2);
718 m_xAutoWidthCB->connect_toggled(LINK(this, SwFramePage, AutoWidthClickHdl));
719 m_xAutoHeightCB->connect_toggled(LINK(this, SwFramePage, AutoHeightClickHdl));
721 if (comphelper::LibreOfficeKit::isActive())
723 m_xAnchorAtPageRB->hide();
724 m_xAnchorAtParaRB->hide();
725 m_xAnchorAtFrameRB->hide();
729 SwFramePage::~SwFramePage()
733 namespace
735 struct FrameMaps
737 FrameMap const * pMap;
738 size_t nCount;
742 void SwFramePage::setOptimalFrameWidth()
744 static FrameMaps const aMaps[] = {
745 { aHPageMap, SAL_N_ELEMENTS(aHPageMap) },
746 { aHPageHtmlMap, SAL_N_ELEMENTS(aHPageHtmlMap) },
747 { aVPageMap, SAL_N_ELEMENTS(aVPageMap) },
748 { aVPageHtmlMap, SAL_N_ELEMENTS(aVPageHtmlMap) },
749 { aHFrameMap, SAL_N_ELEMENTS(aHFrameMap) },
750 { aHFlyHtmlMap, SAL_N_ELEMENTS(aHFlyHtmlMap) },
751 { aVFrameMap, SAL_N_ELEMENTS(aVFrameMap) },
752 { aVFlyHtmlMap, SAL_N_ELEMENTS(aVFlyHtmlMap) },
753 { aHParaMap, SAL_N_ELEMENTS(aHParaMap) },
754 { aHParaHtmlMap, SAL_N_ELEMENTS(aHParaHtmlMap) },
755 { aHParaHtmlAbsMap, SAL_N_ELEMENTS(aHParaHtmlAbsMap) },
756 { aVParaMap, SAL_N_ELEMENTS(aVParaMap) },
757 { aVParaHtmlMap, SAL_N_ELEMENTS(aVParaHtmlMap) },
758 { aHCharMap, SAL_N_ELEMENTS(aHCharMap) },
759 { aHCharHtmlMap, SAL_N_ELEMENTS(aHCharHtmlMap) },
760 { aHCharHtmlAbsMap, SAL_N_ELEMENTS(aHCharHtmlAbsMap) },
761 { aVCharMap, SAL_N_ELEMENTS(aVCharMap) },
762 { aVCharHtmlMap, SAL_N_ELEMENTS(aVCharHtmlMap) },
763 { aVCharHtmlAbsMap, SAL_N_ELEMENTS(aVCharHtmlAbsMap) },
764 { aVAsCharMap, SAL_N_ELEMENTS(aVAsCharMap) },
765 { aVAsCharHtmlMap, SAL_N_ELEMENTS(aVAsCharHtmlMap) }
768 std::vector<SvxSwFramePosString::StringId> aFrames;
769 for (const FrameMaps & rMap : aMaps)
771 for (size_t j = 0; j < rMap.nCount; ++j)
773 aFrames.push_back(rMap.pMap[j].eStrId);
774 aFrames.push_back(rMap.pMap[j].eMirrorStrId);
778 std::sort(aFrames.begin(), aFrames.end());
779 aFrames.erase(std::unique(aFrames.begin(), aFrames.end()), aFrames.end());
781 for (const auto& rFrame : aFrames)
783 m_xHorizontalDLB->append_text(SvxSwFramePosString::GetString(rFrame));
786 Size aBiggest(m_xHorizontalDLB->get_preferred_size());
787 m_xHorizontalDLB->set_size_request(aBiggest.Width(), -1);
788 m_xVerticalDLB->set_size_request(aBiggest.Width(), -1);
789 m_xHorizontalDLB->clear();
792 namespace
794 struct RelationMaps
796 RelationMap const * pMap;
797 size_t nCount;
800 /// Checks if the current fly frame contains exactly one table.
801 bool ContainsSingleTable(const SwFrameFormat& rFlyFormat)
803 const SwNodeIndex* pStartNode = rFlyFormat.GetContent().GetContentIdx();
804 if (!pStartNode)
806 return false;
809 // Check if the frame content starts with a table.
810 SwNodeIndex aNodeIndex(*pStartNode);
811 ++aNodeIndex;
812 if (!aNodeIndex.GetNode().IsTableNode())
814 return false;
817 // Check if the frame content ends with the same table.
818 SwNodeIndex aEndIndex(*aNodeIndex.GetNode().EndOfSectionNode());
819 ++aEndIndex;
820 if (&aEndIndex.GetNode() != pStartNode->GetNode().EndOfSectionNode())
822 return false;
825 return true;
828 bool ContainsChain(const SwFrameFormat& rFlyFormat)
830 const SwFormatChain& rChain = rFlyFormat.GetChain();
831 return rChain.GetPrev() || rChain.GetNext();
835 void SwFramePage::setOptimalRelWidth()
837 static const RelationMaps aMaps[] = {
838 { aRelationMap, SAL_N_ELEMENTS(aRelationMap) },
839 { aAsCharRelationMap, SAL_N_ELEMENTS(aAsCharRelationMap) }
842 std::vector<SvxSwFramePosString::StringId> aRels;
843 for (const RelationMaps & rMap : aMaps)
845 for (size_t j = 0; j < rMap.nCount; ++j)
847 aRels.push_back(rMap.pMap[j].eStrId);
848 aRels.push_back(rMap.pMap[j].eMirrorStrId);
852 std::sort(aRels.begin(), aRels.end());
853 aRels.erase(std::unique(aRels.begin(), aRels.end()), aRels.end());
855 for (const auto& rRel : aRels)
857 m_xHoriRelationLB->append_text(SvxSwFramePosString::GetString(rRel));
860 Size aBiggest(m_xHoriRelationLB->get_preferred_size());
861 m_xHoriRelationLB->set_size_request(aBiggest.Width(), -1);
862 m_xVertRelationLB->set_size_request(aBiggest.Width(), -1);
863 m_xRelWidthRelationLB->set_size_request(aBiggest.Width(), -1);
864 m_xRelHeightRelationLB->set_size_request(aBiggest.Width(), -1);
865 m_xHoriRelationLB->clear();
868 std::unique_ptr<SfxTabPage> SwFramePage::Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet *rSet)
870 return std::make_unique<SwFramePage>(pPage, pController, *rSet);
873 void SwFramePage::EnableGraficMode()
875 // i#39692 - mustn't be called more than once
876 if (!m_xRealSizeBT->get_visible())
878 m_xWidthFT->show();
879 m_xWidthAutoFT->hide();
880 m_xAutoHeightCB->hide();
882 m_xHeightFT->show();
883 m_xHeightAutoFT->hide();
884 m_xAutoWidthCB->hide();
886 m_xRealSizeBT->show();
890 SwWrtShell *SwFramePage::getFrameDlgParentShell()
892 return static_cast<SwFrameDlg*>(GetDialogController())->GetWrtShell();
895 void SwFramePage::Reset( const SfxItemSet *rSet )
897 SwWrtShell* pSh = m_bFormat ? ::GetActiveWrtShell() :
898 getFrameDlgParentShell();
899 OSL_ENSURE(pSh , "shell not found");
900 if (!pSh)
901 return;
903 m_nHtmlMode = ::GetHtmlMode(pSh->GetView().GetDocShell());
904 m_bHtmlMode = (m_nHtmlMode & HTMLMODE_ON) != 0;
906 FieldUnit aMetric = ::GetDfltMetric(m_bHtmlMode);
907 m_xWidthED->SetMetric(aMetric);
908 m_xHeightED->SetMetric(aMetric);
909 ::SetFieldUnit(*m_xAtHorzPosED, aMetric);
910 ::SetFieldUnit(*m_xAtVertPosED, aMetric);
912 const SwFormatAnchor& rAnchor = rSet->Get(RES_ANCHOR);
914 if (const SfxBoolItem* pMathItem = rSet->GetItemIfSet(FN_OLE_IS_MATH, false))
915 m_bIsMathOLE = pMathItem->GetValue();
916 if (const SfxBoolItem* pAlignItem = rSet->GetItemIfSet(FN_MATH_BASELINE_ALIGNMENT, false))
917 m_bIsMathBaselineAlignment = pAlignItem->GetValue();
918 EnableVerticalPositioning( !(m_bIsMathOLE && m_bIsMathBaselineAlignment
919 && RndStdIds::FLY_AS_CHAR == rAnchor.GetAnchorId()) );
921 if (m_bFormat)
923 // at formats no to-fly anchor
924 m_xAnchorAtFrameRB->set_sensitive(false);
925 if (rSet->GetItemState(FN_KEEP_ASPECT_RATIO) != SfxItemState::SET)
927 m_xFixedRatioCB->set_sensitive(false);
930 else
932 if (rAnchor.GetAnchorId() != RndStdIds::FLY_AT_FLY && !pSh->IsFlyInFly())
933 m_xAnchorAtFrameRB->hide();
934 if ( pSh->IsFrameVertical( true, m_bIsInRightToLeft, m_bIsVerticalL2R ) )
936 OUString sHLabel = m_xHorizontalFT->get_label();
937 m_xHorizontalFT->set_label(m_xVerticalFT->get_label());
938 m_xVerticalFT->set_label(sHLabel);
939 m_bIsVerticalFrame = true;
943 if ( m_sDlgType == "PictureDialog" || m_sDlgType == "ObjectDialog" )
945 pSh->GetGrfSize( m_aGrfSize );
947 if ( !m_bNew )
949 m_xRealSizeBT->connect_clicked(LINK(this, SwFramePage, RealSizeHdl));
950 EnableGraficMode();
953 if (m_sDlgType == "PictureDialog")
954 m_xFixedRatioCB->set_active(false);
955 else
957 if ( m_bNew )
958 SetPageTitle(SwResId(STR_FRMUI_OLE_INSERT));
959 else
960 SetPageTitle(SwResId(STR_FRMUI_OLE_EDIT));
963 else
965 m_aGrfSize = rSet->Get(RES_FRM_SIZE).GetSize();
968 // entering percent value made possible
970 // the available space is not yet known so the RefValue has to be calculated from size and relative size values
971 // this is needed only if relative values are already set
972 const SwFormatFrameSize& rFrameSize = rSet->Get(RES_FRM_SIZE);
974 m_xRelWidthRelationLB->append_text(SvxSwFramePosString::GetString(SwFPos::FRAME));
975 m_xRelWidthRelationLB->append_text(SvxSwFramePosString::GetString(SwFPos::REL_PG_FRAME));
976 if (rFrameSize.GetWidthPercent() != SwFormatFrameSize::SYNCED && rFrameSize.GetWidthPercent() != 0)
978 //calculate the reference value from the width and relative width values
979 sal_Int32 nSpace = rFrameSize.GetWidth() * 100 / rFrameSize.GetWidthPercent();
980 m_xWidthED->SetRefValue( nSpace );
982 m_xRelWidthRelationLB->set_sensitive(true);
984 else
985 m_xRelWidthRelationLB->set_sensitive(false);
987 m_xRelHeightRelationLB->append_text(SvxSwFramePosString::GetString(SwFPos::FRAME));
988 m_xRelHeightRelationLB->append_text(SvxSwFramePosString::GetString(SwFPos::REL_PG_FRAME));
989 if (rFrameSize.GetHeightPercent() != SwFormatFrameSize::SYNCED && rFrameSize.GetHeightPercent() != 0)
991 //calculate the reference value from the with and relative width values
992 sal_Int32 nSpace = rFrameSize.GetHeight() * 100 / rFrameSize.GetHeightPercent();
993 m_xHeightED->SetRefValue( nSpace );
995 m_xRelHeightRelationLB->set_sensitive(true);
997 else
998 m_xRelHeightRelationLB->set_sensitive(false);
1000 // general initialisation part
1001 switch(rAnchor.GetAnchorId())
1003 case RndStdIds::FLY_AT_PAGE: m_xAnchorAtPageRB->set_active(true); break;
1004 case RndStdIds::FLY_AT_PARA: m_xAnchorAtParaRB->set_active(true); break;
1005 case RndStdIds::FLY_AT_CHAR: m_xAnchorAtCharRB->set_active(true); break;
1006 case RndStdIds::FLY_AS_CHAR: m_xAnchorAsCharRB->set_active(true); break;
1007 case RndStdIds::FLY_AT_FLY: m_xAnchorAtFrameRB->set_active(true);break;
1008 default:; //prevent warning
1011 // i#22341 - determine content position of character
1012 // Note: content position can be NULL
1013 mpToCharContentPos = rAnchor.GetAnchorNode() ? &rAnchor : nullptr;
1015 // i#18732 - init checkbox value
1017 const bool bFollowTextFlow =
1018 rSet->Get(RES_FOLLOW_TEXT_FLOW).GetValue();
1019 m_xFollowTextFlowCB->set_active(bFollowTextFlow);
1022 const bool bFlySplit = rSet->Get(RES_FLY_SPLIT).GetValue();
1023 m_xFlySplitCB->set_active(bFlySplit);
1026 if(m_bHtmlMode)
1028 m_xAutoHeightCB->set_sensitive(false);
1029 m_xAutoWidthCB->set_sensitive(false);
1030 m_xMirrorPagesCB->hide();
1031 if (m_sDlgType == "FrameDialog")
1032 m_xFixedRatioCB->set_sensitive(false);
1033 // i#18732 hide checkbox in HTML mode
1034 m_xFollowTextFlowCB->hide();
1036 else
1038 // enable/disable of check box 'Mirror on..'
1039 m_xMirrorPagesCB->set_sensitive(!m_xAnchorAsCharRB->get_active());
1041 // enable/disable check box 'Follow text flow'.
1042 // enable check box 'Follow text
1043 // flow' also for anchor type to-frame.
1044 m_xFollowTextFlowCB->set_sensitive(m_xAnchorAtParaRB->get_active() ||
1045 m_xAnchorAtCharRB->get_active() ||
1046 m_xAnchorAtFrameRB->get_active());
1047 m_xFlySplitCB->set_sensitive(m_xAnchorAtParaRB->get_active());
1050 const SwFrameFormat* pFlyFormat = pSh->GetFlyFrameFormat();
1051 if (!pFlyFormat || !ContainsSingleTable(*pFlyFormat) || ContainsChain(*pFlyFormat))
1053 // Only allow fly split if the frame contains a single table, otherwise it would be hard to
1054 // save the resulting model to Word formats.
1055 m_xFlySplitCB->hide();
1058 Init(*rSet);
1059 m_xAtVertPosED->save_value();
1060 m_xAtHorzPosED->save_value();
1061 m_xFollowTextFlowCB->save_state();
1062 m_xFlySplitCB->save_state();
1064 m_xWidthED->save_value();
1065 m_xHeightED->save_value();
1067 m_bNoModifyHdl = false;
1068 //lock PercentFields
1069 m_xWidthED->LockAutoCalculation(true);
1070 m_xHeightED->LockAutoCalculation(true);
1071 RangeModifyHdl(); // set all maximum values initially
1072 m_xHeightED->LockAutoCalculation(false);
1073 m_xWidthED->LockAutoCalculation(false);
1075 m_xAutoHeightCB->save_state();
1076 m_xAutoWidthCB->save_state();
1078 SwTwips nWidth = static_cast< SwTwips >(m_xWidthED->DenormalizePercent(m_xWidthED->get_value(FieldUnit::TWIP)));
1079 SwTwips nHeight = static_cast< SwTwips >(m_xHeightED->DenormalizePercent(m_xHeightED->get_value(FieldUnit::TWIP)));
1080 m_fWidthHeightRatio = nHeight ? double(nWidth) / double(nHeight) : 1.0;
1083 // stuff attributes into the set when OK
1084 bool SwFramePage::FillItemSet(SfxItemSet *rSet)
1086 bool bRet = false;
1088 const SfxItemSet& rOldSet = GetItemSet();
1089 const SfxPoolItem* pOldItem = nullptr;
1091 RndStdIds eAnchorId = GetAnchor();
1093 if ( !m_bFormat || eAnchorId != RndStdIds::FLY_AT_FLY )
1095 pOldItem = GetOldItem(*rSet, RES_ANCHOR);
1096 if (m_bNew || !pOldItem || eAnchorId != static_cast<const SwFormatAnchor*>(pOldItem)->GetAnchorId())
1098 SwWrtShell* pSh = m_bFormat ? ::GetActiveWrtShell()
1099 : getFrameDlgParentShell();
1100 OSL_ENSURE( pSh , "shell not found");
1101 if (pSh)
1103 SwFormatAnchor aAnc( eAnchorId, eAnchorId == RndStdIds::FLY_AT_PAGE ? pSh->GetPhyPageNum() : 0 );
1104 bRet = nullptr != rSet->Put( aAnc );
1109 if ( m_pHMap )
1111 SwFormatHoriOrient aHoriOrient( rOldSet.Get(RES_HORI_ORIENT) );
1113 const sal_Int32 nMapPos = GetMapPos(m_pHMap, *m_xHorizontalDLB);
1114 const sal_Int16 eHOri = GetAlignment(m_pHMap, nMapPos, *m_xHoriRelationLB);
1115 const sal_Int16 eRel = GetRelation(*m_xHoriRelationLB);
1117 aHoriOrient.SetHoriOrient( eHOri );
1118 aHoriOrient.SetRelationOrient( eRel );
1119 aHoriOrient.SetPosToggle(m_xMirrorPagesCB->get_active());
1121 bool bMod = m_xAtHorzPosED->get_value_changed_from_saved();
1122 bMod |= m_xMirrorPagesCB->get_state_changed_from_saved();
1124 if ( eHOri == text::HoriOrientation::NONE &&
1125 (m_bNew || (m_bAtHorzPosModified || bMod) || m_nOldH != eHOri ) )
1127 SwTwips nX = static_cast< SwTwips >(m_xAtHorzPosED->denormalize(m_xAtHorzPosED->get_value(FieldUnit::TWIP)));
1128 aHoriOrient.SetPos( nX );
1131 pOldItem = GetOldItem(*rSet, FN_HORI_ORIENT);
1132 bool bSame = false;
1133 if ((m_bNew == m_bFormat) && pOldItem)
1135 bSame = aHoriOrient == static_cast<const SwFormatHoriOrient&>(*pOldItem);
1137 if ((m_bNew && !m_bFormat) || ((m_bAtHorzPosModified || bMod) && !bSame))
1139 bRet |= nullptr != rSet->Put( aHoriOrient );
1143 if ( m_pVMap )
1145 // alignment vertical
1146 SwFormatVertOrient aVertOrient( rOldSet.Get(RES_VERT_ORIENT) );
1148 const sal_Int32 nMapPos = GetMapPos(m_pVMap, *m_xVerticalDLB);
1149 const sal_Int16 eVOri = GetAlignment(m_pVMap, nMapPos, *m_xVertRelationLB);
1150 const sal_Int16 eRel = GetRelation(*m_xVertRelationLB);
1152 aVertOrient.SetVertOrient ( eVOri);
1153 aVertOrient.SetRelationOrient( eRel );
1155 bool bMod = m_xAtVertPosED->get_value_changed_from_saved();
1157 if ( eVOri == text::VertOrientation::NONE &&
1158 ( m_bNew || (m_bAtVertPosModified || bMod) || m_nOldV != eVOri) )
1160 // vertical position
1161 // recalculate offset for character bound frames
1162 SwTwips nY = static_cast< SwTwips >(m_xAtVertPosED->denormalize(m_xAtVertPosED->get_value(FieldUnit::TWIP)));
1163 if (eAnchorId == RndStdIds::FLY_AS_CHAR)
1165 nY *= -1;
1167 aVertOrient.SetPos( nY );
1169 pOldItem = GetOldItem(*rSet, FN_VERT_ORIENT);
1170 bool bSame = false;
1171 if((m_bNew == m_bFormat) && pOldItem)
1173 bSame = m_bFormat ?
1174 aVertOrient.GetVertOrient() == static_cast<const SwFormatVertOrient*>(pOldItem)->GetVertOrient() &&
1175 aVertOrient.GetRelationOrient() == static_cast<const SwFormatVertOrient*>(pOldItem)->GetRelationOrient() &&
1176 aVertOrient.GetPos() == static_cast<const SwFormatVertOrient*>(pOldItem)->GetPos()
1177 : aVertOrient == static_cast<const SwFormatVertOrient&>(*pOldItem);
1179 if( ( m_bNew && !m_bFormat ) || ((m_bAtVertPosModified || bMod) && !bSame ))
1181 bRet |= nullptr != rSet->Put( aVertOrient );
1185 // set size
1186 // new exception: when the size of pMgr(, 0), then the properties
1187 // for a graphic that isn't even loaded, are set. Then no SetSize
1188 // is done here when the size settings were not changed by the
1189 // user.
1190 const SwFormatFrameSize& rOldSize = rOldSet.Get(RES_FRM_SIZE);
1191 SwFormatFrameSize aSz( rOldSize );
1193 auto nRelWidthRelation = m_xRelWidthRelationLB->get_active();
1194 if (nRelWidthRelation != -1)
1196 if (nRelWidthRelation == 0)
1197 aSz.SetWidthPercentRelation(text::RelOrientation::FRAME);
1198 else if (nRelWidthRelation == 1)
1199 aSz.SetWidthPercentRelation(text::RelOrientation::PAGE_FRAME);
1201 auto nRelHeightRelation = m_xRelHeightRelationLB->get_active();
1202 if (nRelHeightRelation != -1)
1204 if (nRelHeightRelation == 0)
1205 aSz.SetHeightPercentRelation(text::RelOrientation::FRAME);
1206 else if (nRelHeightRelation == 1)
1207 aSz.SetHeightPercentRelation(text::RelOrientation::PAGE_FRAME);
1210 bool bValueModified = m_xWidthED->get_value_changed_from_saved() ||
1211 m_xHeightED->get_value_changed_from_saved();
1212 bool bCheckChanged = m_xRelWidthCB->get_state_changed_from_saved() ||
1213 m_xRelHeightCB->get_state_changed_from_saved() ||
1214 m_xFixedRatioCB->get_state_changed_from_saved();
1216 bool bLegalValue = !(!rOldSize.GetWidth () && !rOldSize.GetHeight() &&
1217 m_xWidthED->get_value() == m_xWidthED->get_min() &&
1218 m_xHeightED->get_value() == m_xHeightED->get_min());
1220 if ((m_bNew && !m_bFormat) || ((bValueModified || bCheckChanged) && bLegalValue))
1222 sal_Int64 nNewWidth = m_xWidthED->DenormalizePercent(m_xWidthED->GetRealValue(FieldUnit::TWIP));
1223 sal_Int64 nNewHeight = m_xHeightED->DenormalizePercent(m_xHeightED->GetRealValue(FieldUnit::TWIP));
1224 aSz.SetWidth (static_cast< SwTwips >(nNewWidth));
1225 aSz.SetHeight(static_cast< SwTwips >(nNewHeight));
1227 if (m_xRelWidthCB->get_active())
1229 aSz.SetWidthPercent(static_cast<sal_uInt8>(std::min(MAX_PERCENT_WIDTH, m_xWidthED->Convert(m_xWidthED->NormalizePercent(nNewWidth), FieldUnit::TWIP, FieldUnit::PERCENT))));
1231 else
1232 aSz.SetWidthPercent(0);
1233 if (m_xRelHeightCB->get_active())
1234 aSz.SetHeightPercent(static_cast<sal_uInt8>(std::min(MAX_PERCENT_HEIGHT, m_xHeightED->Convert(m_xHeightED->NormalizePercent(nNewHeight), FieldUnit::TWIP, FieldUnit::PERCENT))));
1235 else
1236 aSz.SetHeightPercent(0);
1238 if (m_xFixedRatioCB->get_active() && (m_xRelWidthCB->get_active() != m_xRelHeightCB->get_active()))
1240 if (m_xRelWidthCB->get_active())
1241 aSz.SetHeightPercent(SwFormatFrameSize::SYNCED);
1242 else
1243 aSz.SetWidthPercent(SwFormatFrameSize::SYNCED);
1247 if( !IsInGraficMode() )
1249 if (m_xAutoHeightCB->get_state_changed_from_saved())
1251 SwFrameSize eFrameSize = m_xAutoHeightCB->get_active()? SwFrameSize::Minimum : SwFrameSize::Fixed;
1252 if( eFrameSize != aSz.GetHeightSizeType() )
1253 aSz.SetHeightSizeType(eFrameSize);
1255 if (m_xAutoWidthCB->get_state_changed_from_saved())
1257 SwFrameSize eFrameSize = m_xAutoWidthCB->get_active()? SwFrameSize::Minimum : SwFrameSize::Fixed;
1258 if( eFrameSize != aSz.GetWidthSizeType() )
1259 aSz.SetWidthSizeType( eFrameSize );
1262 if (m_xFixedRatioCB->get_state_changed_from_saved())
1263 bRet |= nullptr != rSet->Put(SfxBoolItem(FN_KEEP_ASPECT_RATIO, m_xFixedRatioCB->get_active()));
1265 pOldItem = GetOldItem(*rSet, RES_FRM_SIZE);
1267 if ((pOldItem && aSz != *pOldItem) || (!pOldItem && !m_bFormat) ||
1268 (m_bFormat &&
1269 (aSz.GetWidth() > 0 || aSz.GetWidthPercent() > 0) &&
1270 (aSz.GetHeight() > 0 || aSz.GetHeightPercent() > 0)))
1272 if (aSz.GetHeightSizeType() == SwFrameSize::Variable) // there is no VAR_SIZE in frames
1273 aSz.SetHeightSizeType(SwFrameSize::Minimum);
1275 bRet |= nullptr != rSet->Put( aSz );
1277 if (m_xFollowTextFlowCB->get_state_changed_from_saved())
1279 bRet |= nullptr != rSet->Put(SwFormatFollowTextFlow(m_xFollowTextFlowCB->get_active()));
1281 if (m_xFlySplitCB->get_state_changed_from_saved())
1283 bRet |= rSet->Put(SwFormatFlySplit(m_xFlySplitCB->get_active())) != nullptr;
1285 return bRet;
1288 // initialise horizontal and vertical Pos
1289 void SwFramePage::InitPos(RndStdIds eId,
1290 sal_Int16 nH,
1291 sal_Int16 nHRel,
1292 sal_Int16 nV,
1293 sal_Int16 nVRel,
1294 tools::Long nX,
1295 tools::Long nY)
1297 auto nPos = m_xVerticalDLB->get_active();
1298 if (nPos != -1 && m_pVMap)
1300 m_nOldV = m_pVMap[nPos].nAlign;
1302 nPos = m_xVertRelationLB->get_active();
1303 if (nPos != -1)
1304 m_nOldVRel = weld::fromId<RelationMap*>(m_xVertRelationLB->get_id(nPos))->nRelation;
1307 nPos = m_xHorizontalDLB->get_active();
1308 if (nPos != -1 && m_pHMap)
1310 m_nOldH = m_pHMap[nPos].nAlign;
1312 nPos = m_xHoriRelationLB->get_active();
1313 if (nPos != -1)
1314 m_nOldHRel = weld::fromId<RelationMap*>(m_xHoriRelationLB->get_id(nPos))->nRelation;
1317 bool bEnable = true;
1318 if ( eId == RndStdIds::FLY_AT_PAGE )
1320 m_pVMap = m_bHtmlMode ? aVPageHtmlMap : aVPageMap;
1321 m_pHMap = m_bHtmlMode ? aHPageHtmlMap : aHPageMap;
1323 else if ( eId == RndStdIds::FLY_AT_FLY )
1325 // own vertical alignment map for to frame
1326 // anchored objects.
1327 m_pVMap = m_bHtmlMode ? aVFlyHtmlMap : aVFrameMap;
1328 m_pHMap = m_bHtmlMode ? aHFlyHtmlMap : aHFrameMap;
1330 else if ( eId == RndStdIds::FLY_AT_PARA )
1332 if(m_bHtmlMode)
1334 m_pVMap = aVParaHtmlMap;
1335 m_pHMap = aHParaHtmlAbsMap;
1337 else
1339 m_pVMap = aVParaMap;
1340 m_pHMap = aHParaMap;
1343 else if ( eId == RndStdIds::FLY_AT_CHAR )
1345 if(m_bHtmlMode)
1347 m_pVMap = aVCharHtmlAbsMap;
1348 m_pHMap = aHCharHtmlAbsMap;
1350 else
1352 m_pVMap = aVCharMap;
1353 m_pHMap = aHCharMap;
1356 else if ( eId == RndStdIds::FLY_AS_CHAR )
1358 m_pVMap = m_bHtmlMode ? aVAsCharHtmlMap : aVAsCharMap;
1359 m_pHMap = nullptr;
1360 bEnable = false;
1362 m_xHorizontalDLB->set_sensitive( bEnable );
1363 m_xHorizontalFT->set_sensitive( bEnable );
1365 // select current Pos
1366 // horizontal
1367 if ( nH < 0 )
1369 nH = m_nOldH;
1370 nHRel = m_nOldHRel;
1372 sal_Int32 nMapPos = FillPosLB(m_pHMap, nH, nHRel, *m_xHorizontalDLB);
1373 FillRelLB(m_pHMap, nMapPos, nH, nHRel, *m_xHoriRelationLB, *m_xHoriRelationFT);
1375 // vertical
1376 if ( nV < 0 )
1378 nV = m_nOldV;
1379 nVRel = m_nOldVRel;
1381 nMapPos = FillPosLB(m_pVMap, nV, nVRel, *m_xVerticalDLB);
1382 FillRelLB(m_pVMap, nMapPos, nV, nVRel, *m_xVertRelationLB, *m_xVertRelationFT);
1384 bEnable = nH == text::HoriOrientation::NONE && eId != RndStdIds::FLY_AS_CHAR;
1385 if (!bEnable)
1386 m_xAtHorzPosED->set_value(0, FieldUnit::TWIP);
1387 else
1389 if (nX != LONG_MAX)
1390 m_xAtHorzPosED->set_value(m_xAtHorzPosED->normalize(nX), FieldUnit::TWIP);
1392 m_xAtHorzPosFT->set_sensitive( bEnable );
1393 m_xAtHorzPosED->set_sensitive( bEnable );
1395 bEnable = nV == text::VertOrientation::NONE;
1396 if ( !bEnable )
1397 m_xAtVertPosED->set_value(0, FieldUnit::TWIP);
1398 else
1400 if (eId == RndStdIds::FLY_AS_CHAR)
1402 if ( nY == LONG_MAX )
1403 nY = 0;
1404 else
1405 nY *= -1;
1407 if ( nY != LONG_MAX )
1408 m_xAtVertPosED->set_value(m_xAtVertPosED->normalize(nY), FieldUnit::TWIP);
1410 m_xAtVertPosFT->set_sensitive( bEnable && m_bAllowVertPositioning );
1411 m_xAtVertPosED->set_sensitive( bEnable && m_bAllowVertPositioning );
1412 UpdateExample();
1415 sal_Int32 SwFramePage::FillPosLB(const FrameMap* _pMap,
1416 const sal_Int16 _nAlign,
1417 const sal_Int16 _nRel,
1418 weld::ComboBox& _rLB )
1420 OUString sSelEntry;
1421 const OUString sOldEntry = _rLB.get_active_text();
1423 _rLB.clear();
1425 // i#22341 determine all possible listbox relations for
1426 // given relation for map <aVCharMap>
1427 const LB nLBRelations = (_pMap != aVCharMap)
1428 ? LB::NONE
1429 : ::lcl_GetLBRelationsForRelations( _nRel );
1431 // fill Listbox
1432 size_t nCount = ::lcl_GetFrameMapCount(_pMap);
1433 for (size_t i = 0; _pMap && i < nCount; ++i)
1435 // Why not from the left/from inside or from above?
1436 SvxSwFramePosString::StringId eStrId = m_xMirrorPagesCB->get_active() ? _pMap[i].eMirrorStrId : _pMap[i].eStrId;
1437 // --> OD 2009-08-31 #mongolianlayout#
1438 eStrId = lcl_ChangeResIdToVerticalOrRTL( eStrId,
1439 m_bIsVerticalFrame,
1440 m_bIsVerticalL2R,
1441 m_bIsInRightToLeft);
1442 OUString sEntry(SvxSwFramePosString::GetString(eStrId));
1443 if (_rLB.find_text(sEntry) == -1)
1445 // don't insert entries when frames are character bound
1446 _rLB.append_text(sEntry);
1448 // i#22341 - add condition to handle map <aVCharMap>
1449 // that is ambiguous in the alignment.
1450 if ( _pMap[i].nAlign == _nAlign &&
1451 ( (_pMap != aVCharMap) || _pMap[i].nLBRelations & nLBRelations ) )
1453 sSelEntry = sEntry;
1457 _rLB.set_active_text(sSelEntry);
1458 if (_rLB.get_active() == -1)
1459 _rLB.set_active_text(sOldEntry);
1461 if (_rLB.get_active() == -1 && _rLB.get_count())
1462 _rLB.set_active(0);
1464 PosHdl(_rLB);
1466 return GetMapPos(_pMap, _rLB);
1469 void SwFramePage::FillRelLB(const FrameMap* _pMap,
1470 const sal_uInt16 _nLBSelPos,
1471 const sal_Int16 _nAlign,
1472 const sal_Int16 _nRel,
1473 weld::ComboBox& _rLB,
1474 weld::Label& _rFT)
1476 OUString sSelEntry;
1477 LB nLBRelations = LB::NONE;
1478 size_t nMapCount = ::lcl_GetFrameMapCount(_pMap);
1480 _rLB.clear();
1482 if (_nLBSelPos < nMapCount)
1484 if (_pMap == aVAsCharHtmlMap || _pMap == aVAsCharMap)
1486 const OUString sOldEntry(_rLB.get_active_text());
1487 SvxSwFramePosString::StringId eStrId = _pMap[_nLBSelPos].eStrId;
1489 for (size_t nMapPos = 0; nMapPos < nMapCount; nMapPos++)
1491 if (_pMap[nMapPos].eStrId == eStrId)
1493 nLBRelations = _pMap[nMapPos].nLBRelations;
1494 for (RelationMap const & rCharMap : aAsCharRelationMap)
1496 if (nLBRelations & rCharMap.nLBRelation)
1498 // --> OD 2009-08-31 #mongolianlayout#
1499 SvxSwFramePosString::StringId sStrId1 =
1500 lcl_ChangeResIdToVerticalOrRTL( rCharMap.eStrId,
1501 m_bIsVerticalFrame,
1502 m_bIsVerticalL2R,
1503 m_bIsInRightToLeft);
1504 const OUString sEntry = SvxSwFramePosString::GetString(sStrId1);
1505 _rLB.append(weld::toId(&rCharMap), sEntry);
1506 if (_pMap[nMapPos].nAlign == _nAlign)
1507 sSelEntry = sEntry;
1508 break;
1513 if (!sSelEntry.isEmpty())
1514 _rLB.set_active_text(sSelEntry);
1515 else
1517 _rLB.set_active_text(sOldEntry);
1519 if (_rLB.get_active() == -1)
1521 for (int i = 0; i < _rLB.get_count(); i++)
1523 RelationMap *pEntry = weld::fromId<RelationMap*>(_rLB.get_id(i));
1524 if (pEntry->nLBRelation == LB::RelChar) // default
1526 _rLB.set_active(i);
1527 break;
1533 else
1535 // special handling for map <aVCharMap>,
1536 // because its ambiguous in its <eStrId>/<eMirrorStrId>.
1537 if ( _pMap == aVCharMap )
1539 nLBRelations = ::lcl_GetLBRelationsForStrID( _pMap,
1540 ( m_xMirrorPagesCB->get_active()
1541 ? _pMap[_nLBSelPos].eMirrorStrId
1542 : _pMap[_nLBSelPos].eStrId),
1543 m_xMirrorPagesCB->get_active() );
1545 else
1547 nLBRelations = _pMap[_nLBSelPos].nLBRelations;
1550 for (sal_uLong nBit = 1; nBit < 0x80000000; nBit <<= 1)
1552 if (nLBRelations & static_cast<LB>(nBit))
1554 for (RelationMap const & rMap : aRelationMap)
1556 if (rMap.nLBRelation == static_cast<LB>(nBit))
1558 SvxSwFramePosString::StringId eStrId1 = m_xMirrorPagesCB->get_active() ?
1559 rMap.eMirrorStrId : rMap.eStrId;
1560 // --> OD 2009-08-31 #mongolianlayout#
1561 eStrId1 =
1562 lcl_ChangeResIdToVerticalOrRTL( eStrId1,
1563 m_bIsVerticalFrame,
1564 m_bIsVerticalL2R,
1565 m_bIsInRightToLeft);
1566 const OUString sEntry = SvxSwFramePosString::GetString(eStrId1);
1567 _rLB.append(weld::toId(&rMap), sEntry);
1568 if (sSelEntry.isEmpty() && rMap.nRelation == _nRel)
1569 sSelEntry = sEntry;
1574 if (!sSelEntry.isEmpty())
1575 _rLB.set_active_text(sSelEntry);
1576 else
1578 // Probably anchor switch. So look for similar relation
1579 sal_Int16 nSimRel = -1;
1580 switch (_nRel)
1582 case text::RelOrientation::FRAME:
1583 nSimRel = text::RelOrientation::PAGE_FRAME;
1584 break;
1585 case text::RelOrientation::PRINT_AREA:
1586 nSimRel = text::RelOrientation::PAGE_PRINT_AREA;
1587 break;
1588 case text::RelOrientation::PAGE_LEFT:
1589 nSimRel = text::RelOrientation::FRAME_LEFT;
1590 break;
1591 case text::RelOrientation::PAGE_RIGHT:
1592 nSimRel = text::RelOrientation::FRAME_RIGHT;
1593 break;
1594 case text::RelOrientation::FRAME_LEFT:
1595 nSimRel = text::RelOrientation::PAGE_LEFT;
1596 break;
1597 case text::RelOrientation::FRAME_RIGHT:
1598 nSimRel = text::RelOrientation::PAGE_RIGHT;
1599 break;
1600 case text::RelOrientation::PAGE_FRAME:
1601 nSimRel = text::RelOrientation::FRAME;
1602 break;
1603 case text::RelOrientation::PAGE_PRINT_AREA:
1604 nSimRel = text::RelOrientation::PRINT_AREA;
1605 break;
1607 default:
1608 if (_rLB.get_active() != -1)
1610 RelationMap *pEntry = weld::fromId<RelationMap*>(_rLB.get_id(_rLB.get_count() - 1));
1611 nSimRel = pEntry->nRelation;
1613 break;
1616 for (int i = 0; i < _rLB.get_count(); i++)
1618 RelationMap *pEntry = weld::fromId<RelationMap*>(_rLB.get_id(i));
1619 if (pEntry->nRelation == nSimRel)
1621 _rLB.set_active(i);
1622 break;
1626 if (_rLB.get_active() == -1)
1627 _rLB.set_active(0);
1632 const bool bEnable = _rLB.get_count() != 0
1633 && (&_rLB != m_xVertRelationLB.get() || m_bAllowVertPositioning);
1634 _rLB.set_sensitive( bEnable );
1635 _rFT.set_sensitive( bEnable );
1637 RelHdl(_rLB);
1640 sal_Int16 SwFramePage::GetRelation(const weld::ComboBox& rRelationLB)
1642 const auto nPos = rRelationLB.get_active();
1643 if (nPos != -1)
1645 RelationMap *pEntry = weld::fromId<RelationMap *>(rRelationLB.get_id(nPos));
1646 return pEntry->nRelation;
1649 return 0;
1652 sal_Int16 SwFramePage::GetAlignment(FrameMap const *pMap, sal_Int32 nMapPos,
1653 const weld::ComboBox& rRelationLB)
1655 if (!pMap || nMapPos < 0)
1656 return 0;
1658 const size_t nMapCount = ::lcl_GetFrameMapCount(pMap);
1660 if (o3tl::make_unsigned(nMapPos) >= nMapCount)
1661 return 0;
1663 // i#22341 special handling also for map <aVCharMap>,
1664 // because it contains ambiguous items for alignment
1665 if ( pMap != aVAsCharHtmlMap && pMap != aVAsCharMap && pMap != aVCharMap )
1666 return pMap[nMapPos].nAlign;
1668 if (rRelationLB.get_active() == -1)
1669 return 0;
1671 const RelationMap *const pRelationMap = weld::fromId<const RelationMap*>(
1672 rRelationLB.get_active_id());
1673 const LB nRel = pRelationMap->nLBRelation;
1674 const SvxSwFramePosString::StringId eStrId = pMap[nMapPos].eStrId;
1676 for (size_t i = 0; i < nMapCount; ++i)
1678 if (pMap[i].eStrId == eStrId && (pMap[i].nLBRelations & nRel))
1679 return pMap[i].nAlign;
1682 return 0;
1685 sal_Int32 SwFramePage::GetMapPos(const FrameMap *pMap, const weld::ComboBox& rAlignLB)
1687 sal_Int32 nMapPos = 0;
1688 auto nLBSelPos = rAlignLB.get_active();
1690 if (nLBSelPos != -1)
1692 if (pMap == aVAsCharHtmlMap || pMap == aVAsCharMap)
1694 const size_t nMapCount = ::lcl_GetFrameMapCount(pMap);
1695 const OUString sSelEntry(rAlignLB.get_active_text());
1697 for (size_t i = 0; i < nMapCount; i++)
1699 SvxSwFramePosString::StringId eResId = pMap[i].eStrId;
1701 OUString sEntry = SvxSwFramePosString::GetString(eResId);
1702 sEntry = MnemonicGenerator::EraseAllMnemonicChars( sEntry );
1704 if (sEntry == sSelEntry)
1706 nMapPos = static_cast< sal_Int32 >(i);
1707 break;
1711 else
1712 nMapPos = nLBSelPos;
1715 return nMapPos;
1718 RndStdIds SwFramePage::GetAnchor() const
1720 RndStdIds nRet = RndStdIds::FLY_AT_PAGE;
1721 if (m_xAnchorAtParaRB->get_active())
1723 nRet = RndStdIds::FLY_AT_PARA;
1725 else if (m_xAnchorAtCharRB->get_active())
1727 nRet = RndStdIds::FLY_AT_CHAR;
1729 else if (m_xAnchorAsCharRB->get_active())
1731 nRet = RndStdIds::FLY_AS_CHAR;
1733 else if (m_xAnchorAtFrameRB->get_active())
1735 nRet = RndStdIds::FLY_AT_FLY;
1737 return nRet;
1740 // Bsp - Update
1741 void SwFramePage::ActivatePage(const SfxItemSet& rSet)
1743 m_bNoModifyHdl = true;
1744 Init(rSet);
1745 m_bNoModifyHdl = false;
1746 //lock PercentFields
1747 m_xWidthED->LockAutoCalculation(true);
1748 m_xHeightED->LockAutoCalculation(true);
1749 RangeModifyHdl(); // set all maximum values initially
1750 m_xHeightED->LockAutoCalculation(false);
1751 m_xWidthED->LockAutoCalculation(false);
1752 m_xFollowTextFlowCB->save_state();
1753 m_xFlySplitCB->save_state();
1756 DeactivateRC SwFramePage::DeactivatePage(SfxItemSet * _pSet)
1758 if ( _pSet )
1760 FillItemSet( _pSet );
1762 if (!m_bFormat) // tdf#112574 no anchor in styles
1764 //FillItemSet doesn't set the anchor into the set when it matches
1765 //the original. But for the other pages we need the current anchor.
1766 SwWrtShell* pSh = m_bFormat ? ::GetActiveWrtShell()
1767 : getFrameDlgParentShell();
1768 if (pSh)
1770 RndStdIds eAnchorId = GetAnchor();
1771 SwFormatAnchor aAnc( eAnchorId, eAnchorId == RndStdIds::FLY_AT_PAGE ? pSh->GetPhyPageNum() : 0 );
1772 _pSet->Put( aAnc );
1777 return DeactivateRC::LeavePage;
1780 // swap left/right with inside/outside
1781 IMPL_LINK_NOARG(SwFramePage, MirrorHdl, weld::Toggleable&, void)
1783 RndStdIds eId = GetAnchor();
1784 InitPos(eId, -1, 0, -1, 0, LONG_MAX, LONG_MAX);
1787 IMPL_LINK( SwFramePage, RelSizeClickHdl, weld::Toggleable&, rBtn, void )
1789 if (&rBtn == m_xRelWidthCB.get())
1791 m_xWidthED->ShowPercent(rBtn.get_active());
1792 m_xRelWidthRelationLB->set_sensitive(rBtn.get_active());
1793 if (rBtn.get_active())
1794 m_xWidthED->get()->set_max(MAX_PERCENT_WIDTH, FieldUnit::NONE);
1796 else // rBtn == m_xRelHeightCB.get()
1798 m_xHeightED->ShowPercent(rBtn.get_active());
1799 m_xRelHeightRelationLB->set_sensitive(rBtn.get_active());
1800 if (rBtn.get_active())
1801 m_xHeightED->get()->set_max(MAX_PERCENT_HEIGHT, FieldUnit::NONE);
1804 RangeModifyHdl(); // correct the values again
1806 if (&rBtn == m_xRelWidthCB.get())
1807 ModifyHdl(*m_xWidthED->get());
1808 else // rBtn == m_xRelHeightCB.get()
1809 ModifyHdl(*m_xHeightED->get());
1812 // range check
1813 IMPL_LINK_NOARG(SwFramePage, RangeModifyClickHdl, weld::Toggleable&, void)
1815 RangeModifyHdl();
1818 void SwFramePage::RangeModifyHdl()
1820 if (m_bNoModifyHdl)
1821 return;
1823 SwWrtShell* pSh = m_bFormat ? ::GetActiveWrtShell()
1824 : getFrameDlgParentShell();
1825 OSL_ENSURE(pSh , "shell not found");
1826 if (!pSh)
1827 return;
1829 SwFlyFrameAttrMgr aMgr( m_bNew, pSh, GetItemSet() );
1830 SvxSwFrameValidation aVal;
1832 aVal.nAnchorType = GetAnchor();
1833 aVal.bAutoHeight = m_xAutoHeightCB->get_active();
1834 aVal.bMirror = m_xMirrorPagesCB->get_active();
1835 aVal.bFollowTextFlow = m_xFollowTextFlowCB->get_active();
1837 if ( m_pHMap )
1839 // alignment horizontal
1840 const sal_Int32 nMapPos = GetMapPos(m_pHMap, *m_xHorizontalDLB);
1841 aVal.nHoriOrient = GetAlignment(m_pHMap, nMapPos, *m_xHoriRelationLB);
1842 aVal.nHRelOrient = GetRelation(*m_xHoriRelationLB);
1844 else
1845 aVal.nHoriOrient = text::HoriOrientation::NONE;
1847 if ( m_pVMap )
1849 // alignment vertical
1850 const sal_Int32 nMapPos = GetMapPos(m_pVMap, *m_xVerticalDLB);
1851 aVal.nVertOrient = GetAlignment(m_pVMap, nMapPos, *m_xVertRelationLB);
1852 aVal.nVRelOrient = GetRelation(*m_xVertRelationLB);
1854 else
1855 aVal.nVertOrient = text::VertOrientation::NONE;
1857 const tools::Long nAtHorzPosVal = static_cast< tools::Long >(
1858 m_xAtHorzPosED->denormalize(m_xAtHorzPosED->get_value(FieldUnit::TWIP)) );
1859 const tools::Long nAtVertPosVal = static_cast< tools::Long >(
1860 m_xAtVertPosED->denormalize(m_xAtVertPosED->get_value(FieldUnit::TWIP)) );
1862 aVal.nHPos = nAtHorzPosVal;
1863 aVal.nVPos = nAtVertPosVal;
1865 aMgr.ValidateMetrics(aVal, mpToCharContentPos, true); // one time, to get reference values for percental values
1867 // set reference values for percental values (100%) ...
1868 m_xWidthED->SetRefValue(aVal.aPercentSize.Width());
1869 m_xHeightED->SetRefValue(aVal.aPercentSize.Height());
1871 // ... and correctly convert width and height with it
1872 SwTwips nWidth = static_cast< SwTwips >(m_xWidthED->DenormalizePercent(m_xWidthED->get_value(FieldUnit::TWIP)));
1873 SwTwips nHeight = static_cast< SwTwips >(m_xHeightED->DenormalizePercent(m_xHeightED->get_value(FieldUnit::TWIP)));
1874 aVal.nWidth = nWidth;
1875 aVal.nHeight = nHeight;
1877 aMgr.ValidateMetrics(aVal, mpToCharContentPos); // one more time, to determine all remaining values with correct width and height.
1879 // all columns have to be correct
1880 const SfxItemSet* pExampleSet = GetDialogExampleSet();
1881 if (pExampleSet && SfxItemState::DEFAULT <= pExampleSet->GetItemState(RES_COL))
1883 const SwFormatCol& rCol = pExampleSet->Get(RES_COL);
1884 if ( rCol.GetColumns().size() > 1 )
1886 for (const SwColumn & i : rCol.GetColumns())
1888 aVal.nMinWidth += i.GetLeft() +
1889 i.GetRight() +
1890 MINFLY;
1892 aVal.nMinWidth -= MINFLY;//one was already in there!
1896 nWidth = aVal.nWidth;
1897 nHeight = aVal.nHeight;
1899 // minimum range also for template
1900 m_xHeightED->set_min(m_xHeightED->NormalizePercent(aVal.nMinHeight), FieldUnit::TWIP);
1901 m_xWidthED->set_min(m_xWidthED->NormalizePercent(aVal.nMinWidth), FieldUnit::TWIP);
1903 SwTwips nMaxWidth(aVal.nMaxWidth);
1904 SwTwips nMaxHeight(aVal.nMaxHeight);
1906 if (aVal.bAutoHeight && (m_sDlgType == "PictureDialog" || m_sDlgType == "ObjectDialog"))
1908 SwTwips nTmp = std::min(nWidth * nMaxHeight / std::max(nHeight, SwTwips(1)), nMaxHeight);
1909 m_xWidthED->set_max(m_xWidthED->NormalizePercent(nTmp), FieldUnit::TWIP);
1911 nTmp = std::min(nHeight * nMaxWidth / std::max(nWidth, SwTwips(1)), nMaxWidth);
1912 m_xHeightED->set_max(m_xWidthED->NormalizePercent(nTmp), FieldUnit::TWIP);
1914 else
1916 SwTwips nTmp = static_cast< SwTwips >(m_xHeightED->NormalizePercent(nMaxHeight));
1917 m_xHeightED->set_max(nTmp, FieldUnit::TWIP);
1919 nTmp = static_cast< SwTwips >(m_xWidthED->NormalizePercent(nMaxWidth));
1920 m_xWidthED->set_max(nTmp, FieldUnit::TWIP);
1923 m_xAtHorzPosED->set_range(m_xAtHorzPosED->normalize(aVal.nMinHPos),
1924 m_xAtHorzPosED->normalize(aVal.nMaxHPos),
1925 FieldUnit::TWIP);
1926 if (aVal.nHPos != nAtHorzPosVal)
1927 m_xAtHorzPosED->set_value(m_xAtHorzPosED->normalize(aVal.nHPos), FieldUnit::TWIP);
1929 const SwTwips nUpperOffset = (aVal.nAnchorType == RndStdIds::FLY_AS_CHAR)
1930 ? m_nUpperBorder : 0;
1931 const SwTwips nLowerOffset = (aVal.nAnchorType == RndStdIds::FLY_AS_CHAR)
1932 ? m_nLowerBorder : 0;
1934 m_xAtVertPosED->set_range(m_xAtVertPosED->normalize(aVal.nMinVPos + nLowerOffset + nUpperOffset),
1935 m_xAtVertPosED->normalize(aVal.nMaxVPos),
1936 FieldUnit::TWIP);
1937 if (aVal.nVPos != nAtVertPosVal)
1938 m_xAtVertPosED->set_value(m_xAtVertPosED->normalize(aVal.nVPos), FieldUnit::TWIP);
1941 IMPL_LINK_NOARG(SwFramePage, AnchorTypeHdl, weld::Toggleable&, void)
1943 m_xMirrorPagesCB->set_sensitive(!m_xAnchorAsCharRB->get_active());
1945 // i#18732 - enable check box 'Follow text flow' for anchor
1946 // type to-paragraph' and to-character
1947 // i#22305 - enable check box 'Follow text
1948 // flow' also for anchor type to-frame.
1949 m_xFollowTextFlowCB->set_sensitive(m_xAnchorAtParaRB->get_active() ||
1950 m_xAnchorAtCharRB->get_active() ||
1951 m_xAnchorAtFrameRB->get_active());
1952 m_xFlySplitCB->set_sensitive(m_xAnchorAtParaRB->get_active());
1954 RndStdIds eId = GetAnchor();
1956 InitPos( eId, -1, 0, -1, 0, LONG_MAX, LONG_MAX);
1957 RangeModifyHdl();
1959 if(m_bHtmlMode)
1961 PosHdl(*m_xHorizontalDLB);
1962 PosHdl(*m_xVerticalDLB);
1965 EnableVerticalPositioning( !(m_bIsMathOLE && m_bIsMathBaselineAlignment
1966 && RndStdIds::FLY_AS_CHAR == eId) );
1969 IMPL_LINK( SwFramePage, PosHdl, weld::ComboBox&, rLB, void )
1971 bool bHori = &rLB == m_xHorizontalDLB.get();
1972 weld::ComboBox *pRelLB = bHori ? m_xHoriRelationLB.get() : m_xVertRelationLB.get();
1973 weld::Label *pRelFT = bHori ? m_xHoriRelationFT.get() : m_xVertRelationFT.get();
1974 FrameMap const *pMap = bHori ? m_pHMap : m_pVMap;
1976 const sal_Int32 nMapPos = GetMapPos(pMap, rLB);
1977 const sal_Int16 nAlign = GetAlignment(pMap, nMapPos, *pRelLB);
1979 if (bHori)
1981 bool bEnable = text::HoriOrientation::NONE == nAlign;
1982 m_xAtHorzPosED->set_sensitive( bEnable );
1983 m_xAtHorzPosFT->set_sensitive( bEnable );
1985 else
1987 bool bEnable = text::VertOrientation::NONE == nAlign && m_bAllowVertPositioning;
1988 m_xAtVertPosED->set_sensitive( bEnable );
1989 m_xAtVertPosFT->set_sensitive( bEnable );
1992 RangeModifyHdl();
1994 sal_Int16 nRel = 0;
1995 if (rLB.get_active() != -1)
1997 if (pRelLB->get_active() != -1)
1998 nRel = weld::fromId<RelationMap*>(pRelLB->get_active_id())->nRelation;
1999 FillRelLB(pMap, nMapPos, nAlign, nRel, *pRelLB, *pRelFT);
2001 else
2002 pRelLB->clear();
2004 UpdateExample();
2006 if (bHori)
2007 m_bAtHorzPosModified = true;
2008 else
2009 m_bAtVertPosModified = true;
2011 // special treatment for HTML-Mode with horizontal-vertical-dependencies
2012 if(!(m_bHtmlMode && (RndStdIds::FLY_AT_CHAR == GetAnchor())))
2013 return;
2015 bool bSet = false;
2016 if(bHori)
2018 // right is allowed only above - from the left only above
2019 // from the left at character -> below
2020 if((text::HoriOrientation::LEFT == nAlign || text::HoriOrientation::RIGHT == nAlign) &&
2021 0 == m_xVerticalDLB->get_active())
2023 if(text::RelOrientation::FRAME == nRel)
2024 m_xVerticalDLB->set_active(1);
2025 else
2026 m_xVerticalDLB->set_active(0);
2027 bSet = true;
2029 else if(text::HoriOrientation::LEFT == nAlign && 1 == m_xVerticalDLB->get_active())
2031 m_xVerticalDLB->set_active(0);
2032 bSet = true;
2034 else if(text::HoriOrientation::NONE == nAlign && 1 == m_xVerticalDLB->get_active())
2036 m_xVerticalDLB->set_active(0);
2037 bSet = true;
2039 if(bSet)
2040 PosHdl(*m_xVerticalDLB);
2042 else
2044 if(text::VertOrientation::TOP == nAlign)
2046 if (1 == m_xHorizontalDLB->get_active())
2048 m_xHorizontalDLB->set_active(0);
2049 bSet = true;
2051 m_xHoriRelationLB->set_active(1);
2053 else if(text::VertOrientation::CHAR_BOTTOM == nAlign)
2055 if (2 == m_xHorizontalDLB->get_active())
2057 m_xHorizontalDLB->set_active(0);
2058 bSet = true;
2060 m_xHoriRelationLB->set_active(0) ;
2062 if(bSet)
2063 PosHdl(*m_xHorizontalDLB);
2067 // horizontal Pos
2068 IMPL_LINK( SwFramePage, RelHdl, weld::ComboBox&, rLB, void )
2070 bool bHori = &rLB == m_xHoriRelationLB.get();
2072 UpdateExample();
2074 if (bHori)
2075 m_bAtHorzPosModified = true;
2076 else
2077 m_bAtVertPosModified = true;
2079 if (m_bHtmlMode && (RndStdIds::FLY_AT_CHAR == GetAnchor()))
2081 if(bHori)
2083 const sal_Int16 nRel = GetRelation(*m_xHoriRelationLB);
2084 if(text::RelOrientation::PRINT_AREA == nRel && 0 == m_xVerticalDLB->get_active())
2086 m_xVerticalDLB->set_active(1);
2088 else if(text::RelOrientation::CHAR == nRel && 1 == m_xVerticalDLB->get_active())
2090 m_xVerticalDLB->set_active(0);
2094 RangeModifyHdl();
2097 IMPL_LINK_NOARG(SwFramePage, RealSizeHdl, weld::Button&, void)
2099 m_xWidthED->set_value(m_xWidthED->NormalizePercent(m_aGrfSize.Width()), FieldUnit::TWIP);
2100 m_xHeightED->set_value(m_xHeightED->NormalizePercent(m_aGrfSize.Height()), FieldUnit::TWIP);
2101 m_fWidthHeightRatio = m_aGrfSize.Height() ? double(m_aGrfSize.Width()) / double(m_aGrfSize.Height()) : 1.0;
2102 UpdateExample();
2105 IMPL_LINK_NOARG(SwFramePage, AutoWidthClickHdl, weld::Toggleable&, void)
2107 if( !IsInGraficMode() )
2108 HandleAutoCB( m_xAutoWidthCB->get_active(), *m_xWidthFT, *m_xWidthAutoFT, *m_xWidthED->get() );
2111 IMPL_LINK_NOARG(SwFramePage, AutoHeightClickHdl, weld::Toggleable&, void)
2113 if (!IsInGraficMode())
2114 HandleAutoCB(m_xAutoHeightCB->get_active(), *m_xHeightFT, *m_xHeightAutoFT, *m_xWidthED->get());
2117 IMPL_LINK( SwFramePage, ModifyHdl, weld::MetricSpinButton&, rEdit, void )
2119 SwTwips nWidth = static_cast< SwTwips >(m_xWidthED->DenormalizePercent(m_xWidthED->get_value(FieldUnit::TWIP)));
2120 SwTwips nHeight = static_cast< SwTwips >(m_xHeightED->DenormalizePercent(m_xHeightED->get_value(FieldUnit::TWIP)));
2121 if (m_xFixedRatioCB->get_active())
2123 if (&rEdit == m_xWidthED->get())
2125 nHeight = SwTwips(static_cast<double>(nWidth) / m_fWidthHeightRatio);
2126 m_xHeightED->set_value(m_xHeightED->NormalizePercent(nHeight), FieldUnit::TWIP);
2128 else if (&rEdit == m_xHeightED->get())
2130 nWidth = SwTwips(static_cast<double>(nHeight) * m_fWidthHeightRatio);
2131 m_xWidthED->set_value(m_xWidthED->NormalizePercent(nWidth), FieldUnit::TWIP);
2134 m_fWidthHeightRatio = nHeight ? double(nWidth) / double(nHeight) : 1.0;
2135 UpdateExample();
2138 void SwFramePage::UpdateExample()
2140 auto nPos = m_xHorizontalDLB->get_active();
2141 if (m_pHMap && nPos != -1)
2143 const sal_Int32 nMapPos = GetMapPos(m_pHMap, *m_xHorizontalDLB);
2144 m_aExampleWN.SetHAlign(GetAlignment(m_pHMap, nMapPos, *m_xHoriRelationLB));
2145 m_aExampleWN.SetHoriRel(GetRelation(*m_xHoriRelationLB));
2148 nPos = m_xVerticalDLB->get_active();
2149 if (m_pVMap && nPos != -1)
2151 const sal_Int32 nMapPos = GetMapPos(m_pVMap, *m_xVerticalDLB);
2152 m_aExampleWN.SetVAlign(GetAlignment(m_pVMap, nMapPos, *m_xVertRelationLB));
2153 m_aExampleWN.SetVertRel(GetRelation(*m_xVertRelationLB));
2156 // size
2157 auto nXPos = m_xAtHorzPosED->denormalize(m_xAtHorzPosED->get_value(FieldUnit::TWIP));
2158 auto nYPos = m_xAtVertPosED->denormalize(m_xAtVertPosED->get_value(FieldUnit::TWIP));
2159 m_aExampleWN.SetRelPos(Point(nXPos, nYPos));
2161 m_aExampleWN.SetAnchor(GetAnchor());
2162 m_aExampleWN.Invalidate();
2165 void SwFramePage::Init(const SfxItemSet& rSet)
2167 if(!m_bFormat)
2169 SwWrtShell* pSh = getFrameDlgParentShell();
2171 // size
2172 const bool bSizeFixed = pSh->IsSelObjProtected( FlyProtectFlags::Fixed ) != FlyProtectFlags::NONE;
2174 m_xWidthED->set_sensitive( !bSizeFixed );
2175 m_xHeightED->set_sensitive( !bSizeFixed );
2177 // size controls for math OLE objects
2178 if ( m_sDlgType == "ObjectDialog" && ! m_bNew )
2180 // disable width and height for math objects
2181 const SvGlobalName& rFactNm( pSh->GetOLEObject()->getClassID() );
2183 static struct GlobalNameId {
2184 sal_uInt32 n1;
2185 sal_uInt16 n2, n3;
2186 sal_uInt8 b8, b9, b10, b11, b12, b13, b14, b15;
2187 } const aGlbNmIds[] = { { SO3_SM_CLASSID_60 }, { SO3_SM_CLASSID_50 },
2188 { SO3_SM_CLASSID_40 }, { SO3_SM_CLASSID_30 } };
2190 for (const GlobalNameId & rId : aGlbNmIds) {
2191 SvGlobalName aGlbNm( rId.n1, rId.n2, rId.n3,
2192 rId.b8, rId.b9, rId.b10, rId.b11,
2193 rId.b12, rId.b13, rId.b14, rId.b15 );
2195 if( rFactNm == aGlbNm )
2197 // disable size controls for math OLE objects
2198 m_xWidthFT->set_sensitive(false);
2199 m_xWidthED->set_sensitive(false);
2200 m_xRelWidthCB->set_sensitive(false);
2201 m_xHeightFT->set_sensitive(false);
2202 m_xHeightED->set_sensitive(false);
2203 m_xRelHeightCB->set_sensitive(false);
2204 m_xFixedRatioCB->set_sensitive(false);
2205 m_xRealSizeBT->set_sensitive(false);
2206 break;
2210 // TODO/LATER: get correct aspect
2211 if(0 != (pSh->GetOLEObject()->getStatus( embed::Aspects::MSOLE_CONTENT ) & embed::EmbedMisc::MS_EMBED_RECOMPOSEONRESIZE ) )
2212 m_xRealSizeBT->set_sensitive(false);
2216 const SwFormatFrameSize& rSize = rSet.Get(RES_FRM_SIZE);
2217 sal_Int64 nWidth = m_xWidthED->NormalizePercent(rSize.GetWidth());
2218 sal_Int64 nHeight = m_xHeightED->NormalizePercent(rSize.GetHeight());
2220 if (nWidth != m_xWidthED->get_value(FieldUnit::TWIP))
2221 m_xWidthED->set_value(nWidth, FieldUnit::TWIP);
2223 if (nHeight != m_xHeightED->get_value(FieldUnit::TWIP))
2224 m_xHeightED->set_value(nHeight, FieldUnit::TWIP);
2226 if (!IsInGraficMode())
2228 SwFrameSize eSize = rSize.GetHeightSizeType();
2229 bool bCheck = eSize != SwFrameSize::Fixed;
2230 m_xAutoHeightCB->set_active(bCheck);
2231 HandleAutoCB( bCheck, *m_xHeightFT, *m_xHeightAutoFT, *m_xWidthED->get() );
2232 if( eSize == SwFrameSize::Variable )
2233 m_xHeightED->set_value(m_xHeightED->get_min());
2235 eSize = rSize.GetWidthSizeType();
2236 bCheck = eSize != SwFrameSize::Fixed;
2237 m_xAutoWidthCB->set_active(bCheck);
2238 HandleAutoCB( bCheck, *m_xWidthFT, *m_xWidthAutoFT, *m_xWidthED->get() );
2239 if( eSize == SwFrameSize::Variable )
2240 m_xWidthED->set_value(m_xWidthED->get_min());
2242 if ( !m_bFormat )
2244 SwWrtShell* pSh = getFrameDlgParentShell();
2245 const SwFrameFormat* pFormat = pSh->GetFlyFrameFormat();
2246 if( pFormat && pFormat->GetChain().GetNext() )
2247 m_xAutoHeightCB->set_sensitive( false );
2250 else
2251 m_xAutoHeightCB->hide();
2253 // organise circulation-gap for character bound frames
2254 const SvxULSpaceItem &rUL = rSet.Get(RES_UL_SPACE);
2255 m_nUpperBorder = rUL.GetUpper();
2256 m_nLowerBorder = rUL.GetLower();
2258 if (SfxItemState::SET == rSet.GetItemState(FN_KEEP_ASPECT_RATIO))
2259 m_xFixedRatioCB->set_active(rSet.Get(FN_KEEP_ASPECT_RATIO).GetValue());
2261 // columns
2262 SwFormatCol aCol( rSet.Get(RES_COL) );
2263 ::FitToActualSize( aCol, o3tl::narrowing<sal_uInt16>(rSize.GetWidth()) );
2265 RndStdIds eAnchorId = GetAnchor();
2267 if ( m_bNew && !m_bFormat )
2268 InitPos(eAnchorId, -1, 0, -1, 0, LONG_MAX, LONG_MAX);
2269 else
2271 const SwFormatHoriOrient& rHori = rSet.Get(RES_HORI_ORIENT);
2272 const SwFormatVertOrient& rVert = rSet.Get(RES_VERT_ORIENT);
2273 m_nOldH = rHori.GetHoriOrient();
2274 m_nOldHRel = rHori.GetRelationOrient();
2275 m_nOldV = rVert.GetVertOrient();
2276 m_nOldVRel = rVert.GetRelationOrient();
2278 if (eAnchorId == RndStdIds::FLY_AT_PAGE)
2280 if (m_nOldHRel == text::RelOrientation::FRAME)
2281 m_nOldHRel = text::RelOrientation::PAGE_FRAME;
2282 else if (m_nOldHRel == text::RelOrientation::PRINT_AREA)
2283 m_nOldHRel = text::RelOrientation::PAGE_PRINT_AREA;
2284 if (m_nOldVRel == text::RelOrientation::FRAME)
2285 m_nOldVRel = text::RelOrientation::PAGE_FRAME;
2286 else if (m_nOldVRel == text::RelOrientation::PRINT_AREA)
2287 m_nOldVRel = text::RelOrientation::PAGE_PRINT_AREA;
2290 m_xMirrorPagesCB->set_active(rHori.IsPosToggle());
2291 m_xMirrorPagesCB->save_state();
2293 InitPos(eAnchorId,
2294 m_nOldH,
2295 m_nOldHRel,
2296 m_nOldV,
2297 m_nOldVRel,
2298 rHori.GetPos(),
2299 rVert.GetPos());
2302 // transparent for example
2303 // circulation for example
2304 const SwFormatSurround& rSurround = rSet.Get(RES_SURROUND);
2305 m_aExampleWN.SetWrap( rSurround.GetSurround() );
2307 if ( rSurround.GetSurround() == css::text::WrapTextMode_THROUGH )
2309 const SvxOpaqueItem& rOpaque = rSet.Get(RES_OPAQUE);
2310 m_aExampleWN.SetTransparent(!rOpaque.GetValue());
2313 // switch to percent if applicable
2314 RangeModifyHdl(); // set reference values (for 100%)
2316 if (rSize.GetWidthPercent() == SwFormatFrameSize::SYNCED || rSize.GetHeightPercent() == SwFormatFrameSize::SYNCED)
2317 m_xFixedRatioCB->set_active(true);
2318 m_xFixedRatioCB->save_state();
2319 if (rSize.GetWidthPercent() && rSize.GetWidthPercent() != SwFormatFrameSize::SYNCED &&
2320 !m_xRelWidthCB->get_active())
2322 m_xRelWidthCB->set_active(true);
2323 RelSizeClickHdl(*m_xRelWidthCB);
2324 m_xWidthED->set_value(rSize.GetWidthPercent(), FieldUnit::PERCENT);
2326 if (rSize.GetHeightPercent() && rSize.GetHeightPercent() != SwFormatFrameSize::SYNCED &&
2327 !m_xRelHeightCB->get_active())
2329 m_xRelHeightCB->set_active(true);
2330 RelSizeClickHdl(*m_xRelHeightCB);
2331 m_xHeightED->set_value(rSize.GetHeightPercent(), FieldUnit::PERCENT);
2333 m_xRelWidthCB->save_state();
2334 m_xRelHeightCB->save_state();
2336 if (rSize.GetWidthPercentRelation() == text::RelOrientation::PAGE_FRAME)
2337 m_xRelWidthRelationLB->set_active(1);
2338 else
2339 m_xRelWidthRelationLB->set_active(0);
2341 if (rSize.GetHeightPercentRelation() == text::RelOrientation::PAGE_FRAME)
2342 m_xRelHeightRelationLB->set_active(1);
2343 else
2344 m_xRelHeightRelationLB->set_active(0);
2347 void SwFramePage::SetFormatUsed(bool bFormatUsed)
2349 m_bFormat = bFormatUsed;
2350 if (m_bFormat)
2351 m_xAnchorAtFrameRB->hide();
2354 void SwFramePage::EnableVerticalPositioning( bool bEnable )
2356 m_bAllowVertPositioning = bEnable;
2357 m_xVerticalFT->set_sensitive( bEnable );
2358 m_xVerticalDLB->set_sensitive( bEnable );
2359 m_xAtVertPosFT->set_sensitive( bEnable );
2360 m_xAtVertPosED->set_sensitive( bEnable );
2361 m_xVertRelationFT->set_sensitive( bEnable );
2362 m_xVertRelationLB->set_sensitive( bEnable );
2365 SwGrfExtPage::SwGrfExtPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet &rSet)
2366 : SfxTabPage(pPage, pController, "modules/swriter/ui/picturepage.ui", "PicturePage", &rSet)
2367 , m_bHtmlMode(false)
2368 , m_xMirror(m_xBuilder->weld_widget("flipframe"))
2369 , m_xMirrorVertBox(m_xBuilder->weld_check_button("vert"))
2370 , m_xMirrorHorzBox(m_xBuilder->weld_check_button("hori"))
2371 , m_xAllPagesRB(m_xBuilder->weld_radio_button("allpages"))
2372 , m_xLeftPagesRB(m_xBuilder->weld_radio_button("leftpages"))
2373 , m_xRightPagesRB(m_xBuilder->weld_radio_button("rightpages"))
2374 , m_xConnectED(m_xBuilder->weld_entry("entry"))
2375 , m_xBrowseBT(m_xBuilder->weld_button("browse"))
2376 , m_xLinkFrame(m_xBuilder->weld_frame("linkframe"))
2377 // RotGrfFlyFrame: Need Angle and RotateControls now
2378 , m_xFlAngle(m_xBuilder->weld_frame("FL_ANGLE"))
2379 , m_xNfAngle(m_xBuilder->weld_metric_spin_button("NF_ANGLE", FieldUnit::DEGREE))
2380 , m_xCtlAngle(new svx::DialControl)
2381 , m_xCtlAngleWin(new weld::CustomWeld(*m_xBuilder, "CTL_ANGLE", *m_xCtlAngle))
2382 , m_xBmpWin(new weld::CustomWeld(*m_xBuilder, "preview", m_aBmpWin))
2383 // tdf#138843 place holder for the graphic type
2384 , m_xLabelGraphicType(m_xBuilder->weld_label("label-graphic-type"))
2386 m_aBmpWin.SetBitmapEx(BitmapEx(RID_BMP_PREVIEW_FALLBACK));
2388 m_xCtlAngle->SetLinkedField(m_xNfAngle.get(), 2);
2390 SetExchangeSupport();
2391 m_xMirrorHorzBox->connect_toggled(LINK(this, SwGrfExtPage, MirrorHdl));
2392 m_xMirrorVertBox->connect_toggled(LINK(this, SwGrfExtPage, MirrorHdl));
2393 m_xBrowseBT->connect_clicked(LINK(this, SwGrfExtPage, BrowseHdl));
2396 SwGrfExtPage::~SwGrfExtPage()
2398 m_xBmpWin.reset();
2399 m_xCtlAngleWin.reset();
2400 m_xCtlAngle.reset();
2401 m_xGrfDlg.reset();
2404 std::unique_ptr<SfxTabPage> SwGrfExtPage::Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet *rSet)
2406 return std::make_unique<SwGrfExtPage>(pPage, pController, *rSet);
2409 void SwGrfExtPage::Reset(const SfxItemSet *rSet)
2411 const sal_uInt16 nHtmlMode = ::GetHtmlMode(static_cast<const SwDocShell*>(SfxObjectShell::Current()));
2412 m_bHtmlMode = (nHtmlMode & HTMLMODE_ON) != 0;
2414 const SfxBoolItem* pConnectItem = rSet->GetItemIfSet( FN_PARAM_GRF_CONNECT );
2415 if( pConnectItem && pConnectItem->GetValue() )
2417 m_xBrowseBT->set_sensitive(true);
2418 m_xConnectED->set_editable(true);
2421 // RotGrfFlyFrame: Get RotationAngle and set at control
2422 if(const SdrAngleItem* pAngleItem = rSet->GetItemIfSet( SID_ATTR_TRANSFORM_ANGLE, false))
2424 m_xCtlAngle->SetRotation(pAngleItem->GetValue());
2426 else
2428 m_xCtlAngle->SetRotation(0_deg100);
2430 m_xCtlAngle->SaveValue();
2432 ActivatePage(*rSet);
2435 void SwGrfExtPage::ActivatePage(const SfxItemSet& rSet)
2437 const SvxProtectItem& rProt = rSet.Get(RES_PROTECT);
2438 bool bProtContent = rProt.IsContentProtected();
2440 const SfxPoolItem* pItem = nullptr;
2441 bool bEnable = false;
2442 bool bEnableMirrorRB = false;
2444 SfxItemState eState = rSet.GetItemState(RES_GRFATR_MIRRORGRF, true, &pItem);
2445 if (SfxItemState::UNKNOWN != eState && !bProtContent && !m_bHtmlMode)
2447 if( SfxItemState::SET != eState )
2448 pItem = &rSet.Get( RES_GRFATR_MIRRORGRF );
2450 bEnable = true;
2452 MirrorGraph eMirror = static_cast<const SwMirrorGrf* >(pItem)->GetValue();
2453 switch( eMirror )
2455 case MirrorGraph::Dont: break;
2456 case MirrorGraph::Vertical: m_xMirrorHorzBox->set_active(true); break;
2457 case MirrorGraph::Horizontal: m_xMirrorVertBox->set_active(true); break;
2458 case MirrorGraph::Both: m_xMirrorHorzBox->set_active(true);
2459 m_xMirrorVertBox->set_active(true);
2460 break;
2461 default:
2465 const int nPos = (static_cast<const SwMirrorGrf* >(pItem)->IsGrfToggle() ? 1 : 0)
2466 + ((eMirror == MirrorGraph::Vertical || eMirror == MirrorGraph::Both) ? 2 : 0);
2468 bEnableMirrorRB = nPos != 0;
2470 switch (nPos)
2472 case 1: // mirror at left / even pages
2473 m_xLeftPagesRB->set_active(true);
2474 m_xMirrorHorzBox->set_active(true);
2475 break;
2476 case 2: // mirror on all pages
2477 m_xAllPagesRB->set_active(true);
2478 break;
2479 case 3: // mirror on right / odd pages
2480 m_xRightPagesRB->set_active(true);
2481 break;
2482 default:
2483 m_xAllPagesRB->set_active(true);
2484 break;
2488 if( const SvxBrushItem* pGraphicBrushItem = rSet.GetItemIfSet( SID_ATTR_GRAF_GRAPHIC, false ) )
2490 if( !pGraphicBrushItem->GetGraphicLink().isEmpty() )
2492 m_aGrfName = m_aNewGrfName = pGraphicBrushItem->GetGraphicLink();
2493 m_xConnectED->set_text(m_aNewGrfName);
2495 OUString referer;
2496 SfxStringItem const * it = rSet.GetItem(SID_REFERER);
2497 if (it != nullptr) {
2498 referer = it->GetValue();
2500 const Graphic* pGrf = pGraphicBrushItem->GetGraphic(referer);
2501 if( pGrf )
2503 m_aBmpWin.SetGraphic( *pGrf );
2504 m_xLabelGraphicType->set_label(GraphicHelper::GetImageType(*pGrf));
2508 m_xConnectED->save_value();
2510 m_xMirror->set_sensitive(bEnable);
2511 m_xAllPagesRB->set_sensitive(bEnableMirrorRB);
2512 m_xLeftPagesRB->set_sensitive(bEnableMirrorRB);
2513 m_xRightPagesRB->set_sensitive(bEnableMirrorRB);
2515 m_xAllPagesRB->save_state();
2516 m_xLeftPagesRB->save_state();
2517 m_xRightPagesRB->save_state();
2518 m_xMirrorHorzBox->save_state();
2519 m_xMirrorVertBox->save_state();
2521 m_aBmpWin.MirrorHorz( m_xMirrorVertBox->get_active() );
2522 m_aBmpWin.MirrorVert( m_xMirrorHorzBox->get_active() );
2523 m_aBmpWin.Invalidate();
2526 bool SwGrfExtPage::FillItemSet( SfxItemSet *rSet )
2528 bool bModified = false;
2529 if ( m_xMirrorHorzBox->get_state_changed_from_saved() ||
2530 m_xMirrorVertBox->get_state_changed_from_saved() ||
2531 m_xAllPagesRB->get_state_changed_from_saved() ||
2532 m_xLeftPagesRB->get_state_changed_from_saved() ||
2533 m_xRightPagesRB->get_state_changed_from_saved() )
2535 bModified = true;
2537 bool bHori = false;
2539 if (m_xMirrorHorzBox->get_active() &&
2540 !m_xLeftPagesRB->get_active())
2541 bHori = true;
2543 MirrorGraph eMirror;
2544 eMirror = m_xMirrorVertBox->get_active() && bHori ?
2545 MirrorGraph::Both : bHori ?
2546 MirrorGraph::Vertical : m_xMirrorVertBox->get_active() ?
2547 MirrorGraph::Horizontal : MirrorGraph::Dont;
2549 bool bMirror = !m_xAllPagesRB->get_active();
2550 SwMirrorGrf aMirror( eMirror );
2551 aMirror.SetGrfToggle(bMirror );
2552 rSet->Put( aMirror );
2555 if (m_aGrfName != m_aNewGrfName || m_xConnectED->get_value_changed_from_saved())
2557 bModified = true;
2558 m_aGrfName = m_xConnectED->get_text();
2559 rSet->Put( SvxBrushItem( m_aGrfName, m_aFilterName, GPOS_LT,
2560 SID_ATTR_GRAF_GRAPHIC ));
2563 // RotGrfFlyFrame: Safe rotation if modified
2564 if(m_xCtlAngle->IsValueModified())
2566 rSet->Put(SdrAngleItem(SID_ATTR_TRANSFORM_ANGLE, m_xCtlAngle->GetRotation()));
2567 bModified = true;
2570 return bModified;
2573 DeactivateRC SwGrfExtPage::DeactivatePage(SfxItemSet *_pSet)
2575 if( _pSet )
2576 FillItemSet( _pSet );
2577 return DeactivateRC::LeavePage;
2580 IMPL_LINK_NOARG(SwGrfExtPage, BrowseHdl, weld::Button&, void)
2582 if(!m_xGrfDlg)
2584 m_xGrfDlg.reset(new FileDialogHelper(
2585 ui::dialogs::TemplateDescription::FILEOPEN_LINK_PREVIEW,
2586 FileDialogFlags::Graphic, GetFrameWeld()));
2587 m_xGrfDlg->SetTitle(m_xLinkFrame->get_label());
2589 m_xGrfDlg->SetDisplayDirectory(m_xConnectED->get_text());
2590 uno::Reference < ui::dialogs::XFilePicker3 > xFP = m_xGrfDlg->GetFilePicker();
2591 uno::Reference < ui::dialogs::XFilePickerControlAccess > xCtrlAcc(xFP, uno::UNO_QUERY);
2592 xCtrlAcc->setValue( ui::dialogs::ExtendedFilePickerElementIds::CHECKBOX_LINK, 0, uno::Any(true) );
2594 if ( m_xGrfDlg->Execute() != ERRCODE_NONE )
2595 return;
2597 // remember selected filter
2598 m_aFilterName = m_xGrfDlg->GetCurrentFilter();
2599 m_aNewGrfName = INetURLObject::decode( m_xGrfDlg->GetPath(),
2600 INetURLObject::DecodeMechanism::Unambiguous );
2601 m_xConnectED->set_text(m_aNewGrfName);
2602 //reset mirrors because maybe a Bitmap was swapped with
2603 //another type of graphic that cannot be mirrored.
2604 m_xMirrorVertBox->set_active(false);
2605 m_xMirrorHorzBox->set_active(false);
2606 m_xAllPagesRB->set_sensitive(false);
2607 m_xLeftPagesRB->set_sensitive(false);
2608 m_xRightPagesRB->set_sensitive(false);
2609 m_aBmpWin.MirrorHorz(false);
2610 m_aBmpWin.MirrorVert(false);
2612 Graphic aGraphic;
2613 (void)GraphicFilter::LoadGraphic(m_xGrfDlg->GetPath(), OUString(), aGraphic);
2614 m_aBmpWin.SetGraphic(aGraphic);
2615 m_xLabelGraphicType->set_label(GraphicHelper::GetImageType(aGraphic));
2617 bool bEnable = GraphicType::Bitmap == aGraphic.GetType() ||
2618 GraphicType::GdiMetafile == aGraphic.GetType();
2619 m_xMirrorVertBox->set_sensitive(bEnable);
2620 m_xMirrorHorzBox->set_sensitive(bEnable);
2621 m_xAllPagesRB->set_sensitive(bEnable);
2622 m_xLeftPagesRB->set_sensitive(bEnable);
2623 m_xRightPagesRB->set_sensitive(bEnable);
2627 IMPL_LINK_NOARG(SwGrfExtPage, MirrorHdl, weld::Toggleable&, void)
2629 bool bEnable = m_xMirrorHorzBox->get_active();
2631 m_aBmpWin.MirrorHorz( m_xMirrorVertBox->get_active() );
2632 m_aBmpWin.MirrorVert( bEnable );
2634 m_xAllPagesRB->set_sensitive(bEnable);
2635 m_xLeftPagesRB->set_sensitive(bEnable);
2636 m_xRightPagesRB->set_sensitive(bEnable);
2638 if (!m_xAllPagesRB->get_active() && !m_xLeftPagesRB->get_active() && !m_xRightPagesRB->get_active())
2639 m_xAllPagesRB->set_active(true);
2642 // example window
2643 BmpWindow::BmpWindow()
2644 : m_bHorz(false)
2645 , m_bVert(false)
2646 , m_bGraphic(false)
2650 void BmpWindow::SetDrawingArea(weld::DrawingArea* pDrawingArea)
2652 CustomWidgetController::SetDrawingArea(pDrawingArea);
2653 Size aSize = pDrawingArea->get_ref_device().LogicToPixel(Size(127 , 66), MapMode(MapUnit::MapAppFont));
2654 set_size_request(aSize.Width(), aSize.Height());
2655 SetOutputSizePixel(aSize);
2658 void BmpWindow::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle&)
2660 // Setup
2661 rRenderContext.SetBackground(Wallpaper(Application::GetSettings().GetStyleSettings().GetDialogColor()));
2662 rRenderContext.Erase();
2663 // #i119307# the graphic might have transparency, set up white as the color
2664 // to use when drawing a rectangle under the image
2665 rRenderContext.SetLineColor(COL_WHITE);
2666 rRenderContext.SetFillColor(COL_WHITE);
2668 // Paint
2669 Point aPntPos;
2670 Size aPntSz(GetOutputSizePixel());
2671 Size aGrfSize;
2672 if (m_bGraphic)
2673 aGrfSize = ::GetGraphicSizeTwip(m_aGraphic, &rRenderContext);
2674 //it should show the default bitmap also if no graphic can be found
2675 if (!aGrfSize.Width() && !aGrfSize.Height())
2676 aGrfSize = rRenderContext.PixelToLogic(m_aBmp.GetSizePixel());
2678 tools::Long nRelGrf = aGrfSize.Width() * 100 / aGrfSize.Height();
2679 tools::Long nRelWin = aPntSz.Width() * 100 / aPntSz.Height();
2680 if (nRelGrf < nRelWin)
2682 const tools::Long nWidth = aPntSz.Width();
2683 // if we use a replacement preview, try to draw at original size
2684 if (!m_bGraphic && (aGrfSize.Width() <= aPntSz.Width())
2685 && (aGrfSize.Height() <= aPntSz.Height()))
2687 const tools::Long nHeight = aPntSz.Height();
2688 aPntSz.setWidth( aGrfSize.Width() );
2689 aPntSz.setHeight( aGrfSize.Height() );
2690 aPntPos.AdjustY((nHeight - aPntSz.Height()) / 2 );
2692 else
2693 aPntSz.setWidth( aPntSz.Height() * nRelGrf /100 );
2695 aPntPos.AdjustX(nWidth - aPntSz.Width() ) ;
2698 // #i119307# clear window background, the graphic might have transparency
2699 rRenderContext.DrawRect(tools::Rectangle(aPntPos, aPntSz));
2701 if (m_bHorz || m_bVert)
2703 BitmapEx aTmpBmp(m_bGraphic ? m_aGraphic.GetBitmapEx() : m_aBmp);
2704 BmpMirrorFlags nMirrorFlags(BmpMirrorFlags::NONE);
2705 if (m_bHorz)
2706 nMirrorFlags |= BmpMirrorFlags::Vertical;
2707 if (m_bVert)
2708 nMirrorFlags |= BmpMirrorFlags::Horizontal;
2709 aTmpBmp.Mirror(nMirrorFlags);
2710 rRenderContext.DrawBitmapEx(aPntPos, aPntSz, aTmpBmp);
2712 else if (m_bGraphic) //draw unmirrored preview graphic
2714 m_aGraphic.Draw(rRenderContext, aPntPos, aPntSz);
2716 else //draw unmirrored stock sample image
2718 rRenderContext.DrawBitmapEx(aPntPos, aPntSz, m_aBmp);
2722 BmpWindow::~BmpWindow()
2726 void BmpWindow::SetGraphic(const Graphic& rGraphic)
2728 m_aGraphic = rGraphic;
2729 Size aSize = m_aGraphic.GetPrefSize();
2730 m_bGraphic = aSize.Width() && aSize.Height();
2731 Invalidate();
2734 void BmpWindow::SetBitmapEx(const BitmapEx& rBmp)
2736 m_aBmp = rBmp;
2737 Invalidate();
2740 // set URL and ImageMap at frames
2741 SwFrameURLPage::SwFrameURLPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet &rSet)
2742 : SfxTabPage(pPage, pController, "modules/swriter/ui/frmurlpage.ui", "FrameURLPage", &rSet)
2743 , m_xURLED(m_xBuilder->weld_entry("url"))
2744 , m_xSearchPB(m_xBuilder->weld_button("search"))
2745 , m_xNameED(m_xBuilder->weld_entry("name"))
2746 , m_xFrameCB(m_xBuilder->weld_combo_box("frame"))
2747 , m_xServerCB(m_xBuilder->weld_check_button("server"))
2748 , m_xClientCB(m_xBuilder->weld_check_button("client"))
2750 m_xSearchPB->connect_clicked(LINK(this, SwFrameURLPage, InsertFileHdl));
2753 SwFrameURLPage::~SwFrameURLPage()
2757 void SwFrameURLPage::Reset( const SfxItemSet *rSet )
2759 if ( SfxItemState::SET == rSet->GetItemState( SID_DOCFRAME ))
2761 TargetList aList;
2762 SfxFrame::GetDefaultTargetList(aList);
2763 size_t nCount = aList.size();
2764 for (size_t i = 0; i < nCount; ++i)
2766 m_xFrameCB->append_text(aList.at(i));
2770 if ( const SwFormatURL* pFormatURL = rSet->GetItemIfSet( RES_URL ) )
2772 m_xURLED->set_text(INetURLObject::decode(pFormatURL->GetURL(),
2773 INetURLObject::DecodeMechanism::Unambiguous));
2774 m_xNameED->set_text(pFormatURL->GetName());
2776 m_xClientCB->set_sensitive(pFormatURL->GetMap() != nullptr);
2777 m_xClientCB->set_active(pFormatURL->GetMap() != nullptr);
2778 m_xServerCB->set_active(pFormatURL->IsServerMap());
2780 m_xFrameCB->set_entry_text(pFormatURL->GetTargetFrameName());
2781 m_xFrameCB->save_value();
2783 else
2784 m_xClientCB->set_sensitive(false);
2786 m_xServerCB->save_state();
2787 m_xClientCB->save_state();
2790 bool SwFrameURLPage::FillItemSet(SfxItemSet *rSet)
2792 bool bModified = false;
2793 const SwFormatURL* pOldURL = GetOldItem(*rSet, RES_URL);
2794 std::unique_ptr<SwFormatURL> pFormatURL;
2795 if(pOldURL)
2796 pFormatURL.reset(pOldURL->Clone());
2797 else
2798 pFormatURL.reset(new SwFormatURL());
2801 const OUString sText = m_xURLED->get_text();
2803 if( pFormatURL->GetURL() != sText ||
2804 pFormatURL->GetName() != m_xNameED->get_text() ||
2805 m_xServerCB->get_active() != pFormatURL->IsServerMap() )
2807 pFormatURL->SetURL(sText, m_xServerCB->get_active());
2808 pFormatURL->SetName(m_xNameED->get_text());
2809 bModified = true;
2813 if (!m_xClientCB->get_active() && pFormatURL->GetMap() != nullptr)
2815 pFormatURL->SetMap(nullptr);
2816 bModified = true;
2819 if(pFormatURL->GetTargetFrameName() != m_xFrameCB->get_active_text())
2821 pFormatURL->SetTargetFrameName(m_xFrameCB->get_active_text());
2822 bModified = true;
2824 rSet->Put(std::move(pFormatURL));
2825 return bModified;
2828 std::unique_ptr<SfxTabPage> SwFrameURLPage::Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet *rSet)
2830 return std::make_unique<SwFrameURLPage>(pPage, pController, *rSet);
2833 IMPL_LINK_NOARG(SwFrameURLPage, InsertFileHdl, weld::Button&, void)
2835 FileDialogHelper aDlgHelper(ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE,
2836 FileDialogFlags::NONE, GetFrameWeld());
2837 uno::Reference < ui::dialogs::XFilePicker3 > xFP = aDlgHelper.GetFilePicker();
2841 const OUString sTemp(m_xURLED->get_text());
2842 if(!sTemp.isEmpty())
2843 xFP->setDisplayDirectory(sTemp);
2845 catch( const uno::Exception& ) {}
2846 if( aDlgHelper.Execute() == ERRCODE_NONE )
2848 m_xURLED->set_text(xFP->getSelectedFiles().getConstArray()[0]);
2852 SwFrameAddPage::SwFrameAddPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet &rSet)
2853 : SfxTabPage(pPage, pController, "modules/swriter/ui/frmaddpage.ui", "FrameAddPage", &rSet)
2854 , m_pWrtSh(nullptr)
2855 , m_bHtmlMode(false)
2856 , m_bFormat(false)
2857 , m_bNew(false)
2858 , m_xNameFrame(m_xBuilder->weld_widget("nameframe"))
2859 , m_xNameFT(m_xBuilder->weld_label("name_label"))
2860 , m_xNameED(m_xBuilder->weld_entry("name"))
2861 , m_xAltNameFT(m_xBuilder->weld_label("altname_label"))
2862 , m_xAltNameED(m_xBuilder->weld_entry("altname"))
2863 , m_xDescriptionFT(m_xBuilder->weld_label("description_label"))
2864 , m_xDescriptionED(m_xBuilder->weld_text_view("description"))
2865 , m_xDecorativeCB(m_xBuilder->weld_check_button("decorative"))
2866 , m_xSequenceFrame(m_xBuilder->weld_widget("frmSequence"))
2867 , m_xPrevLB(m_xBuilder->weld_combo_box("prev"))
2868 , m_xNextLB(m_xBuilder->weld_combo_box("next"))
2869 , m_xProtectFrame(m_xBuilder->weld_widget("protect"))
2870 , m_xProtectContentCB(m_xBuilder->weld_check_button("protectcontent"))
2871 , m_xProtectFrameCB(m_xBuilder->weld_check_button("protectframe"))
2872 , m_xProtectSizeCB(m_xBuilder->weld_check_button("protectsize"))
2873 , m_xContentAlignFrame(m_xBuilder->weld_widget("contentalign"))
2874 , m_xVertAlignLB(m_xBuilder->weld_combo_box("vertalign"))
2875 , m_xPropertiesFrame(m_xBuilder->weld_widget("properties"))
2876 , m_xEditInReadonlyCB(m_xBuilder->weld_check_button("editinreadonly"))
2877 , m_xPrintFrameCB(m_xBuilder->weld_check_button("printframe"))
2878 , m_xTextFlowFT(m_xBuilder->weld_label("textflow_label"))
2879 , m_xTextFlowLB(new svx::FrameDirectionListBox(m_xBuilder->weld_combo_box("textflow")))
2881 m_xTextFlowLB->append(SvxFrameDirection::Horizontal_LR_TB, SvxResId(RID_SVXSTR_FRAMEDIR_LTR));
2882 m_xTextFlowLB->append(SvxFrameDirection::Horizontal_RL_TB, SvxResId(RID_SVXSTR_FRAMEDIR_RTL));
2883 m_xTextFlowLB->append(SvxFrameDirection::Vertical_RL_TB, SvxResId(RID_SVXSTR_PAGEDIR_RTL_VERT));
2884 m_xTextFlowLB->append(SvxFrameDirection::Vertical_LR_TB, SvxResId(RID_SVXSTR_PAGEDIR_LTR_VERT));
2885 m_xTextFlowLB->append(SvxFrameDirection::Vertical_LR_BT, SvxResId(RID_SVXSTR_PAGEDIR_LTR_BTT_VERT));
2886 m_xTextFlowLB->append(SvxFrameDirection::Environment, SvxResId(RID_SVXSTR_FRAMEDIR_SUPER));
2887 m_xDescriptionED->set_size_request(-1, m_xDescriptionED->get_preferred_size().Height());
2889 m_xDecorativeCB->connect_toggled(LINK(this, SwFrameAddPage, DecorativeHdl));
2892 SwFrameAddPage::~SwFrameAddPage()
2894 m_xTextFlowLB.reset();
2897 std::unique_ptr<SfxTabPage> SwFrameAddPage::Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet *rSet)
2899 return std::make_unique<SwFrameAddPage>(pPage, pController, *rSet);
2902 void SwFrameAddPage::Reset(const SfxItemSet *rSet )
2904 sal_uInt16 nHtmlMode = ::GetHtmlMode(static_cast<const SwDocShell*>(SfxObjectShell::Current()));
2905 m_bHtmlMode = (nHtmlMode & HTMLMODE_ON) != 0;
2906 if (m_bHtmlMode)
2908 m_xProtectFrame->hide();
2909 m_xEditInReadonlyCB->hide();
2910 m_xPrintFrameCB->hide();
2912 if (m_sDlgType == "PictureDialog" || m_sDlgType == "ObjectDialog")
2914 m_xSequenceFrame->hide();
2915 m_xEditInReadonlyCB->hide();
2916 if (m_bHtmlMode)
2918 m_xPropertiesFrame->hide();
2920 m_xContentAlignFrame->hide();
2923 if(const SfxStringItem* pNameItem = rSet->GetItemIfSet(FN_SET_FRM_ALT_NAME, false))
2925 m_xAltNameED->set_text(pNameItem->GetValue());
2926 m_xAltNameED->save_value();
2929 if(const SfxStringItem* pDescriptionItem = rSet->GetItemIfSet(FN_UNO_DESCRIPTION, false))
2931 m_xDescriptionED->set_text(pDescriptionItem->GetValue());
2932 m_xDescriptionED->save_value();
2935 if(!m_bFormat)
2937 // insert graphic - properties
2938 // bNew is not set, so recognise by selection
2939 OUString aTmpName1;
2940 if(const SfxStringItem* pNameItem = rSet->GetItemIfSet(FN_SET_FRM_NAME, false))
2942 aTmpName1 = pNameItem->GetValue();
2945 OSL_ENSURE(m_pWrtSh, "no Shell?");
2946 if( m_bNew || aTmpName1.isEmpty() )
2948 if (m_sDlgType == "PictureDialog")
2949 aTmpName1 = m_pWrtSh->GetUniqueGrfName();
2950 else if (m_sDlgType == "ObjectDialog")
2951 aTmpName1 = m_pWrtSh->GetUniqueOLEName();
2952 else
2953 aTmpName1 = m_pWrtSh->GetUniqueFrameName();
2955 m_pWrtSh->SetFlyName(aTmpName1);
2958 m_xNameED->set_text( aTmpName1 );
2959 m_xNameED->save_value();
2961 else
2963 m_xNameED->set_sensitive( false );
2964 m_xAltNameED->set_sensitive(false);
2965 m_xNameFT->set_sensitive( false );
2966 m_xAltNameFT->set_sensitive(false);
2968 if (m_sDlgType == "FrameDialog" && m_xAltNameFT->get_visible())
2970 m_xAltNameFT->hide();
2971 m_xAltNameED->hide();
2973 else
2975 m_xNameED->connect_changed(LINK(this, SwFrameAddPage, EditModifyHdl));
2978 if (!m_bNew)
2980 SwFrameFormat* pFormat = m_pWrtSh->GetFlyFrameFormat();
2982 if (pFormat)
2984 const SwFormatChain &rChain = pFormat->GetChain();
2985 const SwFlyFrameFormat* pFlyFormat;
2986 OUString sNextChain, sPrevChain;
2987 pFlyFormat = rChain.GetPrev();
2988 if (pFlyFormat != nullptr)
2990 sPrevChain = pFlyFormat->GetName();
2993 pFlyFormat = rChain.GetNext();
2994 if (pFlyFormat != nullptr)
2996 sNextChain = pFlyFormat->GetName();
2998 //determine chainable frames
2999 std::vector< OUString > aPrevPageFrames;
3000 std::vector< OUString > aThisPageFrames;
3001 std::vector< OUString > aNextPageFrames;
3002 std::vector< OUString > aRemainFrames;
3003 m_pWrtSh->GetConnectableFrameFormats(*pFormat, sNextChain, false,
3004 aPrevPageFrames, aThisPageFrames, aNextPageFrames, aRemainFrames );
3005 for (sal_Int32 nEntry = m_xPrevLB->get_count(); nEntry > 1; nEntry--)
3006 m_xPrevLB->remove(nEntry - 1);
3007 lcl_InsertVectors(*m_xPrevLB, aPrevPageFrames, aThisPageFrames, aNextPageFrames, aRemainFrames);
3008 if(!sPrevChain.isEmpty())
3010 if (m_xPrevLB->find_text(sPrevChain) == -1)
3011 m_xPrevLB->insert_text(1, sPrevChain);
3012 m_xPrevLB->set_active_text(sPrevChain);
3014 else
3015 m_xPrevLB->set_active(0);
3016 aPrevPageFrames.clear();
3017 aNextPageFrames.clear();
3018 aThisPageFrames.clear();
3019 aRemainFrames.clear();
3021 m_pWrtSh->GetConnectableFrameFormats(*pFormat, sPrevChain, true,
3022 aPrevPageFrames, aThisPageFrames, aNextPageFrames, aRemainFrames );
3023 for (sal_Int32 nEntry = m_xNextLB->get_count(); nEntry > 1; nEntry--)
3024 m_xNextLB->remove(nEntry - 1);
3025 lcl_InsertVectors(*m_xNextLB, aPrevPageFrames, aThisPageFrames, aNextPageFrames, aRemainFrames);
3026 if(!sNextChain.isEmpty())
3028 if (m_xNextLB->find_text(sNextChain) == -1)
3029 m_xNextLB->insert_text(1, sNextChain);
3030 m_xNextLB->set_active_text(sNextChain);
3032 else
3033 m_xNextLB->set_active(0);
3034 Link<weld::ComboBox&,void> aLink(LINK(this, SwFrameAddPage, ChainModifyHdl));
3035 m_xPrevLB->connect_changed(aLink);
3036 m_xNextLB->connect_changed(aLink);
3039 // Pos Protected
3040 const SvxProtectItem& rProt = rSet->Get(RES_PROTECT);
3041 m_xProtectFrameCB->set_active(rProt.IsPosProtected());
3042 m_xProtectContentCB->set_active(rProt.IsContentProtected());
3043 m_xProtectSizeCB->set_active(rProt.IsSizeProtected());
3045 const SwFormatEditInReadonly& rEdit = rSet->Get(RES_EDIT_IN_READONLY);
3046 m_xEditInReadonlyCB->set_active(rEdit.GetValue());
3047 m_xEditInReadonlyCB->save_state();
3049 // print
3050 const SvxPrintItem& rPrt = rSet->Get(RES_PRINT);
3051 m_xPrintFrameCB->set_active(rPrt.GetValue());
3052 m_xPrintFrameCB->save_state();
3054 SfxBoolItem const& rDecorative = rSet->Get(RES_DECORATIVE);
3055 m_xDecorativeCB->set_active(rDecorative.GetValue());
3056 m_xDecorativeCB->save_state();
3058 // textflow
3059 if( (!m_bHtmlMode || (0 != (nHtmlMode&HTMLMODE_SOME_STYLES)))
3060 && m_sDlgType != "PictureDialog" && m_sDlgType != "ObjectDialog"
3061 && SfxItemState::UNKNOWN != rSet->GetItemState( RES_FRAMEDIR ) )
3063 m_xTextFlowFT->show();
3064 m_xTextFlowLB->show();
3066 //vertical text flow is not possible in HTML
3067 if(m_bHtmlMode)
3069 m_xTextFlowLB->remove_id(SvxFrameDirection::Vertical_RL_TB);
3071 SvxFrameDirection nVal = rSet->Get(RES_FRAMEDIR).GetValue();
3072 m_xTextFlowLB->set_active_id(nVal);
3073 m_xTextFlowLB->save_value();
3075 else
3077 m_xTextFlowFT->hide();
3078 m_xTextFlowLB->hide();
3081 // Content alignment
3082 if ( rSet->GetItemState(RES_TEXT_VERT_ADJUST) > SfxItemState::DEFAULT )
3084 SdrTextVertAdjust nAdjust = rSet->Get(RES_TEXT_VERT_ADJUST).GetValue();
3085 sal_Int32 nPos = 0;
3086 switch(nAdjust)
3088 case SDRTEXTVERTADJUST_TOP: nPos = 0; break;
3089 case SDRTEXTVERTADJUST_CENTER:
3090 case SDRTEXTVERTADJUST_BLOCK: nPos = 1; break;
3091 case SDRTEXTVERTADJUST_BOTTOM: nPos = 2; break;
3093 m_xVertAlignLB->set_active(nPos);
3095 m_xVertAlignLB->save_value();
3097 DecorativeHdl(*m_xDecorativeCB);
3100 bool SwFrameAddPage::FillItemSet(SfxItemSet *rSet)
3102 bool bRet = false;
3103 if (m_xNameED->get_value_changed_from_saved())
3104 bRet |= nullptr != rSet->Put(SfxStringItem(FN_SET_FRM_NAME, m_xNameED->get_text()));
3105 if (m_xAltNameED->get_value_changed_from_saved())
3106 bRet |= nullptr != rSet->Put(SfxStringItem(FN_SET_FRM_ALT_NAME, m_xAltNameED->get_text()));
3107 if (m_xDescriptionED->get_value_changed_from_saved())
3108 bRet |= nullptr != rSet->Put(SfxStringItem(FN_UNO_DESCRIPTION, m_xDescriptionED->get_text()));
3110 const SfxPoolItem* pOldItem;
3111 SvxProtectItem aProt ( GetItemSet().Get(RES_PROTECT) );
3112 aProt.SetContentProtect( m_xProtectContentCB->get_active() );
3113 aProt.SetSizeProtect ( m_xProtectSizeCB->get_active() );
3114 aProt.SetPosProtect ( m_xProtectFrameCB->get_active() );
3115 if ( nullptr == (pOldItem = GetOldItem(*rSet, FN_SET_PROTECT)) ||
3116 aProt != *pOldItem )
3117 bRet |= nullptr != rSet->Put( aProt);
3119 if ( m_xEditInReadonlyCB->get_state_changed_from_saved() )
3120 bRet |= nullptr != rSet->Put( SwFormatEditInReadonly( RES_EDIT_IN_READONLY, m_xEditInReadonlyCB->get_active()));
3122 if ( m_xPrintFrameCB->get_state_changed_from_saved() )
3123 bRet |= nullptr != rSet->Put( SvxPrintItem( RES_PRINT, m_xPrintFrameCB->get_active()));
3125 if (m_xDecorativeCB->get_state_changed_from_saved())
3127 bRet |= nullptr != rSet->Put(SfxBoolItem(RES_DECORATIVE, m_xDecorativeCB->get_active()));
3130 // textflow
3131 if (m_xTextFlowLB->get_visible() && m_xTextFlowLB->get_value_changed_from_saved())
3133 SvxFrameDirection eDirection = m_xTextFlowLB->get_active_id();
3134 bRet |= nullptr != rSet->Put( SvxFrameDirectionItem(eDirection, RES_FRAMEDIR ));
3136 if(m_pWrtSh)
3138 const SwFrameFormat* pFormat = m_pWrtSh->GetFlyFrameFormat();
3139 if (pFormat)
3141 OUString sCurrentPrevChain, sCurrentNextChain;
3142 if (m_xPrevLB->get_active())
3143 sCurrentPrevChain = m_xPrevLB->get_active_text();
3144 if (m_xNextLB->get_active())
3145 sCurrentNextChain = m_xNextLB->get_active_text();
3146 const SwFormatChain &rChain = pFormat->GetChain();
3147 const SwFlyFrameFormat* pFlyFormat;
3148 OUString sNextChain, sPrevChain;
3149 pFlyFormat = rChain.GetPrev();
3150 if (pFlyFormat != nullptr)
3151 sPrevChain = pFlyFormat->GetName();
3153 pFlyFormat = rChain.GetNext();
3154 if (pFlyFormat != nullptr)
3155 sNextChain = pFlyFormat->GetName();
3156 if(sPrevChain != sCurrentPrevChain)
3157 bRet |= nullptr != rSet->Put(SfxStringItem(FN_PARAM_CHAIN_PREVIOUS, sCurrentPrevChain));
3158 if(sNextChain != sCurrentNextChain)
3159 bRet |= nullptr != rSet->Put(SfxStringItem(FN_PARAM_CHAIN_NEXT, sCurrentNextChain));
3163 if (m_xVertAlignLB->get_value_changed_from_saved())
3165 SdrTextVertAdjust nAdjust;
3166 switch (m_xVertAlignLB->get_active())
3168 default:
3169 case 0 : nAdjust = SDRTEXTVERTADJUST_TOP; break;
3170 case 1 : nAdjust = SDRTEXTVERTADJUST_CENTER; break;
3171 case 2 : nAdjust = SDRTEXTVERTADJUST_BOTTOM; break;
3173 bRet |= nullptr != rSet->Put(SdrTextVertAdjustItem(nAdjust, RES_TEXT_VERT_ADJUST));
3176 return bRet;
3179 IMPL_LINK_NOARG(SwFrameAddPage, EditModifyHdl, weld::Entry&, void)
3181 bool bEnable = !m_xNameED->get_text().isEmpty();
3182 m_xAltNameED->set_sensitive(bEnable);
3183 m_xAltNameFT->set_sensitive(bEnable);
3186 IMPL_LINK_NOARG(SwFrameAddPage, DecorativeHdl, weld::Toggleable&, void)
3188 bool const bEnable(!m_xDecorativeCB->get_active());
3189 m_xAltNameED->set_sensitive(bEnable);
3190 m_xAltNameFT->set_sensitive(bEnable);
3191 m_xDescriptionED->set_sensitive(bEnable);
3192 m_xDescriptionFT->set_sensitive(bEnable);
3195 void SwFrameAddPage::SetFormatUsed(bool bFormatUsed)
3197 m_bFormat = bFormatUsed;
3198 if (m_bFormat)
3200 m_xNameFrame->hide();
3204 IMPL_LINK(SwFrameAddPage, ChainModifyHdl, weld::ComboBox&, rBox, void)
3206 OUString sCurrentPrevChain, sCurrentNextChain;
3207 if (m_xPrevLB->get_active())
3208 sCurrentPrevChain = m_xPrevLB->get_active_text();
3209 if (m_xNextLB->get_active())
3210 sCurrentNextChain = m_xNextLB->get_active_text();
3211 SwFrameFormat* pFormat = m_pWrtSh->GetFlyFrameFormat();
3212 if (!pFormat)
3213 return;
3215 bool bNextBox = m_xNextLB.get() == &rBox;
3216 weld::ComboBox& rChangeLB = bNextBox ? *m_xPrevLB : *m_xNextLB;
3217 for (sal_Int32 nEntry = rChangeLB.get_count(); nEntry > 1; nEntry--)
3218 rChangeLB.remove(nEntry - 1);
3219 //determine chainable frames
3220 std::vector< OUString > aPrevPageFrames;
3221 std::vector< OUString > aThisPageFrames;
3222 std::vector< OUString > aNextPageFrames;
3223 std::vector< OUString > aRemainFrames;
3224 m_pWrtSh->GetConnectableFrameFormats(*pFormat, bNextBox ? sCurrentNextChain : sCurrentPrevChain, !bNextBox,
3225 aPrevPageFrames, aThisPageFrames, aNextPageFrames, aRemainFrames );
3226 lcl_InsertVectors(rChangeLB,
3227 aPrevPageFrames, aThisPageFrames, aNextPageFrames, aRemainFrames);
3228 const OUString sToSelect = bNextBox ? sCurrentPrevChain : sCurrentNextChain;
3229 if (rChangeLB.find_text(sToSelect) != -1)
3230 rChangeLB.set_active_text(sToSelect);
3231 else
3232 rChangeLB.set_active(0);
3236 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */