Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 : #include <com/sun/star/embed/Aspects.hpp>
21 : #include <com/sun/star/embed/EmbedMisc.hpp>
22 :
23 : #include <cmdid.h>
24 : #include <helpid.h>
25 : #include <hintids.hxx>
26 : #include <vcl/msgbox.hxx>
27 : #include <vcl/mnemonic.hxx>
28 : #include <svl/urihelper.hxx>
29 : #include <svl/stritem.hxx>
30 : #include <sfx2/htmlmode.hxx>
31 : #include <editeng/sizeitem.hxx>
32 : #include <editeng/opaqitem.hxx>
33 : #include <editeng/protitem.hxx>
34 : #include <editeng/prntitem.hxx>
35 : #include <editeng/brushitem.hxx>
36 : #include <editeng/ulspitem.hxx>
37 : #include <editeng/frmdiritem.hxx>
38 : #include <svx/swframevalidation.hxx>
39 : #include <comphelper/classids.hxx>
40 :
41 : #include <sfx2/viewfrm.hxx>
42 : #include <fmturl.hxx>
43 : #include <fmteiro.hxx>
44 : #include <fmtcnct.hxx>
45 : #include <view.hxx>
46 : #include <wrtsh.hxx>
47 : #include <swmodule.hxx>
48 : #include <uitool.hxx>
49 : #include <docsh.hxx>
50 : #include <viewopt.hxx>
51 : #include <frmatr.hxx>
52 : #include <frmdlg.hxx>
53 : #include <frmmgr.hxx>
54 : #include <frmpage.hxx>
55 : #include <wrap.hxx>
56 : #include <colmgr.hxx>
57 : #include <grfatr.hxx>
58 : #include <uiitems.hxx>
59 : #include <fmtfollowtextflow.hxx>
60 : #include <editeng/adjustitem.hxx>
61 : #include <svx/sdtaitm.hxx>
62 : #include <sal/macros.h>
63 :
64 : #include <frmui.hrc>
65 : #include <sfx2/filedlghelper.hxx>
66 : #include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
67 : #include <com/sun/star/ui/dialogs/XFilePicker.hpp>
68 : #include <com/sun/star/ui/dialogs/XFilePickerControlAccess.hpp>
69 : #include <com/sun/star/ui/dialogs/ExtendedFilePickerElementIds.hpp>
70 : #include <vcl/graphicfilter.hxx>
71 : #include <vcl/builderfactory.hxx>
72 : #include <boost/scoped_ptr.hpp>
73 :
74 : using namespace ::com::sun::star;
75 : using namespace ::sfx2;
76 :
77 : #define SwFPos SvxSwFramePosString
78 :
79 : struct FrmMap
80 : {
81 : SvxSwFramePosString::StringId eStrId;
82 : SvxSwFramePosString::StringId eMirrorStrId;
83 : sal_Int16 nAlign;
84 : sal_uLong nLBRelations;
85 : };
86 :
87 : struct RelationMap
88 : {
89 : SvxSwFramePosString::StringId eStrId;
90 : SvxSwFramePosString::StringId eMirrorStrId;
91 : sal_uLong nLBRelation;
92 : sal_Int16 nRelation;
93 : };
94 :
95 : struct StringIdPair_Impl
96 : {
97 : SvxSwFramePosString::StringId eHori;
98 : SvxSwFramePosString::StringId eVert;
99 : };
100 :
101 : #define MAX_PERCENT_WIDTH 254L
102 : #define MAX_PERCENT_HEIGHT 254L
103 :
104 : #define LB_FRAME 0x00000001L // text region of the paragraph
105 : #define LB_PRTAREA 0x00000002L // text region of the paragraph + indentions
106 : #define LB_VERT_FRAME 0x00000004L // vertical text region of the paragraph
107 : #define LB_VERT_PRTAREA 0x00000008L // vertival text region of the paragraph + indentions
108 : #define LB_REL_FRM_LEFT 0x00000010L // left paragraph edge
109 : #define LB_REL_FRM_RIGHT 0x00000020L // right paragraph edge
110 :
111 : #define LB_REL_PG_LEFT 0x00000040L // left page edge
112 : #define LB_REL_PG_RIGHT 0x00000080L // right page edge
113 : #define LB_REL_PG_FRAME 0x00000100L // whole page
114 : #define LB_REL_PG_PRTAREA 0x00000200L // text region of the page
115 :
116 : #define LB_FLY_REL_PG_LEFT 0x00000400L // left frame edge
117 : #define LB_FLY_REL_PG_RIGHT 0x00000800L // right frame edge
118 : #define LB_FLY_REL_PG_FRAME 0x00001000L // whole frame
119 : #define LB_FLY_REL_PG_PRTAREA 0x00002000L // inside of the frame
120 :
121 : #define LB_REL_BASE 0x00010000L // character alignment Base
122 : #define LB_REL_CHAR 0x00020000L // character alignment Character
123 : #define LB_REL_ROW 0x00040000L // character alignment Row
124 :
125 : #define LB_FLY_VERT_FRAME 0x00100000L // vertical entire frame
126 : #define LB_FLY_VERT_PRTAREA 0x00200000L // vertical frame text area
127 :
128 : #define LB_VERT_LINE 0x00400000L // vertical text line
129 :
130 : static RelationMap aRelationMap[] =
131 : {
132 : {SwFPos::FRAME, SwFPos::FRAME, LB_FRAME, text::RelOrientation::FRAME},
133 : {SwFPos::PRTAREA, SwFPos::PRTAREA, LB_PRTAREA, text::RelOrientation::PRINT_AREA},
134 : {SwFPos::REL_PG_LEFT, SwFPos::MIR_REL_PG_LEFT, LB_REL_PG_LEFT, text::RelOrientation::PAGE_LEFT},
135 : {SwFPos::REL_PG_RIGHT, SwFPos::MIR_REL_PG_RIGHT, LB_REL_PG_RIGHT, text::RelOrientation::PAGE_RIGHT},
136 : {SwFPos::REL_FRM_LEFT, SwFPos::MIR_REL_FRM_LEFT, LB_REL_FRM_LEFT, text::RelOrientation::FRAME_LEFT},
137 : {SwFPos::REL_FRM_RIGHT, SwFPos::MIR_REL_FRM_RIGHT, LB_REL_FRM_RIGHT, text::RelOrientation::FRAME_RIGHT},
138 : {SwFPos::REL_PG_FRAME, SwFPos::REL_PG_FRAME, LB_REL_PG_FRAME, text::RelOrientation::PAGE_FRAME},
139 : {SwFPos::REL_PG_PRTAREA, SwFPos::REL_PG_PRTAREA, LB_REL_PG_PRTAREA, text::RelOrientation::PAGE_PRINT_AREA},
140 : {SwFPos::REL_CHAR, SwFPos::REL_CHAR, LB_REL_CHAR, text::RelOrientation::CHAR},
141 :
142 : {SwFPos::FLY_REL_PG_LEFT, SwFPos::FLY_MIR_REL_PG_LEFT, LB_FLY_REL_PG_LEFT, text::RelOrientation::PAGE_LEFT},
143 : {SwFPos::FLY_REL_PG_RIGHT, SwFPos::FLY_MIR_REL_PG_RIGHT, LB_FLY_REL_PG_RIGHT, text::RelOrientation::PAGE_RIGHT},
144 : {SwFPos::FLY_REL_PG_FRAME, SwFPos::FLY_REL_PG_FRAME, LB_FLY_REL_PG_FRAME, text::RelOrientation::PAGE_FRAME},
145 : {SwFPos::FLY_REL_PG_PRTAREA, SwFPos::FLY_REL_PG_PRTAREA, LB_FLY_REL_PG_PRTAREA, text::RelOrientation::PAGE_PRINT_AREA},
146 :
147 : {SwFPos::REL_BORDER, SwFPos::REL_BORDER, LB_VERT_FRAME, text::RelOrientation::FRAME},
148 : {SwFPos::REL_PRTAREA, SwFPos::REL_PRTAREA, LB_VERT_PRTAREA, text::RelOrientation::PRINT_AREA},
149 :
150 : {SwFPos::FLY_REL_PG_FRAME, SwFPos::FLY_REL_PG_FRAME, LB_FLY_VERT_FRAME, text::RelOrientation::FRAME},
151 : {SwFPos::FLY_REL_PG_PRTAREA, SwFPos::FLY_REL_PG_PRTAREA, LB_FLY_VERT_PRTAREA, text::RelOrientation::PRINT_AREA},
152 :
153 : {SwFPos::REL_LINE, SwFPos::REL_LINE, LB_VERT_LINE, text::RelOrientation::TEXT_LINE}
154 : };
155 :
156 : static RelationMap aAsCharRelationMap[] =
157 : {
158 : {SwFPos::REL_BASE, SwFPos::REL_BASE, LB_REL_BASE, text::RelOrientation::FRAME},
159 : {SwFPos::REL_CHAR, SwFPos::REL_CHAR, LB_REL_CHAR, text::RelOrientation::FRAME},
160 : {SwFPos::REL_ROW, SwFPos::REL_ROW, LB_REL_ROW, text::RelOrientation::FRAME}
161 : };
162 :
163 : // site anchored
164 : #define HORI_PAGE_REL (LB_REL_PG_FRAME|LB_REL_PG_PRTAREA|LB_REL_PG_LEFT| \
165 : LB_REL_PG_RIGHT)
166 :
167 : static FrmMap aHPageMap[] =
168 : {
169 : {SwFPos::LEFT, SwFPos::MIR_LEFT, text::HoriOrientation::LEFT, HORI_PAGE_REL},
170 : {SwFPos::RIGHT, SwFPos::MIR_RIGHT, text::HoriOrientation::RIGHT, HORI_PAGE_REL},
171 : {SwFPos::CENTER_HORI, SwFPos::CENTER_HORI, text::HoriOrientation::CENTER, HORI_PAGE_REL},
172 : {SwFPos::FROMLEFT, SwFPos::MIR_FROMLEFT, text::HoriOrientation::NONE, HORI_PAGE_REL}
173 : };
174 :
175 : static FrmMap aHPageHtmlMap[] =
176 : {
177 : {SwFPos::FROMLEFT, SwFPos::MIR_FROMLEFT, text::HoriOrientation::NONE, LB_REL_PG_FRAME}
178 : };
179 :
180 : #define VERT_PAGE_REL (LB_REL_PG_FRAME|LB_REL_PG_PRTAREA)
181 :
182 : static FrmMap aVPageMap[] =
183 : {
184 : {SwFPos::TOP, SwFPos::TOP, text::VertOrientation::TOP, VERT_PAGE_REL},
185 : {SwFPos::BOTTOM, SwFPos::BOTTOM, text::VertOrientation::BOTTOM, VERT_PAGE_REL},
186 : {SwFPos::CENTER_VERT, SwFPos::CENTER_VERT, text::VertOrientation::CENTER, VERT_PAGE_REL},
187 : {SwFPos::FROMTOP, SwFPos::FROMTOP, text::VertOrientation::NONE, VERT_PAGE_REL}
188 : };
189 :
190 : static FrmMap aVPageHtmlMap[] =
191 : {
192 : {SwFPos::FROMTOP, SwFPos::FROMTOP, text::VertOrientation::NONE, LB_REL_PG_FRAME}
193 : };
194 :
195 : // frame anchored
196 : #define HORI_FRAME_REL (LB_FLY_REL_PG_FRAME|LB_FLY_REL_PG_PRTAREA| \
197 : LB_FLY_REL_PG_LEFT|LB_FLY_REL_PG_RIGHT)
198 :
199 : static FrmMap aHFrameMap[] =
200 : {
201 : {SwFPos::LEFT, SwFPos::MIR_LEFT, text::HoriOrientation::LEFT, HORI_FRAME_REL},
202 : {SwFPos::RIGHT, SwFPos::MIR_RIGHT, text::HoriOrientation::RIGHT, HORI_FRAME_REL},
203 : {SwFPos::CENTER_HORI, SwFPos::CENTER_HORI, text::HoriOrientation::CENTER, HORI_FRAME_REL},
204 : {SwFPos::FROMLEFT, SwFPos::MIR_FROMLEFT, text::HoriOrientation::NONE, HORI_FRAME_REL}
205 : };
206 :
207 : static FrmMap aHFlyHtmlMap[] =
208 : {
209 : {SwFPos::LEFT, SwFPos::MIR_LEFT, text::HoriOrientation::LEFT, LB_FLY_REL_PG_FRAME},
210 : {SwFPos::FROMLEFT, SwFPos::MIR_FROMLEFT, text::HoriOrientation::NONE, LB_FLY_REL_PG_FRAME}
211 : };
212 :
213 : // own vertical alignment map for objects anchored to frame
214 : #define VERT_FRAME_REL (LB_FLY_VERT_FRAME|LB_FLY_VERT_PRTAREA)
215 :
216 : static FrmMap aVFrameMap[] =
217 : {
218 : {SwFPos::TOP, SwFPos::TOP, text::VertOrientation::TOP, VERT_FRAME_REL},
219 : {SwFPos::BOTTOM, SwFPos::BOTTOM, text::VertOrientation::BOTTOM, VERT_FRAME_REL},
220 : {SwFPos::CENTER_VERT, SwFPos::CENTER_VERT, text::VertOrientation::CENTER, VERT_FRAME_REL},
221 : {SwFPos::FROMTOP, SwFPos::FROMTOP, text::VertOrientation::NONE, VERT_FRAME_REL}
222 : };
223 :
224 : static FrmMap aVFlyHtmlMap[] =
225 : {
226 : {SwFPos::TOP, SwFPos::TOP, text::VertOrientation::TOP, LB_FLY_VERT_FRAME},
227 : {SwFPos::FROMTOP, SwFPos::FROMTOP, text::VertOrientation::NONE, LB_FLY_VERT_FRAME}
228 : };
229 :
230 : // paragraph anchored
231 : #define HORI_PARA_REL (LB_FRAME|LB_PRTAREA|LB_REL_PG_LEFT|LB_REL_PG_RIGHT| \
232 : LB_REL_PG_FRAME|LB_REL_PG_PRTAREA|LB_REL_FRM_LEFT| \
233 : LB_REL_FRM_RIGHT)
234 :
235 : static FrmMap aHParaMap[] =
236 : {
237 : {SwFPos::LEFT, SwFPos::MIR_LEFT, text::HoriOrientation::LEFT, HORI_PARA_REL},
238 : {SwFPos::RIGHT, SwFPos::MIR_RIGHT, text::HoriOrientation::RIGHT, HORI_PARA_REL},
239 : {SwFPos::CENTER_HORI, SwFPos::CENTER_HORI, text::HoriOrientation::CENTER, HORI_PARA_REL},
240 : {SwFPos::FROMLEFT, SwFPos::MIR_FROMLEFT, text::HoriOrientation::NONE, HORI_PARA_REL}
241 : };
242 :
243 : #define HTML_HORI_PARA_REL (LB_FRAME|LB_PRTAREA)
244 :
245 : static FrmMap aHParaHtmlMap[] =
246 : {
247 : {SwFPos::LEFT, SwFPos::LEFT, text::HoriOrientation::LEFT, HTML_HORI_PARA_REL},
248 : {SwFPos::RIGHT, SwFPos::RIGHT, text::HoriOrientation::RIGHT, HTML_HORI_PARA_REL}
249 : };
250 :
251 : static FrmMap aHParaHtmlAbsMap[] =
252 : {
253 : {SwFPos::LEFT, SwFPos::MIR_LEFT, text::HoriOrientation::LEFT, HTML_HORI_PARA_REL},
254 : {SwFPos::RIGHT, SwFPos::MIR_RIGHT, text::HoriOrientation::RIGHT, HTML_HORI_PARA_REL}
255 : };
256 :
257 : // allow vertical alignment at page areas
258 : #define VERT_PARA_REL (LB_VERT_FRAME|LB_VERT_PRTAREA| \
259 : LB_REL_PG_FRAME|LB_REL_PG_PRTAREA)
260 :
261 : static FrmMap aVParaMap[] =
262 : {
263 : {SwFPos::TOP, SwFPos::TOP, text::VertOrientation::TOP, VERT_PARA_REL},
264 : {SwFPos::BOTTOM, SwFPos::BOTTOM, text::VertOrientation::BOTTOM, VERT_PARA_REL},
265 : {SwFPos::CENTER_VERT, SwFPos::CENTER_VERT, text::VertOrientation::CENTER, VERT_PARA_REL},
266 : {SwFPos::FROMTOP, SwFPos::FROMTOP, text::VertOrientation::NONE, VERT_PARA_REL}
267 : };
268 :
269 : static FrmMap aVParaHtmlMap[] =
270 : {
271 : {SwFPos::TOP, SwFPos::TOP, text::VertOrientation::TOP, LB_VERT_PRTAREA}
272 : };
273 :
274 : // anchored relative to the character
275 : #define HORI_CHAR_REL (LB_FRAME|LB_PRTAREA|LB_REL_PG_LEFT|LB_REL_PG_RIGHT| \
276 : LB_REL_PG_FRAME|LB_REL_PG_PRTAREA|LB_REL_FRM_LEFT| \
277 : LB_REL_FRM_RIGHT|LB_REL_CHAR)
278 :
279 : static FrmMap aHCharMap[] =
280 : {
281 : {SwFPos::LEFT, SwFPos::MIR_LEFT, text::HoriOrientation::LEFT, HORI_CHAR_REL},
282 : {SwFPos::RIGHT, SwFPos::MIR_RIGHT, text::HoriOrientation::RIGHT, HORI_CHAR_REL},
283 : {SwFPos::CENTER_HORI, SwFPos::CENTER_HORI, text::HoriOrientation::CENTER, HORI_CHAR_REL},
284 : {SwFPos::FROMLEFT, SwFPos::MIR_FROMLEFT, text::HoriOrientation::NONE, HORI_CHAR_REL}
285 : };
286 :
287 : #define HTML_HORI_CHAR_REL (LB_FRAME|LB_PRTAREA|LB_REL_CHAR)
288 :
289 : static FrmMap aHCharHtmlMap[] =
290 : {
291 : {SwFPos::LEFT, SwFPos::LEFT, text::HoriOrientation::LEFT, HTML_HORI_CHAR_REL},
292 : {SwFPos::RIGHT, SwFPos::RIGHT, text::HoriOrientation::RIGHT, HTML_HORI_CHAR_REL}
293 : };
294 :
295 : static FrmMap aHCharHtmlAbsMap[] =
296 : {
297 : {SwFPos::LEFT, SwFPos::MIR_LEFT, text::HoriOrientation::LEFT, LB_PRTAREA|LB_REL_CHAR},
298 : {SwFPos::RIGHT, SwFPos::MIR_RIGHT, text::HoriOrientation::RIGHT, LB_PRTAREA},
299 : {SwFPos::FROMLEFT, SwFPos::MIR_FROMLEFT, text::HoriOrientation::NONE, LB_REL_PG_FRAME}
300 : };
301 :
302 : // allow vertical alignment at page areas
303 : #define VERT_CHAR_REL (LB_VERT_FRAME|LB_VERT_PRTAREA| \
304 : LB_REL_PG_FRAME|LB_REL_PG_PRTAREA)
305 :
306 : static FrmMap aVCharMap[] =
307 : {
308 : // introduce mappings for new vertical alignment at top of line <LB_VERT_LINE>
309 : // and correct mapping for vertical alignment at character for position <FROM_BOTTOM>
310 : // Note: Because of these adjustments the map becomes ambigous in its values
311 : // <eStrId>/<eMirrorStrId> and <nAlign>. These ambiguities are considered
312 : // in the methods <SwFrmPage::FillRelLB(..)>, <SwFrmPage::GetAlignment(..)>
313 : // and <SwFrmPage::FillPosLB(..)>
314 : {SwFPos::TOP, SwFPos::TOP, text::VertOrientation::TOP, VERT_CHAR_REL|LB_REL_CHAR},
315 : {SwFPos::BOTTOM, SwFPos::BOTTOM, text::VertOrientation::BOTTOM, VERT_CHAR_REL|LB_REL_CHAR},
316 : {SwFPos::BELOW, SwFPos::BELOW, text::VertOrientation::CHAR_BOTTOM, LB_REL_CHAR},
317 : {SwFPos::CENTER_VERT, SwFPos::CENTER_VERT, text::VertOrientation::CENTER, VERT_CHAR_REL|LB_REL_CHAR},
318 : {SwFPos::FROMTOP, SwFPos::FROMTOP, text::VertOrientation::NONE, VERT_CHAR_REL},
319 : {SwFPos::FROMBOTTOM, SwFPos::FROMBOTTOM, text::VertOrientation::NONE, LB_REL_CHAR|LB_VERT_LINE},
320 : {SwFPos::TOP, SwFPos::TOP, text::VertOrientation::LINE_TOP, LB_VERT_LINE},
321 : {SwFPos::BOTTOM, SwFPos::BOTTOM, text::VertOrientation::LINE_BOTTOM, LB_VERT_LINE},
322 : {SwFPos::CENTER_VERT, SwFPos::CENTER_VERT, text::VertOrientation::LINE_CENTER, LB_VERT_LINE}
323 : };
324 :
325 : static FrmMap aVCharHtmlMap[] =
326 : {
327 : {SwFPos::BELOW, SwFPos::BELOW, text::VertOrientation::CHAR_BOTTOM, LB_REL_CHAR}
328 : };
329 :
330 : static FrmMap aVCharHtmlAbsMap[] =
331 : {
332 : {SwFPos::TOP, SwFPos::TOP, text::VertOrientation::TOP, LB_REL_CHAR},
333 : {SwFPos::BELOW, SwFPos::BELOW, text::VertOrientation::CHAR_BOTTOM, LB_REL_CHAR}
334 : };
335 :
336 : // anchored as character
337 : static FrmMap aVAsCharMap[] =
338 : {
339 : {SwFPos::TOP, SwFPos::TOP, text::VertOrientation::TOP, LB_REL_BASE},
340 : {SwFPos::BOTTOM, SwFPos::BOTTOM, text::VertOrientation::BOTTOM, LB_REL_BASE},
341 : {SwFPos::CENTER_VERT, SwFPos::CENTER_VERT, text::VertOrientation::CENTER, LB_REL_BASE},
342 :
343 : {SwFPos::TOP, SwFPos::TOP, text::VertOrientation::CHAR_TOP, LB_REL_CHAR},
344 : {SwFPos::BOTTOM, SwFPos::BOTTOM, text::VertOrientation::CHAR_BOTTOM, LB_REL_CHAR},
345 : {SwFPos::CENTER_VERT, SwFPos::CENTER_VERT, text::VertOrientation::CHAR_CENTER, LB_REL_CHAR},
346 :
347 : {SwFPos::TOP, SwFPos::TOP, text::VertOrientation::LINE_TOP, LB_REL_ROW},
348 : {SwFPos::BOTTOM, SwFPos::BOTTOM, text::VertOrientation::LINE_BOTTOM, LB_REL_ROW},
349 : {SwFPos::CENTER_VERT, SwFPos::CENTER_VERT, text::VertOrientation::LINE_CENTER, LB_REL_ROW},
350 :
351 : {SwFPos::FROMBOTTOM, SwFPos::FROMBOTTOM, text::VertOrientation::NONE, LB_REL_BASE}
352 : };
353 :
354 : static FrmMap aVAsCharHtmlMap[] =
355 : {
356 : {SwFPos::TOP, SwFPos::TOP, text::VertOrientation::TOP, LB_REL_BASE},
357 : {SwFPos::CENTER_VERT, SwFPos::CENTER_VERT, text::VertOrientation::CENTER, LB_REL_BASE},
358 :
359 : {SwFPos::TOP, SwFPos::TOP, text::VertOrientation::CHAR_TOP, LB_REL_CHAR},
360 :
361 : {SwFPos::TOP, SwFPos::TOP, text::VertOrientation::LINE_TOP, LB_REL_ROW},
362 : {SwFPos::BOTTOM, SwFPos::BOTTOM, text::VertOrientation::LINE_BOTTOM, LB_REL_ROW},
363 : {SwFPos::CENTER_VERT, SwFPos::CENTER_VERT, text::VertOrientation::LINE_CENTER, LB_REL_ROW}
364 : };
365 :
366 : const sal_uInt16 SwFrmPage::aPageRg[] = {
367 : RES_FRM_SIZE, RES_FRM_SIZE,
368 : RES_VERT_ORIENT, RES_ANCHOR,
369 : RES_COL, RES_COL,
370 : RES_FOLLOW_TEXT_FLOW, RES_FOLLOW_TEXT_FLOW,
371 : 0
372 : };
373 : const sal_uInt16 SwFrmAddPage::aAddPgRg[] = {
374 : RES_PROTECT, RES_PROTECT,
375 : RES_PRINT, RES_PRINT,
376 : FN_SET_FRM_NAME, FN_SET_FRM_NAME,
377 : FN_SET_FRM_ALT_NAME, FN_SET_FRM_ALT_NAME,
378 : 0
379 : };
380 :
381 0 : static size_t lcl_GetFrmMapCount( const FrmMap* pMap)
382 : {
383 0 : if ( pMap )
384 : {
385 0 : if( pMap == aVParaHtmlMap)
386 0 : return SAL_N_ELEMENTS(aVParaHtmlMap);
387 0 : if( pMap == aVAsCharHtmlMap)
388 0 : return SAL_N_ELEMENTS(aVAsCharHtmlMap);
389 0 : if( pMap == aHParaHtmlMap)
390 0 : return SAL_N_ELEMENTS(aHParaHtmlMap);
391 0 : if( pMap == aHParaHtmlAbsMap)
392 0 : return SAL_N_ELEMENTS(aHParaHtmlAbsMap);
393 0 : if ( pMap == aVPageMap )
394 0 : return SAL_N_ELEMENTS(aVPageMap);
395 0 : if ( pMap == aVPageHtmlMap )
396 0 : return SAL_N_ELEMENTS(aVPageHtmlMap);
397 0 : if ( pMap == aVAsCharMap )
398 0 : return SAL_N_ELEMENTS(aVAsCharMap);
399 0 : if ( pMap == aVParaMap )
400 0 : return SAL_N_ELEMENTS(aVParaMap);
401 0 : if ( pMap == aHParaMap )
402 0 : return SAL_N_ELEMENTS(aHParaMap);
403 0 : if ( pMap == aHFrameMap )
404 0 : return SAL_N_ELEMENTS(aHFrameMap);
405 0 : if ( pMap == aVFrameMap )
406 0 : return SAL_N_ELEMENTS(aVFrameMap);
407 0 : if ( pMap == aHCharMap )
408 0 : return SAL_N_ELEMENTS(aHCharMap);
409 0 : if ( pMap == aHCharHtmlMap )
410 0 : return SAL_N_ELEMENTS(aHCharHtmlMap);
411 0 : if ( pMap == aHCharHtmlAbsMap )
412 0 : return SAL_N_ELEMENTS(aHCharHtmlAbsMap);
413 0 : if ( pMap == aVCharMap )
414 0 : return SAL_N_ELEMENTS(aVCharMap);
415 0 : if ( pMap == aVCharHtmlMap )
416 0 : return SAL_N_ELEMENTS(aVCharHtmlMap);
417 0 : if ( pMap == aVCharHtmlAbsMap )
418 0 : return SAL_N_ELEMENTS(aVCharHtmlAbsMap);
419 0 : if ( pMap == aHPageHtmlMap )
420 0 : return SAL_N_ELEMENTS(aHPageHtmlMap);
421 0 : if ( pMap == aHFlyHtmlMap )
422 0 : return SAL_N_ELEMENTS(aHFlyHtmlMap);
423 0 : if ( pMap == aVFlyHtmlMap )
424 0 : return SAL_N_ELEMENTS(aVFlyHtmlMap);
425 0 : return SAL_N_ELEMENTS(aHPageMap);
426 : }
427 0 : return 0;
428 : }
429 :
430 0 : static void lcl_InsertVectors(ListBox& rBox,
431 : const ::std::vector< OUString >& rPrev, const ::std::vector< OUString >& rThis,
432 : const ::std::vector< OUString >& rNext, const ::std::vector< OUString >& rRemain)
433 : {
434 0 : ::std::vector< OUString >::const_iterator aIt;
435 0 : sal_Int32 nEntry = 0;
436 0 : for(aIt = rPrev.begin(); aIt != rPrev.end(); ++aIt)
437 0 : nEntry = rBox.InsertEntry(*aIt);
438 0 : for(aIt = rThis.begin(); aIt != rThis.end(); ++aIt)
439 0 : nEntry = rBox.InsertEntry(*aIt);
440 0 : for(aIt = rNext.begin(); aIt != rNext.end(); ++aIt)
441 0 : nEntry = rBox.InsertEntry(*aIt);
442 0 : rBox.SetSeparatorPos(nEntry);
443 : //now insert all strings sorted
444 0 : const sal_Int32 nStartPos = rBox.GetEntryCount();
445 :
446 0 : for(aIt = rPrev.begin(); aIt != rPrev.end(); ++aIt)
447 0 : ::InsertStringSorted(*aIt, rBox, nStartPos );
448 0 : for(aIt = rThis.begin(); aIt != rThis.end(); ++aIt)
449 0 : ::InsertStringSorted(*aIt, rBox, nStartPos );
450 0 : for(aIt = rNext.begin(); aIt != rNext.end(); ++aIt)
451 0 : ::InsertStringSorted(*aIt, rBox, nStartPos );
452 0 : for(aIt = rRemain.begin(); aIt != rRemain.end(); ++aIt)
453 0 : ::InsertStringSorted(*aIt, rBox, nStartPos );
454 0 : }
455 :
456 : // --> OD 2009-08-31 #mongolianlayout#
457 : // add input parameter
458 0 : static SvxSwFramePosString::StringId lcl_ChangeResIdToVerticalOrRTL(SvxSwFramePosString::StringId eStringId, bool bVertical, bool bVerticalL2R, bool bRTL)
459 : {
460 : //special handling of STR_FROMLEFT
461 0 : if ( SwFPos::FROMLEFT == eStringId )
462 : {
463 : eStringId = bVertical
464 : ? ( bRTL
465 : ? SwFPos::FROMBOTTOM
466 : : SwFPos::FROMTOP )
467 : : ( bRTL
468 : ? SwFPos::FROMRIGHT
469 0 : : SwFPos::FROMLEFT );
470 0 : return eStringId;
471 : }
472 : // --> OD 2009-08-31 #mongolianlayout#
473 : // special handling of STR_FROMTOP in case of mongolianlayout (vertical left-to-right)
474 0 : if ( SwFPos::FROMTOP == eStringId &&
475 0 : bVertical && bVerticalL2R )
476 : {
477 0 : eStringId = SwFPos::FROMLEFT;
478 0 : return eStringId;
479 : }
480 0 : if ( bVertical )
481 : {
482 : //exchange horizontal strings with vertical strings and vice versa
483 : static const StringIdPair_Impl aHoriIds[] =
484 : {
485 : {SwFPos::LEFT, SwFPos::TOP},
486 : {SwFPos::RIGHT, SwFPos::BOTTOM},
487 : {SwFPos::CENTER_HORI, SwFPos::CENTER_VERT},
488 : {SwFPos::FROMTOP, SwFPos::FROMRIGHT},
489 : {SwFPos::REL_PG_LEFT, SwFPos::REL_PG_TOP},
490 : {SwFPos::REL_PG_RIGHT, SwFPos::REL_PG_BOTTOM} ,
491 : {SwFPos::REL_FRM_LEFT, SwFPos::REL_FRM_TOP},
492 : {SwFPos::REL_FRM_RIGHT, SwFPos::REL_FRM_BOTTOM}
493 : };
494 : static const StringIdPair_Impl aVertIds[] =
495 : {
496 : {SwFPos::TOP, SwFPos::RIGHT},
497 : {SwFPos::BOTTOM, SwFPos::LEFT },
498 : {SwFPos::CENTER_VERT, SwFPos::CENTER_HORI},
499 : {SwFPos::FROMTOP, SwFPos::FROMRIGHT },
500 : {SwFPos::REL_PG_TOP, SwFPos::REL_PG_LEFT },
501 : {SwFPos::REL_PG_BOTTOM, SwFPos::REL_PG_RIGHT } ,
502 : {SwFPos::REL_FRM_TOP, SwFPos::REL_FRM_LEFT },
503 : {SwFPos::REL_FRM_BOTTOM, SwFPos::REL_FRM_RIGHT }
504 : };
505 : // --> OD 2009-08-31 #monglianlayout#
506 : static const StringIdPair_Impl aVertL2RIds[] =
507 : {
508 : {SwFPos::TOP, SwFPos::LEFT },
509 : {SwFPos::BOTTOM, SwFPos::RIGHT },
510 : {SwFPos::CENTER_VERT, SwFPos::CENTER_HORI },
511 : {SwFPos::FROMTOP, SwFPos::FROMLEFT },
512 : {SwFPos::REL_PG_TOP, SwFPos::REL_PG_LEFT },
513 : {SwFPos::REL_PG_BOTTOM, SwFPos::REL_PG_RIGHT } ,
514 : {SwFPos::REL_FRM_TOP, SwFPos::REL_FRM_LEFT },
515 : {SwFPos::REL_FRM_BOTTOM, SwFPos::REL_FRM_RIGHT }
516 : };
517 0 : for(size_t nIndex = 0; nIndex < SAL_N_ELEMENTS(aHoriIds); ++nIndex)
518 : {
519 0 : if(aHoriIds[nIndex].eHori == eStringId)
520 : {
521 0 : eStringId = aHoriIds[nIndex].eVert;
522 0 : return eStringId;
523 : }
524 : }
525 0 : for(size_t nIndex = 0; nIndex < SAL_N_ELEMENTS(aVertIds); ++nIndex)
526 : {
527 : // --> OD 2009-08-31 #mongolianlayout#
528 0 : if ( !bVerticalL2R )
529 : {
530 0 : if(aVertIds[nIndex].eHori == eStringId)
531 : {
532 0 : eStringId = aVertIds[nIndex].eVert;
533 0 : break;
534 : }
535 : }
536 : else
537 : {
538 0 : if(aVertL2RIds[nIndex].eHori == eStringId)
539 : {
540 0 : eStringId = aVertL2RIds[nIndex].eVert;
541 0 : break;
542 : }
543 : }
544 : }
545 : }
546 0 : return eStringId;
547 : }
548 :
549 : // helper method in order to determine all possible
550 : // listbox relations in a relation map for a given relation
551 0 : static sal_uLong lcl_GetLBRelationsForRelations( const sal_Int16 _nRel )
552 : {
553 0 : sal_uLong nLBRelations = 0L;
554 :
555 0 : const size_t nRelMapSize = SAL_N_ELEMENTS(aRelationMap);
556 0 : for ( size_t nRelMapPos = 0; nRelMapPos < nRelMapSize; ++nRelMapPos )
557 : {
558 0 : if ( aRelationMap[nRelMapPos].nRelation == _nRel )
559 : {
560 0 : nLBRelations |= aRelationMap[nRelMapPos].nLBRelation;
561 : }
562 : }
563 :
564 0 : return nLBRelations;
565 : }
566 :
567 : // helper method on order to determine all possible
568 : // listbox relations in a relation map for a given string ID
569 0 : static sal_uLong lcl_GetLBRelationsForStrID( const FrmMap* _pMap,
570 : const SvxSwFramePosString::StringId _eStrId,
571 : const bool _bUseMirrorStr )
572 : {
573 0 : sal_uLong nLBRelations = 0L;
574 :
575 0 : size_t nRelMapSize = lcl_GetFrmMapCount( _pMap );
576 0 : for ( size_t nRelMapPos = 0; nRelMapPos < nRelMapSize; ++nRelMapPos )
577 : {
578 0 : if ( ( !_bUseMirrorStr && _pMap[nRelMapPos].eStrId == _eStrId ) ||
579 0 : ( _bUseMirrorStr && _pMap[nRelMapPos].eMirrorStrId == _eStrId ) )
580 : {
581 0 : nLBRelations |= _pMap[nRelMapPos].nLBRelations;
582 : }
583 : }
584 :
585 0 : return nLBRelations;
586 : }
587 :
588 : // standard frame TabPage
589 : namespace
590 : {
591 0 : void HandleAutoCB( bool _bChecked, FixedText& _rFT_man, FixedText& _rFT_auto, MetricField& _rPF_Edit)
592 : {
593 0 : _rFT_man.Show( !_bChecked );
594 0 : _rFT_auto.Show( _bChecked );
595 0 : OUString accName = _bChecked ? _rFT_auto.GetText() : _rFT_man.GetText();
596 0 : _rPF_Edit.SetAccessibleName(accName);
597 0 : }
598 : }
599 :
600 0 : SwFrmPage::SwFrmPage(vcl::Window *pParent, const SfxItemSet &rSet)
601 : : SfxTabPage(pParent, "FrmTypePage",
602 : "modules/swriter/ui/frmtypepage.ui", &rSet)
603 : ,
604 : bAtHorzPosModified( false ),
605 : bAtVertPosModified( false ),
606 : bFormat(false),
607 : bNew(true),
608 : bNoModifyHdl(true),
609 : bIsVerticalFrame(false),
610 : bIsVerticalL2R(false),
611 : bIsInRightToLeft(false),
612 : bHtmlMode(false),
613 : nHtmlMode(0),
614 : nUpperBorder(0),
615 : nLowerBorder(0),
616 : fWidthHeightRatio(1.0),
617 : mpToCharContentPos( NULL ),
618 :
619 : nOldH(text::HoriOrientation::CENTER),
620 : nOldHRel(text::RelOrientation::FRAME),
621 : nOldV(text::VertOrientation::TOP),
622 : nOldVRel(text::RelOrientation::PRINT_AREA),
623 : pVMap( 0 ),
624 : pHMap( 0 ),
625 : m_bAllowVertPositioning( true ),
626 : m_bIsMathOLE( false ),
627 0 : m_bIsMathBaselineAlignment( true )
628 : {
629 0 : get(m_pWidthFT, "widthft");
630 0 : get(m_pWidthAutoFT, "autowidthft");
631 0 : m_aWidthED.set(get<MetricField>("width"));
632 0 : get(m_pRelWidthCB, "relwidth");
633 0 : get(m_pRelWidthRelationLB, "relwidthrelation");
634 0 : get(m_pAutoWidthCB, "autowidth");
635 :
636 0 : get(m_pHeightFT, "heightft");
637 0 : get(m_pHeightAutoFT, "autoheightft");
638 0 : m_aHeightED.set(get<MetricField>("height"));
639 0 : get(m_pRelHeightCB, "relheight");
640 0 : get(m_pRelHeightRelationLB, "relheightrelation");
641 0 : get(m_pAutoHeightCB, "autoheight");
642 :
643 0 : get(m_pFixedRatioCB, "ratio");
644 0 : get(m_pRealSizeBT, "origsize");
645 :
646 0 : get(m_pAnchorFrame, "anchorframe");
647 0 : get(m_pAnchorAtPageRB, "topage");
648 0 : get(m_pAnchorAtParaRB, "topara");
649 0 : get(m_pAnchorAtCharRB, "tochar");
650 0 : get(m_pAnchorAsCharRB, "aschar");
651 0 : get(m_pAnchorAtFrameRB, "toframe");
652 :
653 0 : get(m_pHorizontalFT, "horiposft");
654 0 : get(m_pHorizontalDLB, "horipos");
655 0 : get(m_pAtHorzPosFT, "horibyft");
656 0 : get(m_pAtHorzPosED, "byhori");
657 0 : get(m_pHoriRelationFT, "horitoft");
658 0 : get(m_pHoriRelationLB, "horianchor");
659 :
660 0 : get(m_pMirrorPagesCB, "mirror");
661 :
662 0 : get(m_pVerticalFT, "vertposft");
663 0 : get(m_pVerticalDLB, "vertpos");
664 0 : get(m_pAtVertPosFT, "vertbyft");
665 0 : get(m_pAtVertPosED, "byvert");
666 0 : get(m_pVertRelationFT, "verttoft");
667 0 : get(m_pVertRelationLB, "vertanchor");
668 :
669 0 : get(m_pFollowTextFlowCB, "followtextflow");
670 0 : get(m_pExampleWN, "preview");
671 :
672 0 : m_pAtHorzPosED->set_width_request(m_pAtHorzPosED->GetOptimalSize().Width());
673 0 : m_pAtHorzPosED->set_width_request(m_pAtVertPosED->GetOptimalSize().Width());
674 :
675 0 : setOptimalFrmWidth();
676 0 : setOptimalRelWidth();
677 :
678 0 : SetExchangeSupport();
679 :
680 0 : Link<> aLk = LINK(this, SwFrmPage, RangeModifyHdl);
681 0 : m_aWidthED.SetLoseFocusHdl( aLk );
682 0 : m_aHeightED.SetLoseFocusHdl( aLk );
683 0 : m_pAtHorzPosED->SetLoseFocusHdl( aLk );
684 0 : m_pAtVertPosED->SetLoseFocusHdl( aLk );
685 0 : m_pFollowTextFlowCB->SetClickHdl( aLk );
686 :
687 0 : aLk = LINK(this, SwFrmPage, ModifyHdl);
688 0 : m_aWidthED.SetModifyHdl( aLk );
689 0 : m_aHeightED.SetModifyHdl( aLk );
690 0 : m_pAtHorzPosED->SetModifyHdl( aLk );
691 0 : m_pAtVertPosED->SetModifyHdl( aLk );
692 :
693 0 : aLk = LINK(this, SwFrmPage, AnchorTypeHdl);
694 0 : m_pAnchorAtPageRB->SetClickHdl( aLk );
695 0 : m_pAnchorAtParaRB->SetClickHdl( aLk );
696 0 : m_pAnchorAtCharRB->SetClickHdl( aLk );
697 0 : m_pAnchorAsCharRB->SetClickHdl( aLk );
698 0 : m_pAnchorAtFrameRB->SetClickHdl( aLk );
699 :
700 0 : m_pHorizontalDLB->SetSelectHdl(LINK(this, SwFrmPage, PosHdl));
701 0 : m_pVerticalDLB-> SetSelectHdl(LINK(this, SwFrmPage, PosHdl));
702 :
703 0 : m_pHoriRelationLB->SetSelectHdl(LINK(this, SwFrmPage, RelHdl));
704 0 : m_pVertRelationLB->SetSelectHdl(LINK(this, SwFrmPage, RelHdl));
705 :
706 0 : m_pMirrorPagesCB->SetClickHdl(LINK(this, SwFrmPage, MirrorHdl));
707 :
708 0 : aLk = LINK(this, SwFrmPage, RelSizeClickHdl);
709 0 : m_pRelWidthCB->SetClickHdl( aLk );
710 0 : m_pRelHeightCB->SetClickHdl( aLk );
711 :
712 0 : m_pAutoWidthCB->SetClickHdl( LINK( this, SwFrmPage, AutoWidthClickHdl ) );
713 0 : m_pAutoHeightCB->SetClickHdl( LINK( this, SwFrmPage, AutoHeightClickHdl ) );
714 0 : }
715 :
716 0 : SwFrmPage::~SwFrmPage()
717 : {
718 0 : disposeOnce();
719 0 : }
720 :
721 0 : void SwFrmPage::dispose()
722 : {
723 0 : m_pWidthFT.clear();
724 0 : m_pWidthAutoFT.clear();
725 0 : m_pRelWidthCB.clear();
726 0 : m_pRelWidthRelationLB.clear();
727 0 : m_pAutoWidthCB.clear();
728 0 : m_pHeightFT.clear();
729 0 : m_pHeightAutoFT.clear();
730 0 : m_pRelHeightCB.clear();
731 0 : m_pRelHeightRelationLB.clear();
732 0 : m_pAutoHeightCB.clear();
733 0 : m_pFixedRatioCB.clear();
734 0 : m_pRealSizeBT.clear();
735 0 : m_pAnchorFrame.clear();
736 0 : m_pAnchorAtPageRB.clear();
737 0 : m_pAnchorAtParaRB.clear();
738 0 : m_pAnchorAtCharRB.clear();
739 0 : m_pAnchorAsCharRB.clear();
740 0 : m_pAnchorAtFrameRB.clear();
741 0 : m_pHorizontalFT.clear();
742 0 : m_pHorizontalDLB.clear();
743 0 : m_pAtHorzPosFT.clear();
744 0 : m_pAtHorzPosED.clear();
745 0 : m_pHoriRelationFT.clear();
746 0 : m_pHoriRelationLB.clear();
747 0 : m_pMirrorPagesCB.clear();
748 0 : m_pVerticalFT.clear();
749 0 : m_pVerticalDLB.clear();
750 0 : m_pAtVertPosFT.clear();
751 0 : m_pAtVertPosED.clear();
752 0 : m_pVertRelationFT.clear();
753 0 : m_pVertRelationLB.clear();
754 0 : m_pFollowTextFlowCB.clear();
755 0 : m_pExampleWN.clear();
756 0 : SfxTabPage::dispose();
757 0 : }
758 :
759 : namespace
760 : {
761 : struct FrmMaps
762 : {
763 : FrmMap *pMap;
764 : size_t nCount;
765 : };
766 : }
767 :
768 0 : void SwFrmPage::setOptimalFrmWidth()
769 : {
770 : const FrmMaps aMaps[] = {
771 : { aHPageMap, SAL_N_ELEMENTS(aHPageMap) },
772 : { aHPageHtmlMap, SAL_N_ELEMENTS(aHPageHtmlMap) },
773 : { aVPageMap, SAL_N_ELEMENTS(aVPageMap) },
774 : { aVPageHtmlMap, SAL_N_ELEMENTS(aVPageHtmlMap) },
775 : { aHFrameMap, SAL_N_ELEMENTS(aHFrameMap) },
776 : { aHFlyHtmlMap, SAL_N_ELEMENTS(aHFlyHtmlMap) },
777 : { aVFrameMap, SAL_N_ELEMENTS(aVFrameMap) },
778 : { aVFlyHtmlMap, SAL_N_ELEMENTS(aVFrameMap) },
779 : { aHParaMap, SAL_N_ELEMENTS(aHParaMap) },
780 : { aHParaHtmlMap, SAL_N_ELEMENTS(aHParaHtmlMap) },
781 : { aHParaHtmlAbsMap, SAL_N_ELEMENTS(aHParaHtmlAbsMap) },
782 : { aVParaMap, SAL_N_ELEMENTS(aVParaMap) },
783 : { aVParaHtmlMap, SAL_N_ELEMENTS(aVParaHtmlMap) },
784 : { aHCharMap, SAL_N_ELEMENTS(aHCharMap) },
785 : { aHCharHtmlMap, SAL_N_ELEMENTS(aHCharHtmlMap) },
786 : { aHCharHtmlAbsMap, SAL_N_ELEMENTS(aHCharHtmlAbsMap) },
787 : { aVCharMap, SAL_N_ELEMENTS(aVCharMap) },
788 : { aVCharHtmlMap, SAL_N_ELEMENTS(aVCharHtmlMap) },
789 : { aVCharHtmlAbsMap, SAL_N_ELEMENTS(aVCharHtmlAbsMap) },
790 : { aVAsCharMap, SAL_N_ELEMENTS(aVAsCharMap) },
791 : { aVAsCharHtmlMap, SAL_N_ELEMENTS(aVAsCharHtmlMap) }
792 0 : };
793 :
794 0 : std::vector<SvxSwFramePosString::StringId> aFrames;
795 0 : for (size_t i = 0; i < SAL_N_ELEMENTS(aMaps); ++i)
796 : {
797 0 : for (size_t j = 0; j < aMaps[i].nCount; ++j)
798 : {
799 0 : aFrames.push_back(aMaps[i].pMap[j].eStrId);
800 0 : aFrames.push_back(aMaps[i].pMap[j].eMirrorStrId);
801 : }
802 : }
803 :
804 0 : std::sort(aFrames.begin(), aFrames.end());
805 0 : aFrames.erase(std::unique(aFrames.begin(), aFrames.end()), aFrames.end());
806 :
807 0 : for (std::vector<SvxSwFramePosString::StringId>::const_iterator aI = aFrames.begin(), aEnd = aFrames.end();
808 : aI != aEnd; ++aI)
809 : {
810 0 : m_pHorizontalDLB->InsertEntry(aFramePosString.GetString(*aI));
811 : }
812 :
813 0 : Size aBiggest(m_pHorizontalDLB->GetOptimalSize());
814 0 : m_pHorizontalDLB->set_width_request(aBiggest.Width());
815 0 : m_pVerticalDLB->set_width_request(aBiggest.Width());
816 0 : m_pHorizontalDLB->Clear();
817 0 : }
818 :
819 : namespace
820 : {
821 : struct RelationMaps
822 : {
823 : RelationMap *pMap;
824 : size_t nCount;
825 : };
826 : }
827 :
828 0 : void SwFrmPage::setOptimalRelWidth()
829 : {
830 : const RelationMaps aMaps[] = {
831 : { aRelationMap, SAL_N_ELEMENTS(aRelationMap) },
832 : { aAsCharRelationMap, SAL_N_ELEMENTS(aAsCharRelationMap) }
833 0 : };
834 :
835 0 : std::vector<SvxSwFramePosString::StringId> aRels;
836 0 : for (size_t i = 0; i < SAL_N_ELEMENTS(aMaps); ++i)
837 : {
838 0 : for (size_t j = 0; j < aMaps[i].nCount; ++j)
839 : {
840 0 : aRels.push_back(aMaps[i].pMap[j].eStrId);
841 0 : aRels.push_back(aMaps[i].pMap[j].eMirrorStrId);
842 : }
843 : }
844 :
845 0 : std::sort(aRels.begin(), aRels.end());
846 0 : aRels.erase(std::unique(aRels.begin(), aRels.end()), aRels.end());
847 :
848 0 : for (std::vector<SvxSwFramePosString::StringId>::const_iterator aI = aRels.begin(), aEnd = aRels.end();
849 : aI != aEnd; ++aI)
850 : {
851 0 : m_pHoriRelationLB->InsertEntry(aFramePosString.GetString(*aI));
852 : }
853 :
854 0 : Size aBiggest(m_pHoriRelationLB->GetOptimalSize());
855 0 : m_pHoriRelationLB->set_width_request(aBiggest.Width());
856 0 : m_pVertRelationLB->set_width_request(aBiggest.Width());
857 0 : m_pRelWidthRelationLB->set_width_request(aBiggest.Width());
858 0 : m_pRelHeightRelationLB->set_width_request(aBiggest.Width());
859 0 : m_pHoriRelationLB->Clear();
860 0 : }
861 :
862 0 : VclPtr<SfxTabPage> SwFrmPage::Create(vcl::Window *pParent, const SfxItemSet *rSet)
863 : {
864 0 : return VclPtr<SwFrmPage>::Create( pParent, *rSet );
865 : }
866 :
867 0 : void SwFrmPage::EnableGraficMode()
868 : {
869 : // i#39692 - mustn't be called more than once
870 0 : if(!m_pRealSizeBT->IsVisible())
871 : {
872 0 : m_pWidthFT->Show();
873 0 : m_pWidthAutoFT->Hide();
874 0 : m_pAutoHeightCB->Hide();
875 :
876 0 : m_pHeightFT->Show();
877 0 : m_pHeightAutoFT->Hide();
878 0 : m_pAutoWidthCB->Hide();
879 :
880 0 : m_pRealSizeBT->Show();
881 : }
882 0 : }
883 :
884 0 : SwWrtShell *SwFrmPage::getFrmDlgParentShell()
885 : {
886 0 : return static_cast<SwFrmDlg*>(GetParentDialog())->GetWrtShell();
887 : }
888 :
889 0 : void SwFrmPage::Reset( const SfxItemSet *rSet )
890 : {
891 : SwWrtShell* pSh = bFormat ? ::GetActiveWrtShell() :
892 0 : getFrmDlgParentShell();
893 :
894 0 : nHtmlMode = ::GetHtmlMode(pSh->GetView().GetDocShell());
895 0 : bHtmlMode = (nHtmlMode & HTMLMODE_ON) != 0;
896 :
897 0 : FieldUnit aMetric = ::GetDfltMetric(bHtmlMode);
898 0 : m_aWidthED.SetMetric(aMetric);
899 0 : m_aHeightED.SetMetric(aMetric);
900 0 : SetMetric( *m_pAtHorzPosED, aMetric );
901 0 : SetMetric( *m_pAtVertPosED, aMetric );
902 :
903 0 : const SfxPoolItem* pItem = NULL;
904 0 : const SwFormatAnchor& rAnchor = static_cast<const SwFormatAnchor&>(rSet->Get(RES_ANCHOR));
905 :
906 0 : if (SfxItemState::SET == rSet->GetItemState(FN_OLE_IS_MATH, false, &pItem))
907 0 : m_bIsMathOLE = static_cast<const SfxBoolItem*>(pItem)->GetValue();
908 0 : if (SfxItemState::SET == rSet->GetItemState(FN_MATH_BASELINE_ALIGNMENT, false, &pItem))
909 0 : m_bIsMathBaselineAlignment = static_cast<const SfxBoolItem*>(pItem)->GetValue();
910 0 : EnableVerticalPositioning( !(m_bIsMathOLE && m_bIsMathBaselineAlignment
911 0 : && FLY_AS_CHAR == rAnchor.GetAnchorId()) );
912 :
913 0 : if (bFormat)
914 : {
915 : // at formats no anchor editing
916 0 : m_pAnchorFrame->Enable(false);
917 0 : m_pFixedRatioCB->Enable(false);
918 : }
919 : else
920 : {
921 0 : if (rAnchor.GetAnchorId() != FLY_AT_FLY && !pSh->IsFlyInFly())
922 0 : m_pAnchorAtFrameRB->Hide();
923 0 : if ( pSh->IsFrmVertical( true, bIsInRightToLeft, bIsVerticalL2R ) )
924 : {
925 0 : OUString sHLabel = m_pHorizontalFT->GetText();
926 0 : m_pHorizontalFT->SetText(m_pVerticalFT->GetText());
927 0 : m_pVerticalFT->SetText(sHLabel);
928 0 : bIsVerticalFrame = true;
929 : }
930 : }
931 :
932 0 : if ( sDlgType == "PictureDialog" || sDlgType == "ObjectDialog" )
933 : {
934 : OSL_ENSURE(pSh , "shell not found");
935 : //OS: only for the variant Insert/Graphic/Properties
936 0 : if(SfxItemState::SET == rSet->GetItemState(FN_PARAM_GRF_REALSIZE, false, &pItem))
937 0 : aGrfSize = static_cast<const SvxSizeItem*>(pItem)->GetSize();
938 : else
939 0 : pSh->GetGrfSize( aGrfSize );
940 :
941 0 : if ( !bNew )
942 : {
943 0 : m_pRealSizeBT->SetClickHdl(LINK(this, SwFrmPage, RealSizeHdl));
944 0 : EnableGraficMode();
945 : }
946 :
947 0 : if ( sDlgType == "PictureDialog" )
948 0 : m_pFixedRatioCB->Check( false );
949 : else
950 : {
951 0 : if ( bNew )
952 0 : SetText( SW_RESSTR(STR_OLE_INSERT));
953 : else
954 0 : SetText( SW_RESSTR(STR_OLE_EDIT));
955 : }
956 : }
957 : else
958 : {
959 0 : aGrfSize = static_cast<const SwFormatFrmSize&>(rSet->Get(RES_FRM_SIZE)).GetSize();
960 : }
961 :
962 : // entering procent value made possible
963 0 : m_aWidthED.SetBaseValue( m_aWidthED.Normalize(aGrfSize.Width()), FUNIT_TWIP );
964 0 : m_aHeightED.SetBaseValue( m_aHeightED.Normalize(aGrfSize.Height()), FUNIT_TWIP );
965 : //the available space is not yet known so the RefValue has to be calculated from size and relative size values
966 : //this is needed only if relative values are already set
967 :
968 0 : const SwFormatFrmSize& rFrmSize = static_cast<const SwFormatFrmSize&>(rSet->Get(RES_FRM_SIZE));
969 :
970 0 : m_pRelWidthRelationLB->InsertEntry(aFramePosString.GetString(SwFPos::FRAME));
971 0 : m_pRelWidthRelationLB->InsertEntry(aFramePosString.GetString(SwFPos::REL_PG_FRAME));
972 0 : if (rFrmSize.GetWidthPercent() != 0xff && rFrmSize.GetWidthPercent() != 0)
973 : {
974 : //calculate the rerference value from the with and relative width values
975 0 : sal_Int32 nSpace = rFrmSize.GetWidth() * 100 / rFrmSize.GetWidthPercent();
976 0 : m_aWidthED.SetRefValue( nSpace );
977 :
978 0 : m_pRelWidthRelationLB->Enable();
979 : }
980 : else
981 0 : m_pRelWidthRelationLB->Disable();
982 :
983 0 : m_pRelHeightRelationLB->InsertEntry(aFramePosString.GetString(SwFPos::FRAME));
984 0 : m_pRelHeightRelationLB->InsertEntry(aFramePosString.GetString(SwFPos::REL_PG_FRAME));
985 0 : if (rFrmSize.GetHeightPercent() != 0xff && rFrmSize.GetHeightPercent() != 0)
986 : {
987 : //calculate the rerference value from the with and relative width values
988 0 : sal_Int32 nSpace = rFrmSize.GetHeight() * 100 / rFrmSize.GetHeightPercent();
989 0 : m_aHeightED.SetRefValue( nSpace );
990 :
991 0 : m_pRelHeightRelationLB->Enable();
992 : }
993 : else
994 0 : m_pRelHeightRelationLB->Disable();
995 :
996 : // general initialisation part
997 0 : switch(rAnchor.GetAnchorId())
998 : {
999 0 : case FLY_AT_PAGE: m_pAnchorAtPageRB->Check(); break;
1000 0 : case FLY_AT_PARA: m_pAnchorAtParaRB->Check(); break;
1001 0 : case FLY_AT_CHAR: m_pAnchorAtCharRB->Check(); break;
1002 0 : case FLY_AS_CHAR: m_pAnchorAsCharRB->Check(); break;
1003 0 : case FLY_AT_FLY: m_pAnchorAtFrameRB->Check();break;
1004 : default:; //prevent warning
1005 : }
1006 :
1007 : // i#22341 - determine content position of character
1008 : // Note: content position can be NULL
1009 0 : mpToCharContentPos = rAnchor.GetContentAnchor();
1010 :
1011 : // i#18732 - init checkbox value
1012 : {
1013 : const bool bFollowTextFlow =
1014 0 : static_cast<const SwFormatFollowTextFlow&>(rSet->Get(RES_FOLLOW_TEXT_FLOW)).GetValue();
1015 0 : m_pFollowTextFlowCB->Check( bFollowTextFlow );
1016 : }
1017 :
1018 0 : if(bHtmlMode)
1019 : {
1020 0 : m_pAutoHeightCB->Enable(false);
1021 0 : m_pAutoWidthCB->Enable(false);
1022 0 : m_pMirrorPagesCB->Show(false);
1023 0 : if (sDlgType == "FrameDialog")
1024 0 : m_pFixedRatioCB->Enable(false);
1025 : // i#18732 hide checkbox in HTML mode
1026 0 : m_pFollowTextFlowCB->Show(false);
1027 : }
1028 : else
1029 : {
1030 : // enable/disable of check box 'Mirror on..'
1031 0 : m_pMirrorPagesCB->Enable(!m_pAnchorAsCharRB->IsChecked());
1032 :
1033 : // enable/disable check box 'Follow text flow'.
1034 : // enable check box 'Follow text
1035 : // flow' also for anchor type to-frame.
1036 0 : m_pFollowTextFlowCB->Enable( m_pAnchorAtParaRB->IsChecked() ||
1037 0 : m_pAnchorAtCharRB->IsChecked() ||
1038 0 : m_pAnchorAtFrameRB->IsChecked() );
1039 : }
1040 :
1041 0 : Init( *rSet, true );
1042 0 : m_pAtVertPosED->SaveValue();
1043 0 : m_pAtHorzPosED->SaveValue();
1044 0 : m_pFollowTextFlowCB->SaveValue();
1045 :
1046 0 : bNoModifyHdl = false;
1047 : //lock PercentFields
1048 0 : m_aWidthED.LockAutoCalculation(true);
1049 0 : m_aHeightED.LockAutoCalculation(true);
1050 0 : RangeModifyHdl(&m_aWidthED); // set all maximum values initially
1051 0 : m_aHeightED.LockAutoCalculation(false);
1052 0 : m_aWidthED.LockAutoCalculation(false);
1053 :
1054 0 : m_pAutoHeightCB->SaveValue();
1055 0 : m_pAutoWidthCB->SaveValue();
1056 :
1057 0 : SwTwips nWidth = static_cast< SwTwips >(m_aWidthED.DenormalizePercent(m_aWidthED.GetValue(FUNIT_TWIP)));
1058 0 : SwTwips nHeight = static_cast< SwTwips >(m_aHeightED.DenormalizePercent(m_aHeightED.GetValue(FUNIT_TWIP)));
1059 0 : fWidthHeightRatio = nHeight ? double(nWidth) / double(nHeight) : 1.0;
1060 0 : }
1061 :
1062 : // stuff attributes into the set when OK
1063 0 : bool SwFrmPage::FillItemSet(SfxItemSet *rSet)
1064 : {
1065 0 : bool bRet = false;
1066 : SwWrtShell* pSh = bFormat ? ::GetActiveWrtShell()
1067 0 : : getFrmDlgParentShell();
1068 : OSL_ENSURE( pSh , "shell not found");
1069 0 : const SfxItemSet& rOldSet = GetItemSet();
1070 0 : const SfxPoolItem* pOldItem = 0;
1071 :
1072 0 : RndStdIds eAnchorId = (RndStdIds)GetAnchor();
1073 :
1074 0 : if ( !bFormat )
1075 : {
1076 0 : pOldItem = GetOldItem(*rSet, RES_ANCHOR);
1077 0 : if (bNew || !pOldItem || eAnchorId != static_cast<const SwFormatAnchor*>(pOldItem)->GetAnchorId())
1078 : {
1079 0 : SwFormatAnchor aAnc( eAnchorId, pSh->GetPhyPageNum() );
1080 0 : bRet = 0 != rSet->Put( aAnc );
1081 : }
1082 : }
1083 :
1084 0 : if ( pHMap )
1085 : {
1086 : SwFormatHoriOrient aHoriOrient( static_cast<const SwFormatHoriOrient&>(
1087 0 : rOldSet.Get(RES_HORI_ORIENT)) );
1088 :
1089 0 : const sal_Int32 nMapPos = GetMapPos(pHMap, *m_pHorizontalDLB);
1090 0 : const sal_Int16 eHOri = GetAlignment(pHMap, nMapPos, *m_pHorizontalDLB, *m_pHoriRelationLB);
1091 0 : const sal_Int16 eRel = GetRelation(pHMap, *m_pHoriRelationLB);
1092 :
1093 0 : aHoriOrient.SetHoriOrient( eHOri );
1094 0 : aHoriOrient.SetRelationOrient( eRel );
1095 0 : aHoriOrient.SetPosToggle(m_pMirrorPagesCB->IsChecked());
1096 :
1097 0 : bool bMod = m_pAtHorzPosED->IsValueChangedFromSaved();
1098 0 : bMod |= m_pMirrorPagesCB->IsValueChangedFromSaved();
1099 :
1100 0 : if ( eHOri == text::HoriOrientation::NONE &&
1101 0 : (bNew || (bAtHorzPosModified || bMod) || nOldH != eHOri ) )
1102 : {
1103 0 : SwTwips nX = static_cast< SwTwips >(m_pAtHorzPosED->Denormalize(m_pAtHorzPosED->GetValue(FUNIT_TWIP)));
1104 0 : aHoriOrient.SetPos( nX );
1105 : }
1106 :
1107 0 : pOldItem = GetOldItem(*rSet, FN_HORI_ORIENT);
1108 0 : bool bSame = false;
1109 0 : if ((bNew == bFormat) && pOldItem)
1110 : {
1111 0 : bSame = aHoriOrient == static_cast<const SwFormatHoriOrient&>(*pOldItem);
1112 : }
1113 0 : if ((bNew && !bFormat) || ((bAtHorzPosModified || bMod) && !bSame))
1114 : {
1115 0 : bRet |= 0 != rSet->Put( aHoriOrient );
1116 0 : }
1117 : }
1118 :
1119 0 : if ( pVMap )
1120 : {
1121 : // alignment vertical
1122 : SwFormatVertOrient aVertOrient( static_cast<const SwFormatVertOrient&>(
1123 0 : rOldSet.Get(RES_VERT_ORIENT)) );
1124 :
1125 0 : const sal_Int32 nMapPos = GetMapPos(pVMap, *m_pVerticalDLB);
1126 0 : const sal_Int16 eVOri = GetAlignment(pVMap, nMapPos, *m_pVerticalDLB, *m_pVertRelationLB);
1127 0 : const sal_Int16 eRel = GetRelation(pVMap, *m_pVertRelationLB);
1128 :
1129 0 : aVertOrient.SetVertOrient ( eVOri);
1130 0 : aVertOrient.SetRelationOrient( eRel );
1131 :
1132 0 : bool bMod = m_pAtVertPosED->IsValueChangedFromSaved();
1133 :
1134 0 : if ( eVOri == text::VertOrientation::NONE &&
1135 0 : ( bNew || (bAtVertPosModified || bMod) || nOldV != eVOri) )
1136 : {
1137 : // vertival position
1138 : // recalculate offset for character bound frames
1139 0 : SwTwips nY = static_cast< SwTwips >(m_pAtVertPosED->Denormalize(m_pAtVertPosED->GetValue(FUNIT_TWIP)));
1140 0 : if (eAnchorId == FLY_AS_CHAR)
1141 : {
1142 0 : nY *= -1;
1143 : }
1144 0 : aVertOrient.SetPos( nY );
1145 : }
1146 0 : pOldItem = GetOldItem(*rSet, FN_VERT_ORIENT);
1147 0 : bool bSame = false;
1148 0 : if((bNew == bFormat) && pOldItem)
1149 : {
1150 : bSame = bFormat ?
1151 0 : aVertOrient.GetVertOrient() == static_cast<const SwFormatVertOrient*>(pOldItem)->GetVertOrient() &&
1152 0 : aVertOrient.GetRelationOrient() == static_cast<const SwFormatVertOrient*>(pOldItem)->GetRelationOrient() &&
1153 0 : aVertOrient.GetPos() == static_cast<const SwFormatVertOrient*>(pOldItem)->GetPos()
1154 0 : : aVertOrient == static_cast<const SwFormatVertOrient&>(*pOldItem);
1155 : }
1156 0 : if( ( bNew && !bFormat ) || ((bAtVertPosModified || bMod) && !bSame ))
1157 : {
1158 0 : bRet |= 0 != rSet->Put( aVertOrient );
1159 0 : }
1160 : }
1161 :
1162 : // set size
1163 : // new exception: when the size of pMgr(, 0), then the properties
1164 : // for a graphic that isn't even loaded, are set. Then no SetSize
1165 : // is done here when the size settings were not changed by the
1166 : // user.
1167 0 : const SwFormatFrmSize& rOldSize = static_cast<const SwFormatFrmSize& >(rOldSet.Get(RES_FRM_SIZE));
1168 0 : SwFormatFrmSize aSz( rOldSize );
1169 :
1170 0 : sal_Int32 nRelWidthRelation = m_pRelWidthRelationLB->GetSelectEntryPos();
1171 0 : if (nRelWidthRelation != LISTBOX_ENTRY_NOTFOUND)
1172 : {
1173 0 : if (nRelWidthRelation == 0)
1174 0 : aSz.SetWidthPercentRelation(text::RelOrientation::FRAME);
1175 0 : else if (nRelWidthRelation == 1)
1176 0 : aSz.SetWidthPercentRelation(text::RelOrientation::PAGE_FRAME);
1177 : }
1178 0 : sal_Int32 nRelHeightRelation = m_pRelHeightRelationLB->GetSelectEntryPos();
1179 0 : if (nRelHeightRelation != LISTBOX_ENTRY_NOTFOUND)
1180 : {
1181 0 : if (nRelHeightRelation == 0)
1182 0 : aSz.SetHeightPercentRelation(text::RelOrientation::FRAME);
1183 0 : else if (nRelHeightRelation == 1)
1184 0 : aSz.SetHeightPercentRelation(text::RelOrientation::PAGE_FRAME);
1185 : }
1186 :
1187 0 : bool bValueModified = (m_aWidthED.IsValueModified() || m_aHeightED.IsValueModified());
1188 0 : bool bCheckChanged = m_pRelWidthCB->IsValueChangedFromSaved()
1189 0 : || m_pRelHeightCB->IsValueChangedFromSaved();
1190 :
1191 0 : bool bLegalValue = !(!rOldSize.GetWidth () && !rOldSize.GetHeight() &&
1192 0 : m_aWidthED .GetValue() == m_aWidthED .GetMin() &&
1193 0 : m_aHeightED.GetValue() == m_aHeightED.GetMin());
1194 :
1195 0 : if ((bNew && !bFormat) || ((bValueModified || bCheckChanged) && bLegalValue))
1196 : {
1197 0 : sal_Int64 nNewWidth = m_aWidthED.DenormalizePercent(m_aWidthED.GetRealValue(FUNIT_TWIP));
1198 0 : sal_Int64 nNewHeight = m_aHeightED.DenormalizePercent(m_aHeightED.GetRealValue(FUNIT_TWIP));
1199 0 : aSz.SetWidth (static_cast< SwTwips >(nNewWidth));
1200 0 : aSz.SetHeight(static_cast< SwTwips >(nNewHeight));
1201 :
1202 0 : if (m_pRelWidthCB->IsChecked())
1203 : {
1204 0 : aSz.SetWidthPercent((sal_uInt8)std::min( static_cast< sal_Int64 >(MAX_PERCENT_WIDTH), m_aWidthED.Convert(m_aWidthED.NormalizePercent(nNewWidth), FUNIT_TWIP, FUNIT_CUSTOM)));
1205 : }
1206 : else
1207 0 : aSz.SetWidthPercent(0);
1208 0 : if (m_pRelHeightCB->IsChecked())
1209 0 : aSz.SetHeightPercent((sal_uInt8)std::min(static_cast< sal_Int64 >(MAX_PERCENT_HEIGHT), m_aHeightED.Convert(m_aHeightED.NormalizePercent(nNewHeight), FUNIT_TWIP, FUNIT_CUSTOM)));
1210 : else
1211 0 : aSz.SetHeightPercent(0);
1212 :
1213 0 : if (m_pFixedRatioCB->IsChecked() && (m_pRelWidthCB->IsChecked() != m_pRelHeightCB->IsChecked()))
1214 : {
1215 0 : if (m_pRelWidthCB->IsChecked())
1216 0 : aSz.SetHeightPercent(0xff);
1217 : else
1218 0 : aSz.SetWidthPercent(0xff);
1219 : }
1220 : }
1221 0 : if( !IsInGraficMode() )
1222 : {
1223 0 : if( m_pAutoHeightCB->IsValueChangedFromSaved() )
1224 : {
1225 0 : SwFrmSize eFrmSize = m_pAutoHeightCB->IsChecked()? ATT_MIN_SIZE : ATT_FIX_SIZE;
1226 0 : if( eFrmSize != aSz.GetHeightSizeType() )
1227 0 : aSz.SetHeightSizeType(eFrmSize);
1228 : }
1229 0 : if( m_pAutoWidthCB->IsValueChangedFromSaved() )
1230 : {
1231 0 : SwFrmSize eFrmSize = m_pAutoWidthCB->IsChecked()? ATT_MIN_SIZE : ATT_FIX_SIZE;
1232 0 : if( eFrmSize != aSz.GetWidthSizeType() )
1233 0 : aSz.SetWidthSizeType( eFrmSize );
1234 : }
1235 : }
1236 0 : if( !bFormat && m_pFixedRatioCB->IsValueChangedFromSaved() )
1237 0 : bRet |= 0 != rSet->Put(SfxBoolItem(FN_KEEP_ASPECT_RATIO, m_pFixedRatioCB->IsChecked()));
1238 :
1239 0 : pOldItem = GetOldItem(*rSet, RES_FRM_SIZE);
1240 :
1241 0 : if ((pOldItem && aSz != *pOldItem) || (!pOldItem && !bFormat) ||
1242 0 : (bFormat &&
1243 0 : (aSz.GetWidth() > 0 || aSz.GetWidthPercent() > 0) &&
1244 0 : (aSz.GetHeight() > 0 || aSz.GetHeightPercent() > 0)))
1245 : {
1246 0 : if (aSz.GetHeightSizeType() == ATT_VAR_SIZE) // there is no VAR_SIZE in frames
1247 0 : aSz.SetHeightSizeType(ATT_MIN_SIZE);
1248 :
1249 0 : bRet |= 0 != rSet->Put( aSz );
1250 : }
1251 0 : if(m_pFollowTextFlowCB->IsValueChangedFromSaved())
1252 : {
1253 0 : bRet |= 0 != rSet->Put(SwFormatFollowTextFlow(m_pFollowTextFlowCB->IsChecked()));
1254 : }
1255 0 : return bRet;
1256 : }
1257 :
1258 : // initialise horizonal and vertical Pos
1259 0 : void SwFrmPage::InitPos(RndStdIds eId,
1260 : sal_Int16 nH,
1261 : sal_Int16 nHRel,
1262 : sal_Int16 nV,
1263 : sal_Int16 nVRel,
1264 : long nX,
1265 : long nY)
1266 : {
1267 0 : sal_Int32 nPos = m_pVerticalDLB->GetSelectEntryPos();
1268 0 : if ( nPos != LISTBOX_ENTRY_NOTFOUND && pVMap )
1269 : {
1270 0 : nOldV = pVMap[nPos].nAlign;
1271 :
1272 0 : nPos = m_pVertRelationLB->GetSelectEntryPos();
1273 0 : if (nPos != LISTBOX_ENTRY_NOTFOUND)
1274 0 : nOldVRel = static_cast<RelationMap *>(m_pVertRelationLB->GetEntryData(nPos))->nRelation;
1275 : }
1276 :
1277 0 : nPos = m_pHorizontalDLB->GetSelectEntryPos();
1278 0 : if ( nPos != LISTBOX_ENTRY_NOTFOUND && pHMap )
1279 : {
1280 0 : nOldH = pHMap[nPos].nAlign;
1281 :
1282 0 : nPos = m_pHoriRelationLB->GetSelectEntryPos();
1283 0 : if (nPos != LISTBOX_ENTRY_NOTFOUND)
1284 0 : nOldHRel = static_cast<RelationMap *>(m_pHoriRelationLB->GetEntryData(nPos))->nRelation;
1285 : }
1286 :
1287 0 : bool bEnable = true;
1288 0 : if ( eId == FLY_AT_PAGE )
1289 : {
1290 0 : pVMap = bHtmlMode ? aVPageHtmlMap : aVPageMap;
1291 0 : pHMap = bHtmlMode ? aHPageHtmlMap : aHPageMap;
1292 : }
1293 0 : else if ( eId == FLY_AT_FLY )
1294 : {
1295 : // own vertical alignment map for to frame
1296 : // anchored objects.
1297 0 : pVMap = bHtmlMode ? aVFlyHtmlMap : aVFrameMap;
1298 0 : pHMap = bHtmlMode ? aHFlyHtmlMap : aHFrameMap;
1299 : }
1300 0 : else if ( eId == FLY_AT_PARA )
1301 : {
1302 0 : if(bHtmlMode)
1303 : {
1304 0 : pVMap = aVParaHtmlMap;
1305 0 : pHMap = aHParaHtmlAbsMap;
1306 : }
1307 : else
1308 : {
1309 0 : pVMap = aVParaMap;
1310 0 : pHMap = aHParaMap;
1311 : }
1312 : }
1313 0 : else if ( eId == FLY_AT_CHAR )
1314 : {
1315 0 : if(bHtmlMode)
1316 : {
1317 0 : pVMap = aVCharHtmlAbsMap;
1318 0 : pHMap = aHCharHtmlAbsMap;
1319 : }
1320 : else
1321 : {
1322 0 : pVMap = aVCharMap;
1323 0 : pHMap = aHCharMap;
1324 : }
1325 : }
1326 0 : else if ( eId == FLY_AS_CHAR )
1327 : {
1328 0 : pVMap = bHtmlMode ? aVAsCharHtmlMap : aVAsCharMap;
1329 0 : pHMap = 0;
1330 0 : bEnable = false;
1331 : }
1332 0 : m_pHorizontalDLB->Enable( bEnable );
1333 0 : m_pHorizontalFT->Enable( bEnable );
1334 :
1335 : // select current Pos
1336 : // horizontal
1337 0 : if ( nH < 0 )
1338 : {
1339 0 : nH = nOldH;
1340 0 : nHRel = nOldHRel;
1341 : }
1342 0 : sal_Int32 nMapPos = FillPosLB(pHMap, nH, nHRel, *m_pHorizontalDLB);
1343 0 : FillRelLB(pHMap, nMapPos, nH, nHRel, *m_pHoriRelationLB, *m_pHoriRelationFT);
1344 :
1345 : // vertical
1346 0 : if ( nV < 0 )
1347 : {
1348 0 : nV = nOldV;
1349 0 : nVRel = nOldVRel;
1350 : }
1351 0 : nMapPos = FillPosLB(pVMap, nV, nVRel, *m_pVerticalDLB);
1352 0 : FillRelLB(pVMap, nMapPos, nV, nVRel, *m_pVertRelationLB, *m_pVertRelationFT);
1353 :
1354 0 : bEnable = nH == text::HoriOrientation::NONE && eId != FLY_AS_CHAR;
1355 0 : if (!bEnable)
1356 : {
1357 0 : m_pAtHorzPosED->SetValue( 0, FUNIT_TWIP );
1358 0 : if (nX != LONG_MAX && bHtmlMode)
1359 0 : m_pAtHorzPosED->SetModifyFlag();
1360 : }
1361 : else
1362 : {
1363 0 : if (nX != LONG_MAX)
1364 0 : m_pAtHorzPosED->SetValue( m_pAtHorzPosED->Normalize(nX), FUNIT_TWIP );
1365 : }
1366 0 : m_pAtHorzPosFT->Enable( bEnable );
1367 0 : m_pAtHorzPosED->Enable( bEnable );
1368 :
1369 0 : bEnable = nV == text::VertOrientation::NONE;
1370 0 : if ( !bEnable )
1371 : {
1372 0 : m_pAtVertPosED->SetValue( 0, FUNIT_TWIP );
1373 0 : if(nY != LONG_MAX && bHtmlMode)
1374 0 : m_pAtVertPosED->SetModifyFlag();
1375 : }
1376 : else
1377 : {
1378 0 : if ( eId == FLY_AS_CHAR )
1379 : {
1380 0 : if ( nY == LONG_MAX )
1381 0 : nY = 0;
1382 : else
1383 0 : nY *= -1;
1384 : }
1385 0 : if ( nY != LONG_MAX )
1386 0 : m_pAtVertPosED->SetValue( m_pAtVertPosED->Normalize(nY), FUNIT_TWIP );
1387 : }
1388 0 : m_pAtVertPosFT->Enable( bEnable && m_bAllowVertPositioning );
1389 0 : m_pAtVertPosED->Enable( bEnable && m_bAllowVertPositioning );
1390 0 : UpdateExample();
1391 0 : }
1392 :
1393 0 : sal_Int32 SwFrmPage::FillPosLB(const FrmMap* _pMap,
1394 : const sal_Int16 _nAlign,
1395 : const sal_Int16 _nRel,
1396 : ListBox& _rLB )
1397 : {
1398 0 : OUString sSelEntry;
1399 0 : const OUString sOldEntry = _rLB.GetSelectEntry();
1400 :
1401 0 : _rLB.Clear();
1402 :
1403 : // i#22341 determine all possible listbox relations for
1404 : // given relation for map <aVCharMap>
1405 : const sal_uLong nLBRelations = (_pMap != aVCharMap)
1406 : ? 0L
1407 0 : : ::lcl_GetLBRelationsForRelations( _nRel );
1408 :
1409 : // fill Listbox
1410 0 : size_t nCount = ::lcl_GetFrmMapCount(_pMap);
1411 0 : for (size_t i = 0; _pMap && i < nCount; ++i)
1412 : {
1413 : // Why not from the left/from inside or from above?
1414 : {
1415 0 : SvxSwFramePosString::StringId eStrId = m_pMirrorPagesCB->IsChecked() ? _pMap[i].eMirrorStrId : _pMap[i].eStrId;
1416 : // --> OD 2009-08-31 #mongolianlayout#
1417 : eStrId = lcl_ChangeResIdToVerticalOrRTL( eStrId,
1418 : bIsVerticalFrame,
1419 : bIsVerticalL2R,
1420 0 : bIsInRightToLeft);
1421 0 : OUString sEntry(aFramePosString.GetString(eStrId));
1422 0 : if (_rLB.GetEntryPos(sEntry) == LISTBOX_ENTRY_NOTFOUND)
1423 : {
1424 : // don't insert entries when frames are character bound
1425 0 : _rLB.InsertEntry(sEntry);
1426 : }
1427 : // i#22341 - add condition to handle map <aVCharMap>
1428 : // that is ambigous in the alignment.
1429 0 : if ( _pMap[i].nAlign == _nAlign &&
1430 0 : ( !(_pMap == aVCharMap) || _pMap[i].nLBRelations & nLBRelations ) )
1431 : {
1432 0 : sSelEntry = sEntry;
1433 0 : }
1434 : }
1435 : }
1436 :
1437 0 : _rLB.SelectEntry(sSelEntry);
1438 0 : if (!_rLB.GetSelectEntryCount())
1439 0 : _rLB.SelectEntry(sOldEntry);
1440 :
1441 0 : if (!_rLB.GetSelectEntryCount())
1442 0 : _rLB.SelectEntryPos(0);
1443 :
1444 0 : PosHdl(&_rLB);
1445 :
1446 0 : return GetMapPos(_pMap, _rLB);
1447 : }
1448 :
1449 0 : sal_uLong SwFrmPage::FillRelLB( const FrmMap* _pMap,
1450 : const sal_uInt16 _nLBSelPos,
1451 : const sal_Int16 _nAlign,
1452 : const sal_Int16 _nRel,
1453 : ListBox& _rLB,
1454 : FixedText& _rFT )
1455 : {
1456 0 : OUString sSelEntry;
1457 0 : sal_uLong nLBRelations = 0;
1458 0 : size_t nMapCount = ::lcl_GetFrmMapCount(_pMap);
1459 :
1460 0 : _rLB.Clear();
1461 :
1462 0 : if (_nLBSelPos < nMapCount)
1463 : {
1464 0 : if (_pMap == aVAsCharHtmlMap || _pMap == aVAsCharMap)
1465 : {
1466 0 : const OUString sOldEntry(_rLB.GetSelectEntry());
1467 0 : const size_t nRelCount = SAL_N_ELEMENTS(aAsCharRelationMap);
1468 0 : SvxSwFramePosString::StringId eStrId = _pMap[_nLBSelPos].eStrId;
1469 :
1470 0 : for (size_t nMapPos = 0; nMapPos < nMapCount; nMapPos++)
1471 : {
1472 0 : if (_pMap[nMapPos].eStrId == eStrId)
1473 : {
1474 0 : nLBRelations = _pMap[nMapPos].nLBRelations;
1475 0 : for (size_t nRelPos = 0; nRelPos < nRelCount; ++nRelPos)
1476 : {
1477 0 : if (nLBRelations & aAsCharRelationMap[nRelPos].nLBRelation)
1478 : {
1479 0 : SvxSwFramePosString::StringId sStrId1 = aAsCharRelationMap[nRelPos].eStrId;
1480 :
1481 : // --> OD 2009-08-31 #mongolianlayout#
1482 : sStrId1 =
1483 : lcl_ChangeResIdToVerticalOrRTL( sStrId1,
1484 : bIsVerticalFrame,
1485 : bIsVerticalL2R,
1486 0 : bIsInRightToLeft);
1487 0 : const OUString sEntry = aFramePosString.GetString(sStrId1);
1488 0 : sal_Int32 nPos = _rLB.InsertEntry(sEntry);
1489 0 : _rLB.SetEntryData(nPos, &aAsCharRelationMap[nRelPos]);
1490 0 : if (_pMap[nMapPos].nAlign == _nAlign)
1491 0 : sSelEntry = sEntry;
1492 0 : break;
1493 : }
1494 : }
1495 : }
1496 : }
1497 0 : if (!sSelEntry.isEmpty())
1498 0 : _rLB.SelectEntry(sSelEntry);
1499 : else
1500 : {
1501 0 : _rLB.SelectEntry(sOldEntry);
1502 :
1503 0 : if (!_rLB.GetSelectEntryCount())
1504 : {
1505 0 : for (sal_Int32 i = 0; i < _rLB.GetEntryCount(); i++)
1506 : {
1507 0 : RelationMap *pEntry = static_cast<RelationMap *>(_rLB.GetEntryData(i));
1508 0 : if (pEntry->nLBRelation == LB_REL_CHAR) // default
1509 : {
1510 0 : _rLB.SelectEntryPos(i);
1511 0 : break;
1512 : }
1513 : }
1514 : }
1515 0 : }
1516 : }
1517 : else
1518 : {
1519 : // special handling for map <aVCharMap>,
1520 : // because its ambigous in its <eStrId>/<eMirrorStrId>.
1521 0 : if ( _pMap == aVCharMap )
1522 : {
1523 : nLBRelations = ::lcl_GetLBRelationsForStrID( _pMap,
1524 0 : ( m_pMirrorPagesCB->IsChecked()
1525 0 : ? _pMap[_nLBSelPos].eMirrorStrId
1526 0 : : _pMap[_nLBSelPos].eStrId),
1527 0 : m_pMirrorPagesCB->IsChecked() );
1528 : }
1529 : else
1530 : {
1531 0 : nLBRelations = _pMap[_nLBSelPos].nLBRelations;
1532 : }
1533 :
1534 0 : const size_t nRelCount = SAL_N_ELEMENTS(aRelationMap);
1535 :
1536 0 : for (sal_uLong nBit = 1; nBit < 0x80000000; nBit <<= 1)
1537 : {
1538 0 : if (nLBRelations & nBit)
1539 : {
1540 0 : for (size_t nRelPos = 0; nRelPos < nRelCount; ++nRelPos)
1541 : {
1542 0 : if (aRelationMap[nRelPos].nLBRelation == nBit)
1543 : {
1544 0 : SvxSwFramePosString::StringId eStrId1 = m_pMirrorPagesCB->IsChecked() ?
1545 0 : aRelationMap[nRelPos].eMirrorStrId : aRelationMap[nRelPos].eStrId;
1546 : // --> OD 2009-08-31 #mongolianlayout#
1547 : eStrId1 =
1548 : lcl_ChangeResIdToVerticalOrRTL( eStrId1,
1549 : bIsVerticalFrame,
1550 : bIsVerticalL2R,
1551 0 : bIsInRightToLeft);
1552 0 : const OUString sEntry = aFramePosString.GetString(eStrId1);
1553 0 : sal_Int32 nPos = _rLB.InsertEntry(sEntry);
1554 0 : _rLB.SetEntryData(nPos, &aRelationMap[nRelPos]);
1555 0 : if (sSelEntry.isEmpty() && aRelationMap[nRelPos].nRelation == _nRel)
1556 0 : sSelEntry = sEntry;
1557 : }
1558 : }
1559 : }
1560 : }
1561 0 : if (!sSelEntry.isEmpty())
1562 0 : _rLB.SelectEntry(sSelEntry);
1563 : else
1564 : {
1565 : // Probably anchor switch. So look for similar relation
1566 0 : sal_Int16 nSimRel = -1;
1567 0 : switch (_nRel)
1568 : {
1569 : case text::RelOrientation::FRAME:
1570 0 : nSimRel = text::RelOrientation::PAGE_FRAME;
1571 0 : break;
1572 : case text::RelOrientation::PRINT_AREA:
1573 0 : nSimRel = text::RelOrientation::PAGE_PRINT_AREA;
1574 0 : break;
1575 : case text::RelOrientation::PAGE_LEFT:
1576 0 : nSimRel = text::RelOrientation::FRAME_LEFT;
1577 0 : break;
1578 : case text::RelOrientation::PAGE_RIGHT:
1579 0 : nSimRel = text::RelOrientation::FRAME_RIGHT;
1580 0 : break;
1581 : case text::RelOrientation::FRAME_LEFT:
1582 0 : nSimRel = text::RelOrientation::PAGE_LEFT;
1583 0 : break;
1584 : case text::RelOrientation::FRAME_RIGHT:
1585 0 : nSimRel = text::RelOrientation::PAGE_RIGHT;
1586 0 : break;
1587 : case text::RelOrientation::PAGE_FRAME:
1588 0 : nSimRel = text::RelOrientation::FRAME;
1589 0 : break;
1590 : case text::RelOrientation::PAGE_PRINT_AREA:
1591 0 : nSimRel = text::RelOrientation::PRINT_AREA;
1592 0 : break;
1593 :
1594 : default:
1595 0 : if (_rLB.GetEntryCount())
1596 : {
1597 0 : RelationMap *pEntry = static_cast<RelationMap *>(_rLB.GetEntryData(_rLB.GetEntryCount() - 1));
1598 0 : nSimRel = pEntry->nRelation;
1599 : }
1600 0 : break;
1601 : }
1602 :
1603 0 : for (sal_Int32 i = 0; i < _rLB.GetEntryCount(); i++)
1604 : {
1605 0 : RelationMap *pEntry = static_cast<RelationMap *>(_rLB.GetEntryData(i));
1606 0 : if (pEntry->nRelation == nSimRel)
1607 : {
1608 0 : _rLB.SelectEntryPos(i);
1609 0 : break;
1610 : }
1611 : }
1612 :
1613 0 : if (!_rLB.GetSelectEntryCount())
1614 0 : _rLB.SelectEntryPos(0);
1615 : }
1616 : }
1617 : }
1618 :
1619 0 : const bool bEnable = _rLB.GetEntryCount() != 0
1620 0 : && (&_rLB != m_pVertRelationLB || m_bAllowVertPositioning);
1621 0 : _rLB.Enable( bEnable );
1622 0 : _rFT.Enable( bEnable );
1623 :
1624 0 : RelHdl(&_rLB);
1625 :
1626 0 : return nLBRelations;
1627 : }
1628 :
1629 0 : sal_Int16 SwFrmPage::GetRelation(FrmMap * /*pMap*/, ListBox &rRelationLB)
1630 : {
1631 0 : const sal_Int32 nPos = rRelationLB.GetSelectEntryPos();
1632 :
1633 0 : if (nPos != LISTBOX_ENTRY_NOTFOUND)
1634 : {
1635 0 : RelationMap *pEntry = static_cast<RelationMap *>(rRelationLB.GetEntryData(nPos));
1636 0 : return pEntry->nRelation;
1637 : }
1638 :
1639 0 : return 0;
1640 : }
1641 :
1642 0 : sal_Int16 SwFrmPage::GetAlignment(FrmMap *pMap, sal_Int32 nMapPos,
1643 : ListBox &/*rAlignLB*/, ListBox &rRelationLB)
1644 : {
1645 0 : if (!pMap || nMapPos < 0)
1646 0 : return 0;
1647 :
1648 0 : const size_t nMapCount = ::lcl_GetFrmMapCount(pMap);
1649 :
1650 0 : if (static_cast<size_t>(nMapPos) >= nMapCount)
1651 0 : return 0;
1652 :
1653 : // i#22341 special handling also for map <aVCharMap>,
1654 : // because it contains ambigous items for alignment
1655 0 : if ( pMap != aVAsCharHtmlMap && pMap != aVAsCharMap && pMap != aVCharMap )
1656 0 : return pMap[nMapPos].nAlign;
1657 :
1658 0 : if (rRelationLB.GetSelectEntryPos() == LISTBOX_ENTRY_NOTFOUND)
1659 0 : return 0;
1660 :
1661 : const RelationMap *const pRelationMap = static_cast<const RelationMap *>(
1662 0 : rRelationLB.GetSelectEntryData());
1663 0 : const sal_uLong nRel = pRelationMap->nLBRelation;
1664 0 : const SvxSwFramePosString::StringId eStrId = pMap[nMapPos].eStrId;
1665 :
1666 0 : for (size_t i = 0; i < nMapCount; ++i)
1667 : {
1668 0 : if (pMap[i].eStrId == eStrId && (pMap[i].nLBRelations & nRel))
1669 0 : return pMap[i].nAlign;
1670 : }
1671 :
1672 0 : return 0;
1673 : }
1674 :
1675 0 : sal_Int32 SwFrmPage::GetMapPos( const FrmMap *pMap, ListBox &rAlignLB )
1676 : {
1677 0 : sal_Int32 nMapPos = 0;
1678 0 : sal_Int32 nLBSelPos = rAlignLB.GetSelectEntryPos();
1679 :
1680 0 : if (nLBSelPos != LISTBOX_ENTRY_NOTFOUND)
1681 : {
1682 0 : if (pMap == aVAsCharHtmlMap || pMap == aVAsCharMap)
1683 : {
1684 0 : const size_t nMapCount = ::lcl_GetFrmMapCount(pMap);
1685 0 : const OUString sSelEntry(rAlignLB.GetSelectEntry());
1686 :
1687 0 : for (size_t i = 0; i < nMapCount; i++)
1688 : {
1689 0 : SvxSwFramePosString::StringId eResId = pMap[i].eStrId;
1690 :
1691 0 : OUString sEntry = aFramePosString.GetString(eResId);
1692 0 : sEntry = MnemonicGenerator::EraseAllMnemonicChars( sEntry );
1693 :
1694 0 : if (sEntry == sSelEntry)
1695 : {
1696 0 : nMapPos = static_cast< sal_Int32 >(i);
1697 0 : break;
1698 : }
1699 0 : }
1700 : }
1701 : else
1702 0 : nMapPos = nLBSelPos;
1703 : }
1704 :
1705 0 : return nMapPos;
1706 : }
1707 :
1708 0 : RndStdIds SwFrmPage::GetAnchor()
1709 : {
1710 0 : RndStdIds nRet = FLY_AT_PAGE;
1711 0 : if(m_pAnchorAtParaRB->IsChecked())
1712 : {
1713 0 : nRet = FLY_AT_PARA;
1714 : }
1715 0 : else if(m_pAnchorAtCharRB->IsChecked())
1716 : {
1717 0 : nRet = FLY_AT_CHAR;
1718 : }
1719 0 : else if(m_pAnchorAsCharRB->IsChecked())
1720 : {
1721 0 : nRet = FLY_AS_CHAR;
1722 : }
1723 0 : else if(m_pAnchorAtFrameRB->IsChecked())
1724 : {
1725 0 : nRet = FLY_AT_FLY;
1726 : }
1727 0 : return nRet;
1728 : }
1729 :
1730 : // Bsp - Update
1731 0 : void SwFrmPage::ActivatePage(const SfxItemSet& rSet)
1732 : {
1733 0 : bNoModifyHdl = true;
1734 0 : Init(rSet);
1735 0 : bNoModifyHdl = false;
1736 : //lock PercentFields
1737 0 : m_aWidthED.LockAutoCalculation(true);
1738 0 : m_aHeightED.LockAutoCalculation(true);
1739 0 : RangeModifyHdl(&m_aWidthED); // set all maximum values initially
1740 0 : m_aHeightED.LockAutoCalculation(false);
1741 0 : m_aWidthED.LockAutoCalculation(false);
1742 0 : m_pFollowTextFlowCB->SaveValue();
1743 0 : }
1744 :
1745 0 : SfxTabPage::sfxpg SwFrmPage::DeactivatePage(SfxItemSet * _pSet)
1746 : {
1747 0 : if ( _pSet )
1748 : {
1749 0 : FillItemSet( _pSet );
1750 :
1751 : //FillItemSet doesn't set the anchor into the set when it matches
1752 : //the original. But for the other pages we need the current anchor.
1753 : SwWrtShell* pSh = bFormat ? ::GetActiveWrtShell()
1754 0 : : getFrmDlgParentShell();
1755 0 : RndStdIds eAnchorId = (RndStdIds)GetAnchor();
1756 0 : SwFormatAnchor aAnc( eAnchorId, pSh->GetPhyPageNum() );
1757 0 : _pSet->Put( aAnc );
1758 : }
1759 :
1760 0 : return LEAVE_PAGE;
1761 : }
1762 :
1763 : // swap left/right with inside/outside
1764 0 : IMPL_LINK_NOARG(SwFrmPage, MirrorHdl)
1765 : {
1766 0 : RndStdIds eId = GetAnchor();
1767 0 : InitPos( eId, -1, 0, -1, 0, LONG_MAX, LONG_MAX);
1768 :
1769 0 : return 0;
1770 : }
1771 :
1772 0 : IMPL_LINK( SwFrmPage, RelSizeClickHdl, CheckBox *, pBtn )
1773 : {
1774 0 : if (pBtn == m_pRelWidthCB)
1775 : {
1776 0 : m_aWidthED.ShowPercent(pBtn->IsChecked());
1777 0 : m_pRelWidthRelationLB->Enable(pBtn->IsChecked());
1778 0 : if(pBtn->IsChecked())
1779 0 : m_aWidthED.get()->SetMax(MAX_PERCENT_WIDTH);
1780 : }
1781 : else // pBtn == m_pRelHeightCB
1782 : {
1783 0 : m_aHeightED.ShowPercent(pBtn->IsChecked());
1784 0 : m_pRelHeightRelationLB->Enable(pBtn->IsChecked());
1785 0 : if(pBtn->IsChecked())
1786 0 : m_aHeightED.get()->SetMax(MAX_PERCENT_HEIGHT);
1787 : }
1788 :
1789 0 : RangeModifyHdl(m_aWidthED.get()); // correct the values again
1790 :
1791 0 : if (pBtn == m_pRelWidthCB)
1792 0 : ModifyHdl(m_aWidthED.get());
1793 : else // pBtn == m_pRelHeightCB
1794 0 : ModifyHdl(m_aHeightED.get());
1795 :
1796 0 : return 0;
1797 : }
1798 :
1799 : // range check
1800 0 : IMPL_LINK_NOARG(SwFrmPage, RangeModifyHdl)
1801 : {
1802 0 : if (bNoModifyHdl)
1803 0 : return 0;
1804 :
1805 : SwWrtShell* pSh = bFormat ? ::GetActiveWrtShell()
1806 0 : : getFrmDlgParentShell();
1807 : OSL_ENSURE(pSh , "shell not found");
1808 0 : SwFlyFrmAttrMgr aMgr( bNew, pSh, static_cast<const SwAttrSet&>(GetItemSet()) );
1809 0 : SvxSwFrameValidation aVal;
1810 :
1811 0 : aVal.nAnchorType = static_cast< sal_Int16 >(GetAnchor());
1812 0 : aVal.bAutoHeight = m_pAutoHeightCB->IsChecked();
1813 0 : aVal.bAutoWidth = m_pAutoWidthCB->IsChecked();
1814 0 : aVal.bMirror = m_pMirrorPagesCB->IsChecked();
1815 0 : aVal.bFollowTextFlow = m_pFollowTextFlowCB->IsChecked();
1816 :
1817 0 : if ( pHMap )
1818 : {
1819 : // alignment horizonal
1820 0 : const sal_Int32 nMapPos = GetMapPos(pHMap, *m_pHorizontalDLB);
1821 0 : aVal.nHoriOrient = GetAlignment(pHMap, nMapPos, *m_pHorizontalDLB, *m_pHoriRelationLB);
1822 0 : aVal.nHRelOrient = GetRelation(pHMap, *m_pHoriRelationLB);
1823 : }
1824 : else
1825 0 : aVal.nHoriOrient = text::HoriOrientation::NONE;
1826 :
1827 0 : if ( pVMap )
1828 : {
1829 : // alignment vertical
1830 0 : const sal_Int32 nMapPos = GetMapPos(pVMap, *m_pVerticalDLB);
1831 0 : aVal.nVertOrient = GetAlignment(pVMap, nMapPos, *m_pVerticalDLB, *m_pVertRelationLB);
1832 0 : aVal.nVRelOrient = GetRelation(pVMap, *m_pVertRelationLB);
1833 : }
1834 : else
1835 0 : aVal.nVertOrient = text::VertOrientation::NONE;
1836 :
1837 : const long nAtHorzPosVal = static_cast< long >(
1838 0 : m_pAtHorzPosED->Denormalize(m_pAtHorzPosED->GetValue(FUNIT_TWIP)) );
1839 : const long nAtVertPosVal = static_cast< long >(
1840 0 : m_pAtVertPosED->Denormalize(m_pAtVertPosED->GetValue(FUNIT_TWIP)) );
1841 :
1842 0 : aVal.nHPos = nAtHorzPosVal;
1843 0 : aVal.nVPos = nAtVertPosVal;
1844 :
1845 0 : aMgr.ValidateMetrics(aVal, mpToCharContentPos, true); // one time, to get reference values for percental values
1846 :
1847 : // set reference values for percental values (100%) ...
1848 0 : m_aWidthED.SetRefValue(aVal.aPercentSize.Width());
1849 0 : m_aHeightED.SetRefValue(aVal.aPercentSize.Height());
1850 :
1851 : // ... and correctly convert width and height with it
1852 0 : SwTwips nWidth = static_cast< SwTwips >(m_aWidthED. DenormalizePercent(m_aWidthED.GetValue(FUNIT_TWIP)));
1853 0 : SwTwips nHeight = static_cast< SwTwips >(m_aHeightED.DenormalizePercent(m_aHeightED.GetValue(FUNIT_TWIP)));
1854 0 : aVal.nWidth = nWidth;
1855 0 : aVal.nHeight = nHeight;
1856 :
1857 0 : aMgr.ValidateMetrics(aVal, mpToCharContentPos); // one more time, to determine all remaining values with correct width and height.
1858 :
1859 : // all columns have to be correct
1860 0 : if(GetTabDialog()->GetExampleSet() &&
1861 0 : SfxItemState::DEFAULT <= GetTabDialog()->GetExampleSet()->GetItemState(RES_COL))
1862 : {
1863 0 : const SwFormatCol& rCol = static_cast<const SwFormatCol&>(GetTabDialog()->GetExampleSet()->Get(RES_COL));
1864 0 : if ( rCol.GetColumns().size() > 1 )
1865 : {
1866 0 : for ( size_t i = 0; i < rCol.GetColumns().size(); ++i )
1867 : {
1868 0 : aVal.nMinWidth += rCol.GetColumns()[i].GetLeft() +
1869 0 : rCol.GetColumns()[i].GetRight() +
1870 0 : MINFLY;
1871 : }
1872 0 : aVal.nMinWidth -= MINFLY;//one was already in there!
1873 : }
1874 : }
1875 :
1876 0 : nWidth = aVal.nWidth;
1877 0 : nHeight = aVal.nHeight;
1878 :
1879 : // minimum range also for template
1880 0 : m_aHeightED.SetMin(m_aHeightED.NormalizePercent(aVal.nMinHeight), FUNIT_TWIP);
1881 0 : m_aWidthED. SetMin(m_aWidthED.NormalizePercent(aVal.nMinWidth), FUNIT_TWIP);
1882 :
1883 0 : SwTwips nMaxWidth(aVal.nMaxWidth);
1884 0 : SwTwips nMaxHeight(aVal.nMaxHeight);
1885 :
1886 0 : if (aVal.bAutoHeight && (sDlgType == "PictureDialog" || sDlgType == "ObjectDialog"))
1887 : {
1888 0 : SwTwips nTmp = std::min(nWidth * nMaxHeight / std::max(nHeight, 1L), nMaxHeight);
1889 0 : m_aWidthED.SetMax(m_aWidthED.NormalizePercent(nTmp), FUNIT_TWIP);
1890 :
1891 0 : nTmp = std::min(nHeight * nMaxWidth / std::max(nWidth, 1L), nMaxWidth);
1892 0 : m_aHeightED.SetMax(m_aWidthED.NormalizePercent(nTmp), FUNIT_TWIP);
1893 : }
1894 : else
1895 : {
1896 0 : SwTwips nTmp = static_cast< SwTwips >(m_aHeightED.NormalizePercent(nMaxHeight));
1897 0 : m_aHeightED.SetMax(nTmp, FUNIT_TWIP);
1898 :
1899 0 : nTmp = static_cast< SwTwips >(m_aWidthED.NormalizePercent(nMaxWidth));
1900 0 : m_aWidthED.SetMax(nTmp, FUNIT_TWIP);
1901 : }
1902 :
1903 0 : m_pAtHorzPosED->SetMin(m_pAtHorzPosED->Normalize(aVal.nMinHPos), FUNIT_TWIP);
1904 0 : m_pAtHorzPosED->SetMax(m_pAtHorzPosED->Normalize(aVal.nMaxHPos), FUNIT_TWIP);
1905 0 : if ( aVal.nHPos != nAtHorzPosVal )
1906 0 : m_pAtHorzPosED->SetValue(m_pAtHorzPosED->Normalize(aVal.nHPos), FUNIT_TWIP);
1907 :
1908 0 : const SwTwips nUpperOffset = (aVal.nAnchorType == FLY_AS_CHAR)
1909 0 : ? nUpperBorder : 0;
1910 0 : const SwTwips nLowerOffset = (aVal.nAnchorType == FLY_AS_CHAR)
1911 0 : ? nLowerBorder : 0;
1912 :
1913 0 : m_pAtVertPosED->SetMin(m_pAtVertPosED->Normalize(aVal.nMinVPos + nLowerOffset + nUpperOffset), FUNIT_TWIP);
1914 0 : m_pAtVertPosED->SetMax(m_pAtVertPosED->Normalize(aVal.nMaxVPos), FUNIT_TWIP);
1915 0 : if ( aVal.nVPos != nAtVertPosVal )
1916 0 : m_pAtVertPosED->SetValue(m_pAtVertPosED->Normalize(aVal.nVPos), FUNIT_TWIP);
1917 :
1918 0 : return 0;
1919 : }
1920 :
1921 0 : IMPL_LINK_NOARG(SwFrmPage, AnchorTypeHdl)
1922 : {
1923 0 : m_pMirrorPagesCB->Enable(!m_pAnchorAsCharRB->IsChecked());
1924 :
1925 : // i#18732 - enable check box 'Follow text flow' for anchor
1926 : // type to-paragraph' and to-character
1927 : // i#22305 - enable check box 'Follow text
1928 : // flow' also for anchor type to-frame.
1929 0 : m_pFollowTextFlowCB->Enable( m_pAnchorAtParaRB->IsChecked() ||
1930 0 : m_pAnchorAtCharRB->IsChecked() ||
1931 0 : m_pAnchorAtFrameRB->IsChecked() );
1932 :
1933 0 : RndStdIds eId = GetAnchor();
1934 :
1935 0 : InitPos( eId, -1, 0, -1, 0, LONG_MAX, LONG_MAX);
1936 0 : RangeModifyHdl(0);
1937 :
1938 0 : if(bHtmlMode)
1939 : {
1940 0 : PosHdl(m_pHorizontalDLB);
1941 0 : PosHdl(m_pVerticalDLB);
1942 : }
1943 :
1944 0 : EnableVerticalPositioning( !(m_bIsMathOLE && m_bIsMathBaselineAlignment
1945 0 : && FLY_AS_CHAR == eId) );
1946 :
1947 0 : return 0;
1948 : }
1949 :
1950 0 : IMPL_LINK( SwFrmPage, PosHdl, ListBox *, pLB )
1951 : {
1952 0 : bool bHori = pLB == m_pHorizontalDLB;
1953 0 : ListBox *pRelLB = bHori ? m_pHoriRelationLB : m_pVertRelationLB;
1954 0 : FixedText *pRelFT = bHori ? m_pHoriRelationFT : m_pVertRelationFT;
1955 0 : FrmMap *pMap = bHori ? pHMap : pVMap;
1956 :
1957 0 : const sal_Int32 nMapPos = GetMapPos(pMap, *pLB);
1958 0 : const sal_Int16 nAlign = GetAlignment(pMap, nMapPos, *pLB, *pRelLB);
1959 :
1960 0 : if (bHori)
1961 : {
1962 0 : bool bEnable = text::HoriOrientation::NONE == nAlign;
1963 0 : m_pAtHorzPosED->Enable( bEnable );
1964 0 : m_pAtHorzPosFT->Enable( bEnable );
1965 : }
1966 : else
1967 : {
1968 0 : bool bEnable = text::VertOrientation::NONE == nAlign && m_bAllowVertPositioning;
1969 0 : m_pAtVertPosED->Enable( bEnable );
1970 0 : m_pAtVertPosFT->Enable( bEnable );
1971 : }
1972 :
1973 0 : RangeModifyHdl( 0 );
1974 :
1975 0 : sal_Int16 nRel = 0;
1976 0 : if (pLB->GetSelectEntryCount())
1977 : {
1978 :
1979 0 : if (pRelLB->GetSelectEntryPos() != LISTBOX_ENTRY_NOTFOUND)
1980 0 : nRel = static_cast<RelationMap *>(pRelLB->GetSelectEntryData())->nRelation;
1981 :
1982 0 : FillRelLB(pMap, nMapPos, nAlign, nRel, *pRelLB, *pRelFT);
1983 : }
1984 : else
1985 0 : pRelLB->Clear();
1986 :
1987 0 : UpdateExample();
1988 :
1989 0 : if (bHori)
1990 0 : bAtHorzPosModified = true;
1991 : else
1992 0 : bAtVertPosModified = true;
1993 :
1994 : // special treatment for HTML-Mode with horizonal-vertical-dependencies
1995 0 : if(bHtmlMode && (FLY_AT_CHAR == GetAnchor()))
1996 : {
1997 0 : bool bSet = false;
1998 0 : if(bHori)
1999 : {
2000 : // right is allowed only above - from the left only above
2001 : // from the left at character -> below
2002 0 : if((text::HoriOrientation::LEFT == nAlign || text::HoriOrientation::RIGHT == nAlign) &&
2003 0 : 0 == m_pVerticalDLB->GetSelectEntryPos())
2004 : {
2005 0 : if(text::RelOrientation::FRAME == nRel)
2006 0 : m_pVerticalDLB->SelectEntryPos(1);
2007 : else
2008 0 : m_pVerticalDLB->SelectEntryPos(0);
2009 0 : bSet = true;
2010 : }
2011 0 : else if(text::HoriOrientation::LEFT == nAlign && 1 == m_pVerticalDLB->GetSelectEntryPos())
2012 : {
2013 0 : m_pVerticalDLB->SelectEntryPos(0);
2014 0 : bSet = true;
2015 : }
2016 0 : else if(text::HoriOrientation::NONE == nAlign && 1 == m_pVerticalDLB->GetSelectEntryPos())
2017 : {
2018 0 : m_pVerticalDLB->SelectEntryPos(0);
2019 0 : bSet = true;
2020 : }
2021 0 : if(bSet)
2022 0 : PosHdl(m_pVerticalDLB);
2023 : }
2024 : else
2025 : {
2026 0 : if(text::VertOrientation::TOP == nAlign)
2027 : {
2028 0 : if(1 == m_pHorizontalDLB->GetSelectEntryPos())
2029 : {
2030 0 : m_pHorizontalDLB->SelectEntryPos(0);
2031 0 : bSet = true;
2032 : }
2033 0 : m_pHoriRelationLB->SelectEntryPos(1);
2034 : }
2035 0 : else if(text::VertOrientation::CHAR_BOTTOM == nAlign)
2036 : {
2037 0 : if(2 == m_pHorizontalDLB->GetSelectEntryPos())
2038 : {
2039 0 : m_pHorizontalDLB->SelectEntryPos(0);
2040 0 : bSet = true;
2041 : }
2042 0 : m_pHoriRelationLB->SelectEntryPos(0) ;
2043 : }
2044 0 : if(bSet)
2045 0 : PosHdl(m_pHorizontalDLB);
2046 : }
2047 :
2048 : }
2049 0 : return 0;
2050 : }
2051 :
2052 : // horizontal Pos
2053 0 : IMPL_LINK( SwFrmPage, RelHdl, ListBox *, pLB )
2054 : {
2055 0 : bool bHori = pLB == m_pHoriRelationLB;
2056 :
2057 0 : UpdateExample();
2058 :
2059 0 : if (bHori)
2060 0 : bAtHorzPosModified = true;
2061 : else
2062 0 : bAtVertPosModified = true;
2063 :
2064 0 : if (bHtmlMode && (FLY_AT_CHAR == GetAnchor()))
2065 : {
2066 0 : if(bHori)
2067 : {
2068 0 : const sal_Int16 nRel = GetRelation(pHMap, *m_pHoriRelationLB);
2069 0 : if(text::RelOrientation::PRINT_AREA == nRel && 0 == m_pVerticalDLB->GetSelectEntryPos())
2070 : {
2071 0 : m_pVerticalDLB->SelectEntryPos(1);
2072 : }
2073 0 : else if(text::RelOrientation::CHAR == nRel && 1 == m_pVerticalDLB->GetSelectEntryPos())
2074 : {
2075 0 : m_pVerticalDLB->SelectEntryPos(0);
2076 : }
2077 : }
2078 : }
2079 0 : if (pLB) // Only when Handler was called by changing of the controller
2080 0 : RangeModifyHdl(0);
2081 :
2082 0 : return 0;
2083 : }
2084 :
2085 0 : IMPL_LINK_NOARG(SwFrmPage, RealSizeHdl)
2086 : {
2087 0 : m_aWidthED.SetUserValue( m_aWidthED. NormalizePercent(aGrfSize.Width() ), FUNIT_TWIP);
2088 0 : m_aHeightED.SetUserValue(m_aHeightED.NormalizePercent(aGrfSize.Height()), FUNIT_TWIP);
2089 0 : fWidthHeightRatio = aGrfSize.Height() ? double(aGrfSize.Width()) / double(aGrfSize.Height()) : 1.0;
2090 0 : UpdateExample();
2091 0 : return 0;
2092 : }
2093 :
2094 0 : IMPL_LINK_NOARG(SwFrmPage, AutoWidthClickHdl)
2095 : {
2096 0 : if( !IsInGraficMode() )
2097 0 : HandleAutoCB( m_pAutoWidthCB->IsChecked(), *m_pWidthFT, *m_pWidthAutoFT, *m_aWidthED.get() );
2098 0 : return 0;
2099 : }
2100 :
2101 0 : IMPL_LINK_NOARG(SwFrmPage, AutoHeightClickHdl)
2102 : {
2103 0 : if( !IsInGraficMode() )
2104 0 : HandleAutoCB( m_pAutoHeightCB->IsChecked(), *m_pHeightFT, *m_pHeightAutoFT, *m_aWidthED.get() );
2105 0 : return 0;
2106 : }
2107 :
2108 0 : IMPL_LINK( SwFrmPage, ModifyHdl, Edit *, pEdit )
2109 : {
2110 0 : SwTwips nWidth = static_cast< SwTwips >(m_aWidthED.DenormalizePercent(m_aWidthED.GetValue(FUNIT_TWIP)));
2111 0 : SwTwips nHeight = static_cast< SwTwips >(m_aHeightED.DenormalizePercent(m_aHeightED.GetValue(FUNIT_TWIP)));
2112 0 : if ( m_pFixedRatioCB->IsChecked() )
2113 : {
2114 0 : if (pEdit == m_aWidthED.get())
2115 : {
2116 0 : nHeight = SwTwips((double)nWidth / fWidthHeightRatio);
2117 0 : m_aHeightED.SetPrcntValue(m_aHeightED.NormalizePercent(nHeight), FUNIT_TWIP);
2118 : }
2119 0 : else if (pEdit == m_aHeightED.get())
2120 : {
2121 0 : nWidth = SwTwips((double)nHeight * fWidthHeightRatio);
2122 0 : m_aWidthED.SetPrcntValue(m_aWidthED.NormalizePercent(nWidth), FUNIT_TWIP);
2123 : }
2124 : }
2125 0 : fWidthHeightRatio = nHeight ? double(nWidth) / double(nHeight) : 1.0;
2126 0 : UpdateExample();
2127 0 : return 0;
2128 : }
2129 :
2130 0 : void SwFrmPage::UpdateExample()
2131 : {
2132 0 : sal_Int32 nPos = m_pHorizontalDLB->GetSelectEntryPos();
2133 0 : if ( pHMap && nPos != LISTBOX_ENTRY_NOTFOUND )
2134 : {
2135 0 : const sal_Int32 nMapPos = GetMapPos(pHMap, *m_pHorizontalDLB);
2136 0 : m_pExampleWN->SetHAlign(GetAlignment(pHMap, nMapPos, *m_pHorizontalDLB, *m_pHoriRelationLB));
2137 0 : m_pExampleWN->SetHoriRel(GetRelation(pHMap, *m_pHoriRelationLB));
2138 : }
2139 :
2140 0 : nPos = m_pVerticalDLB->GetSelectEntryPos();
2141 0 : if ( pVMap && nPos != LISTBOX_ENTRY_NOTFOUND )
2142 : {
2143 0 : const sal_Int32 nMapPos = GetMapPos(pVMap, *m_pVerticalDLB);
2144 0 : m_pExampleWN->SetVAlign(GetAlignment(pVMap, nMapPos, *m_pVerticalDLB, *m_pVertRelationLB));
2145 0 : m_pExampleWN->SetVertRel(GetRelation(pVMap, *m_pVertRelationLB));
2146 : }
2147 :
2148 : // size
2149 0 : long nXPos = static_cast< long >(m_pAtHorzPosED->Denormalize(m_pAtHorzPosED->GetValue(FUNIT_TWIP)));
2150 0 : long nYPos = static_cast< long >(m_pAtVertPosED->Denormalize(m_pAtVertPosED->GetValue(FUNIT_TWIP)));
2151 0 : m_pExampleWN->SetRelPos(Point(nXPos, nYPos));
2152 :
2153 0 : m_pExampleWN->SetAnchor( static_cast< sal_Int16 >(GetAnchor()) );
2154 0 : m_pExampleWN->Invalidate();
2155 0 : }
2156 :
2157 0 : void SwFrmPage::Init(const SfxItemSet& rSet, bool bReset)
2158 : {
2159 0 : if(!bFormat)
2160 : {
2161 0 : SwWrtShell* pSh = getFrmDlgParentShell();
2162 :
2163 : // size
2164 0 : const bool bSizeFixed = pSh->IsSelObjProtected( FlyProtectFlags::Fixed ) != FlyProtectFlags::NONE;
2165 :
2166 0 : m_aWidthED .Enable( !bSizeFixed );
2167 0 : m_aHeightED.Enable( !bSizeFixed );
2168 :
2169 : // size controls for math OLE objects
2170 0 : if ( sDlgType == "ObjectDialog" && ! bNew )
2171 : {
2172 : // disable width and height for math objects
2173 0 : const SvGlobalName& rFactNm( pSh->GetOLEObject()->getClassID() );
2174 :
2175 : struct _GlobalNameId {
2176 : sal_uInt32 n1;
2177 : sal_uInt16 n2, n3;
2178 : sal_uInt8 b8, b9, b10, b11, b12, b13, b14, b15;
2179 : } aGlbNmIds[4] = { { SO3_SM_CLASSID_60 }, { SO3_SM_CLASSID_50 },
2180 0 : { SO3_SM_CLASSID_40 }, { SO3_SM_CLASSID_30 } };
2181 :
2182 0 : for ( int i = 0; i < 4; ++i ) {
2183 0 : const _GlobalNameId& rId = aGlbNmIds[ i ];
2184 :
2185 : SvGlobalName aGlbNm( rId.n1, rId.n2, rId.n3,
2186 : rId.b8, rId.b9, rId.b10, rId.b11,
2187 0 : rId.b12, rId.b13, rId.b14, rId.b15 );
2188 :
2189 0 : if( rFactNm == aGlbNm )
2190 : {
2191 : // disable size controls for math OLE objects
2192 0 : m_pWidthFT->Disable();
2193 0 : m_aWidthED.Disable();
2194 0 : m_pRelWidthCB->Disable();
2195 0 : m_pHeightFT->Disable();
2196 0 : m_aHeightED.Disable();
2197 0 : m_pRelHeightCB->Disable();
2198 0 : m_pFixedRatioCB->Disable();
2199 0 : m_pRealSizeBT->Disable();
2200 0 : break;
2201 : }
2202 0 : }
2203 :
2204 : // TODO/LATER: get correct aspect
2205 0 : if(0 != (pSh->GetOLEObject()->getStatus( embed::Aspects::MSOLE_CONTENT ) & embed::EmbedMisc::MS_EMBED_RECOMPOSEONRESIZE ) )
2206 0 : m_pRealSizeBT->Disable();
2207 : }
2208 : }
2209 :
2210 0 : const SwFormatFrmSize& rSize = static_cast<const SwFormatFrmSize&>(rSet.Get(RES_FRM_SIZE));
2211 0 : sal_Int64 nWidth = m_aWidthED.NormalizePercent(rSize.GetWidth());
2212 0 : sal_Int64 nHeight = m_aHeightED.NormalizePercent(rSize.GetHeight());
2213 :
2214 0 : if (nWidth != m_aWidthED.GetValue(FUNIT_TWIP))
2215 : {
2216 0 : if(!bReset)
2217 : {
2218 : // value was changed by circulation-Tabpage and
2219 : // has to be set with Modify-Flag
2220 0 : m_aWidthED.SetUserValue(nWidth, FUNIT_TWIP);
2221 : }
2222 : else
2223 0 : m_aWidthED.SetPrcntValue(nWidth, FUNIT_TWIP);
2224 : }
2225 :
2226 0 : if (nHeight != m_aHeightED.GetValue(FUNIT_TWIP))
2227 : {
2228 0 : if (!bReset)
2229 : {
2230 : // values was changed by circulation-Tabpage and
2231 : // has to be set with Modify-Flag
2232 0 : m_aHeightED.SetUserValue(nHeight, FUNIT_TWIP);
2233 : }
2234 : else
2235 0 : m_aHeightED.SetPrcntValue(nHeight, FUNIT_TWIP);
2236 : }
2237 :
2238 0 : if (!IsInGraficMode())
2239 : {
2240 0 : SwFrmSize eSize = rSize.GetHeightSizeType();
2241 0 : bool bCheck = eSize != ATT_FIX_SIZE;
2242 0 : m_pAutoHeightCB->Check( bCheck );
2243 0 : HandleAutoCB( bCheck, *m_pHeightFT, *m_pHeightAutoFT, *m_aWidthED.get() );
2244 0 : if( eSize == ATT_VAR_SIZE )
2245 0 : m_aHeightED.SetValue( m_aHeightED.GetMin(), FUNIT_NONE );
2246 :
2247 0 : eSize = rSize.GetWidthSizeType();
2248 0 : bCheck = eSize != ATT_FIX_SIZE;
2249 0 : m_pAutoWidthCB->Check( bCheck );
2250 0 : HandleAutoCB( bCheck, *m_pWidthFT, *m_pWidthAutoFT, *m_aWidthED.get() );
2251 0 : if( eSize == ATT_VAR_SIZE )
2252 0 : m_aWidthED.SetValue( m_aWidthED.GetMin(), FUNIT_NONE );
2253 :
2254 0 : if ( !bFormat )
2255 : {
2256 0 : SwWrtShell* pSh = getFrmDlgParentShell();
2257 0 : const SwFrameFormat* pFormat = pSh->GetFlyFrameFormat();
2258 0 : if( pFormat && pFormat->GetChain().GetNext() )
2259 0 : m_pAutoHeightCB->Enable( false );
2260 : }
2261 : }
2262 : else
2263 0 : m_pAutoHeightCB->Hide();
2264 :
2265 : // organise circulation-gap for character bound frames
2266 0 : const SvxULSpaceItem &rUL = static_cast<const SvxULSpaceItem &>(rSet.Get(RES_UL_SPACE));
2267 0 : nUpperBorder = rUL.GetUpper();
2268 0 : nLowerBorder = rUL.GetLower();
2269 :
2270 0 : if(SfxItemState::SET == rSet.GetItemState(FN_KEEP_ASPECT_RATIO))
2271 : {
2272 0 : m_pFixedRatioCB->Check(static_cast<const SfxBoolItem&>(rSet.Get(FN_KEEP_ASPECT_RATIO)).GetValue());
2273 0 : m_pFixedRatioCB->SaveValue();
2274 : }
2275 :
2276 : // columns
2277 0 : SwFormatCol aCol( static_cast<const SwFormatCol&>(rSet.Get(RES_COL)) );
2278 0 : ::FitToActualSize( aCol, (sal_uInt16)rSize.GetWidth() );
2279 :
2280 0 : RndStdIds eAnchorId = (RndStdIds)GetAnchor();
2281 :
2282 0 : if ( bNew && !bFormat )
2283 0 : InitPos(eAnchorId, -1, 0, -1, 0, LONG_MAX, LONG_MAX);
2284 : else
2285 : {
2286 0 : const SwFormatHoriOrient& rHori = static_cast<const SwFormatHoriOrient&>(rSet.Get(RES_HORI_ORIENT));
2287 0 : const SwFormatVertOrient& rVert = static_cast<const SwFormatVertOrient&>(rSet.Get(RES_VERT_ORIENT));
2288 0 : nOldH = rHori.GetHoriOrient();
2289 0 : nOldHRel = rHori.GetRelationOrient();
2290 0 : nOldV = rVert.GetVertOrient(),
2291 0 : nOldVRel = rVert.GetRelationOrient();
2292 :
2293 0 : if (eAnchorId == FLY_AT_PAGE)
2294 : {
2295 0 : if (nOldHRel == text::RelOrientation::FRAME)
2296 0 : nOldHRel = text::RelOrientation::PAGE_FRAME;
2297 0 : else if (nOldHRel == text::RelOrientation::PRINT_AREA)
2298 0 : nOldHRel = text::RelOrientation::PAGE_PRINT_AREA;
2299 0 : if (nOldVRel == text::RelOrientation::FRAME)
2300 0 : nOldVRel = text::RelOrientation::PAGE_FRAME;
2301 0 : else if (nOldVRel == text::RelOrientation::PRINT_AREA)
2302 0 : nOldVRel = text::RelOrientation::PAGE_PRINT_AREA;
2303 : }
2304 :
2305 0 : m_pMirrorPagesCB->Check(rHori.IsPosToggle());
2306 0 : m_pMirrorPagesCB->SaveValue();
2307 :
2308 : InitPos(eAnchorId,
2309 : nOldH,
2310 : nOldHRel,
2311 : nOldV,
2312 : nOldVRel,
2313 : rHori.GetPos(),
2314 0 : rVert.GetPos());
2315 : }
2316 :
2317 : // transparent for example
2318 : // circulation for example
2319 0 : const SwFormatSurround& rSurround = static_cast<const SwFormatSurround&>(rSet.Get(RES_SURROUND));
2320 0 : m_pExampleWN->SetWrap ( static_cast< sal_uInt16 >(rSurround.GetSurround()) );
2321 :
2322 0 : if ( rSurround.GetSurround() == SURROUND_THROUGHT )
2323 : {
2324 0 : const SvxOpaqueItem& rOpaque = static_cast<const SvxOpaqueItem&>(rSet.Get(RES_OPAQUE));
2325 0 : m_pExampleWN->SetTransparent(!rOpaque.GetValue());
2326 : }
2327 :
2328 : // switch to percent if applicable
2329 0 : RangeModifyHdl(&m_aWidthED); // set reference values (for 100%)
2330 :
2331 0 : if (rSize.GetWidthPercent() == 0xff || rSize.GetHeightPercent() == 0xff)
2332 0 : m_pFixedRatioCB->Check(true);
2333 0 : if (rSize.GetWidthPercent() && rSize.GetWidthPercent() != 0xff &&
2334 0 : !m_pRelWidthCB->IsChecked())
2335 : {
2336 0 : m_pRelWidthCB->Check(true);
2337 0 : RelSizeClickHdl(m_pRelWidthCB);
2338 0 : m_aWidthED.SetPrcntValue(rSize.GetWidthPercent(), FUNIT_CUSTOM);
2339 : }
2340 0 : if (rSize.GetHeightPercent() && rSize.GetHeightPercent() != 0xff &&
2341 0 : !m_pRelHeightCB->IsChecked())
2342 : {
2343 0 : m_pRelHeightCB->Check(true);
2344 0 : RelSizeClickHdl(m_pRelHeightCB);
2345 0 : m_aHeightED.SetPrcntValue(rSize.GetHeightPercent(), FUNIT_CUSTOM);
2346 : }
2347 0 : m_pRelWidthCB->SaveValue();
2348 0 : m_pRelHeightCB->SaveValue();
2349 :
2350 0 : if (rSize.GetWidthPercentRelation() == text::RelOrientation::PAGE_FRAME)
2351 0 : m_pRelWidthRelationLB->SelectEntryPos(1);
2352 : else
2353 0 : m_pRelWidthRelationLB->SelectEntryPos(0);
2354 :
2355 0 : if (rSize.GetHeightPercentRelation() == text::RelOrientation::PAGE_FRAME)
2356 0 : m_pRelHeightRelationLB->SelectEntryPos(1);
2357 : else
2358 0 : m_pRelHeightRelationLB->SelectEntryPos(0);
2359 0 : }
2360 :
2361 0 : void SwFrmPage::SetFormatUsed(bool bFormatUsed)
2362 : {
2363 0 : bFormat = bFormatUsed;
2364 0 : if (bFormat)
2365 : {
2366 0 : m_pAnchorFrame->Hide();
2367 : }
2368 0 : }
2369 :
2370 0 : void SwFrmPage::EnableVerticalPositioning( bool bEnable )
2371 : {
2372 0 : m_bAllowVertPositioning = bEnable;
2373 0 : m_pVerticalFT->Enable( bEnable );
2374 0 : m_pVerticalDLB->Enable( bEnable );
2375 0 : m_pAtVertPosFT->Enable( bEnable );
2376 0 : m_pAtVertPosED->Enable( bEnable );
2377 0 : m_pVertRelationFT->Enable( bEnable );
2378 0 : m_pVertRelationLB->Enable( bEnable );
2379 0 : }
2380 :
2381 0 : SwGrfExtPage::SwGrfExtPage(vcl::Window *pParent, const SfxItemSet &rSet)
2382 : : SfxTabPage(pParent, "PicturePage",
2383 : "modules/swriter/ui/picturepage.ui", &rSet)
2384 : , pGrfDlg(0)
2385 0 : , bHtmlMode(false)
2386 : {
2387 0 : get(m_pMirror, "flipframe");
2388 0 : get(m_pMirrorVertBox, "vert");
2389 0 : get(m_pMirrorHorzBox, "hori");
2390 0 : get(m_pAllPagesRB, "allpages");
2391 0 : get(m_pLeftPagesRB, "leftpages");
2392 0 : get(m_pRightPagesRB, "rightpages");
2393 0 : get(m_pConnectED, "entry");
2394 0 : get(m_pBrowseBT, "browse");
2395 0 : get(m_pBmpWin, "preview");
2396 0 : m_pBmpWin->SetBitmapEx(get<FixedImage>("fallback")->GetImage().GetBitmapEx());
2397 :
2398 0 : SetExchangeSupport();
2399 0 : m_pMirrorHorzBox->SetClickHdl( LINK(this, SwGrfExtPage, MirrorHdl));
2400 0 : m_pMirrorVertBox->SetClickHdl( LINK(this, SwGrfExtPage, MirrorHdl));
2401 0 : m_pBrowseBT->SetClickHdl ( LINK(this, SwGrfExtPage, BrowseHdl));
2402 0 : }
2403 :
2404 0 : SwGrfExtPage::~SwGrfExtPage()
2405 : {
2406 0 : disposeOnce();
2407 0 : }
2408 :
2409 0 : void SwGrfExtPage::dispose()
2410 : {
2411 0 : delete pGrfDlg;
2412 0 : m_pMirror.clear();
2413 0 : m_pMirrorVertBox.clear();
2414 0 : m_pMirrorHorzBox.clear();
2415 0 : m_pAllPagesRB.clear();
2416 0 : m_pLeftPagesRB.clear();
2417 0 : m_pRightPagesRB.clear();
2418 0 : m_pBmpWin.clear();
2419 0 : m_pConnectED.clear();
2420 0 : m_pBrowseBT.clear();
2421 0 : SfxTabPage::dispose();
2422 0 : }
2423 :
2424 0 : VclPtr<SfxTabPage> SwGrfExtPage::Create( vcl::Window *pParent, const SfxItemSet *rSet )
2425 : {
2426 0 : return VclPtr<SwGrfExtPage>::Create( pParent, *rSet );
2427 : }
2428 :
2429 0 : void SwGrfExtPage::Reset(const SfxItemSet *rSet)
2430 : {
2431 : const SfxPoolItem* pItem;
2432 0 : const sal_uInt16 nHtmlMode = ::GetHtmlMode(static_cast<const SwDocShell*>(SfxObjectShell::Current()));
2433 0 : bHtmlMode = (nHtmlMode & HTMLMODE_ON) != 0;
2434 :
2435 0 : if( SfxItemState::SET == rSet->GetItemState( FN_PARAM_GRF_CONNECT, true, &pItem)
2436 0 : && static_cast<const SfxBoolItem *>(pItem)->GetValue() )
2437 : {
2438 0 : m_pBrowseBT->Enable();
2439 0 : m_pConnectED->SetReadOnly(false);
2440 : }
2441 :
2442 0 : ActivatePage(*rSet);
2443 0 : }
2444 :
2445 0 : void SwGrfExtPage::ActivatePage(const SfxItemSet& rSet)
2446 : {
2447 0 : const SvxProtectItem& rProt = static_cast<const SvxProtectItem& >(rSet.Get(RES_PROTECT));
2448 0 : bool bProtContent = rProt.IsContentProtected();
2449 :
2450 0 : const SfxPoolItem* pItem = 0;
2451 0 : bool bEnable = false;
2452 0 : bool bEnableMirrorRB = false;
2453 :
2454 0 : SfxItemState eState = rSet.GetItemState(RES_GRFATR_MIRRORGRF, true, &pItem);
2455 0 : if( SfxItemState::UNKNOWN != eState && !bProtContent && !bHtmlMode )
2456 : {
2457 0 : if( SfxItemState::SET != eState )
2458 0 : pItem = &rSet.Get( RES_GRFATR_MIRRORGRF );
2459 :
2460 0 : bEnable = true;
2461 :
2462 0 : MirrorGraph eMirror = static_cast< MirrorGraph >(static_cast<const SwMirrorGrf* >(pItem)->GetValue());
2463 0 : switch( eMirror )
2464 : {
2465 0 : case RES_MIRROR_GRAPH_DONT: break;
2466 0 : case RES_MIRROR_GRAPH_VERT: m_pMirrorHorzBox->Check(true); break;
2467 0 : case RES_MIRROR_GRAPH_HOR: m_pMirrorVertBox->Check(true); break;
2468 0 : case RES_MIRROR_GRAPH_BOTH: m_pMirrorHorzBox->Check(true);
2469 0 : m_pMirrorVertBox->Check(true);
2470 0 : break;
2471 : default:
2472 : ;
2473 : }
2474 :
2475 0 : const int nPos = (static_cast<const SwMirrorGrf* >(pItem)->IsGrfToggle() ? 1 : 0)
2476 0 : + ((eMirror == RES_MIRROR_GRAPH_VERT || eMirror == RES_MIRROR_GRAPH_BOTH) ? 2 : 0);
2477 :
2478 0 : bEnableMirrorRB = nPos != 0;
2479 :
2480 0 : switch (nPos)
2481 : {
2482 : case 1: // mirror at left / even pages
2483 0 : m_pLeftPagesRB->Check();
2484 0 : m_pMirrorHorzBox->Check(true);
2485 0 : break;
2486 : case 2: // mirror on all pages
2487 0 : m_pAllPagesRB->Check();
2488 0 : break;
2489 : case 3: // mirror on right / odd pages
2490 0 : m_pRightPagesRB->Check();
2491 0 : break;
2492 : default:
2493 0 : m_pAllPagesRB->Check();
2494 0 : break;
2495 : }
2496 : }
2497 :
2498 0 : if( SfxItemState::SET == rSet.GetItemState( SID_ATTR_GRAF_GRAPHIC, false, &pItem ) )
2499 : {
2500 0 : const SvxBrushItem& rBrush = *static_cast<const SvxBrushItem*>(pItem);
2501 0 : if( !rBrush.GetGraphicLink().isEmpty() )
2502 : {
2503 0 : aGrfName = aNewGrfName = rBrush.GetGraphicLink();
2504 0 : m_pConnectED->SetText( aNewGrfName );
2505 : }
2506 0 : OUString referer;
2507 : SfxStringItem const * it = static_cast<SfxStringItem const *>(
2508 0 : rSet.GetItem(SID_REFERER));
2509 0 : if (it != 0) {
2510 0 : referer = it->GetValue();
2511 : }
2512 0 : const Graphic* pGrf = rBrush.GetGraphic(referer);
2513 0 : if( pGrf )
2514 0 : m_pBmpWin->SetGraphic( *pGrf );
2515 : }
2516 :
2517 0 : m_pAllPagesRB->Enable(bEnableMirrorRB);
2518 0 : m_pLeftPagesRB->Enable(bEnableMirrorRB);
2519 0 : m_pRightPagesRB->Enable(bEnableMirrorRB);
2520 0 : m_pMirror->Enable(bEnable);
2521 :
2522 0 : m_pAllPagesRB->SaveValue();
2523 0 : m_pLeftPagesRB->SaveValue();
2524 0 : m_pRightPagesRB->SaveValue();
2525 0 : m_pMirrorHorzBox->SaveValue();
2526 0 : m_pMirrorVertBox->SaveValue();
2527 :
2528 0 : m_pBmpWin->MirrorHorz( m_pMirrorVertBox->IsChecked() );
2529 0 : m_pBmpWin->MirrorVert( m_pMirrorHorzBox->IsChecked() );
2530 0 : m_pBmpWin->Invalidate();
2531 0 : }
2532 :
2533 0 : bool SwGrfExtPage::FillItemSet( SfxItemSet *rSet )
2534 : {
2535 0 : bool bModified = false;
2536 0 : if ( m_pMirrorHorzBox->IsValueChangedFromSaved() ||
2537 0 : m_pMirrorVertBox->IsValueChangedFromSaved() ||
2538 0 : m_pAllPagesRB->IsValueChangedFromSaved() ||
2539 0 : m_pLeftPagesRB->IsValueChangedFromSaved() ||
2540 0 : m_pRightPagesRB->IsValueChangedFromSaved() )
2541 : {
2542 0 : bModified = true;
2543 :
2544 0 : bool bHori = false;
2545 :
2546 0 : if (m_pMirrorHorzBox->IsChecked() &&
2547 0 : !m_pLeftPagesRB->IsChecked())
2548 0 : bHori = true;
2549 :
2550 : MirrorGraph eMirror;
2551 0 : eMirror = m_pMirrorVertBox->IsChecked() && bHori ?
2552 : RES_MIRROR_GRAPH_BOTH : bHori ?
2553 0 : RES_MIRROR_GRAPH_VERT : m_pMirrorVertBox->IsChecked() ?
2554 0 : RES_MIRROR_GRAPH_HOR : RES_MIRROR_GRAPH_DONT;
2555 :
2556 0 : bool bMirror = !m_pAllPagesRB->IsChecked();
2557 0 : SwMirrorGrf aMirror( eMirror );
2558 0 : aMirror.SetGrfToggle(bMirror );
2559 0 : rSet->Put( aMirror );
2560 : }
2561 :
2562 0 : if( aGrfName != aNewGrfName || m_pConnectED->IsModified() )
2563 : {
2564 0 : bModified = true;
2565 0 : aGrfName = m_pConnectED->GetText();
2566 : rSet->Put( SvxBrushItem( aGrfName, aFilterName, GPOS_LT,
2567 0 : SID_ATTR_GRAF_GRAPHIC ));
2568 : }
2569 0 : return bModified;
2570 : }
2571 :
2572 0 : SfxTabPage::sfxpg SwGrfExtPage::DeactivatePage(SfxItemSet *_pSet)
2573 : {
2574 0 : if( _pSet )
2575 0 : FillItemSet( _pSet );
2576 0 : return LEAVE_PAGE;
2577 : }
2578 :
2579 0 : IMPL_LINK_NOARG(SwGrfExtPage, BrowseHdl)
2580 : {
2581 0 : if(!pGrfDlg)
2582 : {
2583 : pGrfDlg = new FileDialogHelper(
2584 : ui::dialogs::TemplateDescription::FILEOPEN_LINK_PREVIEW,
2585 0 : SFXWB_GRAPHIC );
2586 0 : pGrfDlg->SetTitle(get<VclFrame>("linkframe")->get_label());
2587 : }
2588 0 : pGrfDlg->SetDisplayDirectory( m_pConnectED->GetText() );
2589 0 : uno::Reference < ui::dialogs::XFilePicker > xFP = pGrfDlg->GetFilePicker();
2590 0 : uno::Reference < ui::dialogs::XFilePickerControlAccess > xCtrlAcc(xFP, uno::UNO_QUERY);
2591 0 : xCtrlAcc->setValue( ui::dialogs::ExtendedFilePickerElementIds::CHECKBOX_LINK, 0, uno::makeAny(true) );
2592 :
2593 0 : if ( pGrfDlg->Execute() == ERRCODE_NONE )
2594 : { // remember selected filter
2595 0 : aFilterName = pGrfDlg->GetCurrentFilter();
2596 0 : aNewGrfName = INetURLObject::decode( pGrfDlg->GetPath(),
2597 : INetURLObject::DECODE_UNAMBIGUOUS,
2598 0 : RTL_TEXTENCODING_UTF8 );
2599 0 : m_pConnectED->SetModifyFlag();
2600 0 : m_pConnectED->SetText( aNewGrfName );
2601 : //reset mirrors because maybe a Bitmap was swapped with
2602 : //another type of graphic that cannot be mirrored.
2603 0 : m_pMirrorVertBox->Check(false);
2604 0 : m_pMirrorHorzBox->Check(false);
2605 0 : m_pAllPagesRB->Enable(false);
2606 0 : m_pLeftPagesRB->Enable(false);
2607 0 : m_pRightPagesRB->Enable(false);
2608 0 : m_pBmpWin->MirrorHorz(false);
2609 0 : m_pBmpWin->MirrorVert(false);
2610 :
2611 0 : Graphic aGraphic;
2612 0 : (void)GraphicFilter::LoadGraphic(pGrfDlg->GetPath(), OUString(), aGraphic);
2613 0 : m_pBmpWin->SetGraphic(aGraphic);
2614 :
2615 0 : bool bEnable = GRAPHIC_BITMAP == aGraphic.GetType() ||
2616 0 : GRAPHIC_GDIMETAFILE == aGraphic.GetType();
2617 0 : m_pMirrorVertBox->Enable(bEnable);
2618 0 : m_pMirrorHorzBox->Enable(bEnable);
2619 0 : m_pAllPagesRB->Enable(bEnable);
2620 0 : m_pLeftPagesRB->Enable(bEnable);
2621 0 : m_pRightPagesRB->Enable(bEnable);
2622 : }
2623 0 : return 0;
2624 : }
2625 :
2626 0 : IMPL_LINK_NOARG(SwGrfExtPage, MirrorHdl)
2627 : {
2628 0 : bool bEnable = m_pMirrorHorzBox->IsChecked();
2629 :
2630 0 : m_pBmpWin->MirrorHorz( m_pMirrorVertBox->IsChecked() );
2631 0 : m_pBmpWin->MirrorVert( bEnable );
2632 :
2633 0 : m_pAllPagesRB->Enable(bEnable);
2634 0 : m_pLeftPagesRB->Enable(bEnable);
2635 0 : m_pRightPagesRB->Enable(bEnable);
2636 :
2637 0 : if (!m_pAllPagesRB->IsChecked() && !m_pLeftPagesRB->IsChecked() && !m_pRightPagesRB->IsChecked())
2638 0 : m_pAllPagesRB->Check();
2639 :
2640 0 : return 0;
2641 : }
2642 :
2643 : // example window
2644 0 : BmpWindow::BmpWindow(vcl::Window* pPar, WinBits nStyle)
2645 : : Window(pPar, nStyle)
2646 : , bHorz(false)
2647 : , bVert(false)
2648 : , bGraphic(false)
2649 0 : , bLeftAlign(false)
2650 : {
2651 0 : }
2652 :
2653 0 : Size BmpWindow::GetOptimalSize() const
2654 : {
2655 0 : return LogicToPixel(Size(127 , 66), MapMode(MAP_APPFONT));
2656 : }
2657 :
2658 0 : VCL_BUILDER_FACTORY_ARGS(BmpWindow, 0)
2659 :
2660 0 : void BmpWindow::Paint(vcl::RenderContext& rRenderContext, const Rectangle&)
2661 : {
2662 : // Setup
2663 0 : rRenderContext.SetBackground();
2664 0 : SetPaintTransparent(true);
2665 : // #i119307# the graphic might have transparency, set up white as the color
2666 : // to use when drawing a rectangle under the image
2667 0 : rRenderContext.SetLineColor(COL_WHITE);
2668 0 : rRenderContext.SetFillColor(COL_WHITE);
2669 :
2670 : // Paint
2671 0 : Point aPntPos;
2672 0 : Size aPntSz(GetSizePixel());
2673 0 : Size aGrfSize;
2674 0 : if (bGraphic)
2675 0 : aGrfSize = ::GetGraphicSizeTwip(aGraphic, &rRenderContext);
2676 : //it should show the default bitmap also if no graphic can be found
2677 0 : if (!aGrfSize.Width() && !aGrfSize.Height())
2678 0 : aGrfSize = rRenderContext.PixelToLogic(aBmp.GetSizePixel());
2679 :
2680 0 : long nRelGrf = aGrfSize.Width() * 100L / aGrfSize.Height();
2681 0 : long nRelWin = aPntSz.Width() * 100L / aPntSz.Height();
2682 0 : if (nRelGrf < nRelWin)
2683 : {
2684 0 : const long nWidth = aPntSz.Width();
2685 : // if we use a replacement preview, try to draw at original size
2686 0 : if (!bGraphic && (aGrfSize.Width() <= aPntSz.Width())
2687 0 : && (aGrfSize.Height() <= aPntSz.Height()))
2688 : {
2689 0 : const long nHeight = aPntSz.Height();
2690 0 : aPntSz.Width() = aGrfSize.Width();
2691 0 : aPntSz.Height() = aGrfSize.Height();
2692 0 : aPntPos.Y() += (nHeight - aPntSz.Height()) / 2;
2693 : }
2694 : else
2695 0 : aPntSz.Width() = aPntSz.Height() * nRelGrf /100;
2696 :
2697 0 : if (!bLeftAlign)
2698 0 : aPntPos.X() += nWidth - aPntSz.Width() ;
2699 : }
2700 :
2701 : // #i119307# clear window background, the graphic might have transparency
2702 0 : rRenderContext.DrawRect(Rectangle(aPntPos, aPntSz));
2703 :
2704 0 : if (bHorz || bVert)
2705 : {
2706 0 : BitmapEx aTmpBmp(bGraphic ? aGraphic.GetBitmapEx() : aBmp);
2707 0 : BmpMirrorFlags nMirrorFlags(BmpMirrorFlags::NONE);
2708 0 : if (bHorz)
2709 0 : nMirrorFlags |= BmpMirrorFlags::Vertical;
2710 0 : if (bVert)
2711 0 : nMirrorFlags |= BmpMirrorFlags::Horizontal;
2712 0 : aTmpBmp.Mirror(nMirrorFlags);
2713 0 : rRenderContext.DrawBitmapEx(aPntPos, aPntSz, aTmpBmp);
2714 : }
2715 0 : else if (bGraphic) //draw unmirrored preview graphic
2716 : {
2717 0 : aGraphic.Draw(&rRenderContext, aPntPos, aPntSz);
2718 : }
2719 : else //draw unmirrored stock sample image
2720 : {
2721 0 : rRenderContext.DrawBitmapEx(aPntPos, aPntSz, aBmp);
2722 : }
2723 0 : }
2724 :
2725 0 : BmpWindow::~BmpWindow()
2726 : {
2727 0 : }
2728 :
2729 0 : void BmpWindow::SetGraphic(const Graphic& rGraphic)
2730 : {
2731 0 : aGraphic = rGraphic;
2732 0 : Size aSize = aGraphic.GetPrefSize();
2733 0 : bGraphic = aSize.Width() && aSize.Height();
2734 0 : Invalidate();
2735 0 : }
2736 :
2737 0 : void BmpWindow::SetBitmapEx(const BitmapEx& rBmp)
2738 : {
2739 0 : aBmp = rBmp;
2740 0 : Invalidate();
2741 0 : }
2742 :
2743 : // set URL and ImageMap at frames
2744 0 : SwFrmURLPage::SwFrmURLPage( vcl::Window *pParent, const SfxItemSet &rSet ) :
2745 0 : SfxTabPage(pParent, "FrmURLPage" , "modules/swriter/ui/frmurlpage.ui", &rSet)
2746 : {
2747 0 : get(pURLED,"url");
2748 0 : get(pSearchPB,"search");
2749 0 : get(pNameED,"name");
2750 0 : get(pFrameCB,"frame");
2751 :
2752 0 : get(pServerCB,"server");
2753 0 : get(pClientCB,"client");
2754 :
2755 0 : pSearchPB->SetClickHdl(LINK(this, SwFrmURLPage, InsertFileHdl));
2756 0 : }
2757 :
2758 0 : SwFrmURLPage::~SwFrmURLPage()
2759 : {
2760 0 : disposeOnce();
2761 0 : }
2762 :
2763 0 : void SwFrmURLPage::dispose()
2764 : {
2765 0 : pURLED.clear();
2766 0 : pSearchPB.clear();
2767 0 : pNameED.clear();
2768 0 : pFrameCB.clear();
2769 0 : pServerCB.clear();
2770 0 : pClientCB.clear();
2771 0 : SfxTabPage::dispose();
2772 0 : }
2773 :
2774 0 : void SwFrmURLPage::Reset( const SfxItemSet *rSet )
2775 : {
2776 : const SfxPoolItem* pItem;
2777 0 : if ( SfxItemState::SET == rSet->GetItemState( SID_DOCFRAME, true, &pItem))
2778 : {
2779 0 : boost::scoped_ptr<TargetList> pList(new TargetList);
2780 0 : static_cast<const SfxFrameItem*>(pItem)->GetFrame()->GetTargetList(*pList);
2781 0 : if( !pList->empty() )
2782 : {
2783 0 : size_t nCount = pList->size();
2784 0 : for ( size_t i = 0; i < nCount; i++ )
2785 : {
2786 0 : pFrameCB->InsertEntry( pList->at( i ) );
2787 : }
2788 0 : }
2789 : }
2790 :
2791 0 : if ( SfxItemState::SET == rSet->GetItemState( RES_URL, true, &pItem ) )
2792 : {
2793 0 : const SwFormatURL* pFormatURL = static_cast<const SwFormatURL*>(pItem);
2794 0 : pURLED->SetText( INetURLObject::decode( pFormatURL->GetURL(),
2795 : INetURLObject::DECODE_UNAMBIGUOUS,
2796 0 : RTL_TEXTENCODING_UTF8 ));
2797 0 : pNameED->SetText( pFormatURL->GetName());
2798 :
2799 0 : pClientCB->Enable( pFormatURL->GetMap() != 0 );
2800 0 : pClientCB->Check ( pFormatURL->GetMap() != 0 );
2801 0 : pServerCB->Check ( pFormatURL->IsServerMap() );
2802 :
2803 0 : pFrameCB->SetText(pFormatURL->GetTargetFrameName());
2804 0 : pFrameCB->SaveValue();
2805 : }
2806 : else
2807 0 : pClientCB->Enable( false );
2808 :
2809 0 : pServerCB->SaveValue();
2810 0 : pClientCB->SaveValue();
2811 0 : }
2812 :
2813 0 : bool SwFrmURLPage::FillItemSet(SfxItemSet *rSet)
2814 : {
2815 0 : bool bModified = false;
2816 0 : const SwFormatURL* pOldURL = static_cast<const SwFormatURL*>(GetOldItem(*rSet, RES_URL));
2817 0 : boost::scoped_ptr<SwFormatURL> pFormatURL;
2818 0 : if(pOldURL)
2819 0 : pFormatURL.reset(static_cast<SwFormatURL*>(pOldURL->Clone()));
2820 : else
2821 0 : pFormatURL.reset(new SwFormatURL());
2822 :
2823 : {
2824 0 : const OUString sText = pURLED->GetText();
2825 :
2826 0 : if( pFormatURL->GetURL() != sText ||
2827 0 : pFormatURL->GetName() != pNameED->GetText() ||
2828 0 : pServerCB->IsChecked() != pFormatURL->IsServerMap() )
2829 : {
2830 0 : pFormatURL->SetURL( sText, pServerCB->IsChecked() );
2831 0 : pFormatURL->SetName( pNameED->GetText() );
2832 0 : bModified = true;
2833 0 : }
2834 : }
2835 :
2836 0 : if(!pClientCB->IsChecked() && pFormatURL->GetMap() != 0)
2837 : {
2838 0 : pFormatURL->SetMap(0);
2839 0 : bModified = true;
2840 : }
2841 :
2842 0 : if(pFormatURL->GetTargetFrameName() != pFrameCB->GetText())
2843 : {
2844 0 : pFormatURL->SetTargetFrameName(pFrameCB->GetText());
2845 0 : bModified = true;
2846 : }
2847 0 : rSet->Put(*pFormatURL);
2848 0 : return bModified;
2849 : }
2850 :
2851 0 : VclPtr<SfxTabPage> SwFrmURLPage::Create(vcl::Window *pParent, const SfxItemSet *rSet)
2852 : {
2853 0 : return VclPtr<SwFrmURLPage>::Create( pParent, *rSet );
2854 : }
2855 :
2856 0 : IMPL_LINK_NOARG(SwFrmURLPage, InsertFileHdl)
2857 : {
2858 0 : FileDialogHelper aDlgHelper( ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE, 0 );
2859 0 : uno::Reference < ui::dialogs::XFilePicker > xFP = aDlgHelper.GetFilePicker();
2860 :
2861 : try
2862 : {
2863 0 : const OUString sTemp(pURLED->GetText());
2864 0 : if(!sTemp.isEmpty())
2865 0 : xFP->setDisplayDirectory(sTemp);
2866 : }
2867 0 : catch( const uno::Exception& rEx )
2868 : {
2869 : (void) rEx;
2870 : }
2871 0 : if( aDlgHelper.Execute() == ERRCODE_NONE )
2872 : {
2873 0 : pURLED->SetText( xFP->getFiles().getConstArray()[0] );
2874 : }
2875 :
2876 0 : return 0;
2877 : }
2878 :
2879 0 : SwFrmAddPage::SwFrmAddPage(vcl::Window *pParent, const SfxItemSet &rSet)
2880 : : SfxTabPage(pParent, "FrmAddPage" , "modules/swriter/ui/frmaddpage.ui", &rSet)
2881 : , pWrtSh(0)
2882 : , bHtmlMode(false)
2883 : , bFormat(false)
2884 0 : , bNew(false)
2885 : {
2886 0 : get(pNameFrame, "nameframe");
2887 0 : get(pNameFT,"name_label");
2888 0 : get(pNameED,"name");
2889 0 : get(pAltNameFT,"altname_label");
2890 0 : get(pAltNameED,"altname");
2891 0 : get(pPrevFT,"prev_label");
2892 0 : get(pPrevLB,"prev");
2893 0 : get(pNextFT,"next_label");
2894 0 : get(pNextLB,"next");
2895 :
2896 0 : get(pProtectFrame,"protect");
2897 0 : get(pProtectContentCB,"protectcontent");
2898 0 : get(pProtectFrameCB,"protectframe");
2899 0 : get(pProtectSizeCB,"protectsize");
2900 :
2901 0 : get(m_pContentAlignFrame, "contentalign");
2902 0 : get(m_pVertAlignLB,"vertalign");
2903 :
2904 0 : get(pPropertiesFrame,"properties");
2905 0 : get(pEditInReadonlyCB,"editinreadonly");
2906 0 : get(pPrintFrameCB,"printframe");
2907 0 : get(pTextFlowFT,"textflow_label");
2908 0 : get(pTextFlowLB,"textflow");
2909 :
2910 0 : }
2911 :
2912 0 : SwFrmAddPage::~SwFrmAddPage()
2913 : {
2914 0 : disposeOnce();
2915 0 : }
2916 :
2917 0 : void SwFrmAddPage::dispose()
2918 : {
2919 0 : pNameFrame.clear();
2920 0 : pNameFT.clear();
2921 0 : pNameED.clear();
2922 0 : pAltNameFT.clear();
2923 0 : pAltNameED.clear();
2924 0 : pPrevFT.clear();
2925 0 : pPrevLB.clear();
2926 0 : pNextFT.clear();
2927 0 : pNextLB.clear();
2928 0 : pProtectFrame.clear();
2929 0 : pProtectContentCB.clear();
2930 0 : pProtectFrameCB.clear();
2931 0 : pProtectSizeCB.clear();
2932 0 : m_pContentAlignFrame.clear();
2933 0 : m_pVertAlignLB.clear();
2934 0 : pPropertiesFrame.clear();
2935 0 : pEditInReadonlyCB.clear();
2936 0 : pPrintFrameCB.clear();
2937 0 : pTextFlowFT.clear();
2938 0 : pTextFlowLB.clear();
2939 0 : SfxTabPage::dispose();
2940 0 : }
2941 :
2942 :
2943 0 : VclPtr<SfxTabPage> SwFrmAddPage::Create(vcl::Window *pParent, const SfxItemSet *rSet)
2944 : {
2945 0 : return VclPtr<SwFrmAddPage>::Create(pParent, *rSet);
2946 : }
2947 :
2948 0 : void SwFrmAddPage::Reset(const SfxItemSet *rSet )
2949 : {
2950 : const SfxPoolItem* pItem;
2951 0 : sal_uInt16 nHtmlMode = ::GetHtmlMode(static_cast<const SwDocShell*>(SfxObjectShell::Current()));
2952 0 : bHtmlMode = (nHtmlMode & HTMLMODE_ON) != 0;
2953 0 : if (bHtmlMode)
2954 : {
2955 0 : pProtectFrame->Hide();
2956 0 : pEditInReadonlyCB->Hide();
2957 0 : pPrintFrameCB->Hide();
2958 : }
2959 0 : if (sDlgType == "PictureDialog" || sDlgType == "ObjectDialog")
2960 : {
2961 0 : pEditInReadonlyCB->Hide();
2962 0 : if (bHtmlMode)
2963 : {
2964 0 : pPropertiesFrame->Hide();
2965 : }
2966 0 : m_pContentAlignFrame->Hide();
2967 : }
2968 :
2969 0 : if(SfxItemState::SET == rSet->GetItemState(FN_SET_FRM_ALT_NAME, false, &pItem))
2970 : {
2971 0 : pAltNameED->SetText(static_cast<const SfxStringItem*>(pItem)->GetValue());
2972 0 : pAltNameED->SaveValue();
2973 : }
2974 :
2975 0 : if(!bFormat)
2976 : {
2977 : // insert graphic - properties
2978 : // bNew is not set, so recognise by selection
2979 0 : OUString aTmpName1;
2980 0 : if(SfxItemState::SET == rSet->GetItemState(FN_SET_FRM_NAME, false, &pItem))
2981 : {
2982 0 : aTmpName1 = static_cast<const SfxStringItem*>(pItem)->GetValue();
2983 : }
2984 :
2985 : OSL_ENSURE(pWrtSh, "keine Shell?");
2986 0 : if( bNew || aTmpName1.isEmpty() )
2987 : {
2988 0 : if (sDlgType == "PictureDialog")
2989 0 : aTmpName1 = pWrtSh->GetUniqueGrfName();
2990 0 : else if (sDlgType == "ObjectDialog")
2991 0 : aTmpName1 = pWrtSh->GetUniqueOLEName();
2992 : else
2993 0 : aTmpName1 = pWrtSh->GetUniqueFrameName();
2994 :
2995 0 : pWrtSh->SetFlyName(aTmpName1);
2996 : }
2997 :
2998 0 : pNameED->SetText( aTmpName1 );
2999 0 : pNameED->SaveValue();
3000 : }
3001 : else
3002 : {
3003 0 : pNameED->Enable( false );
3004 0 : pAltNameED->Enable(false);
3005 0 : pNameFT->Enable( false );
3006 0 : pAltNameFT->Enable(false);
3007 : }
3008 0 : if (sDlgType == "FrameDialog" && pAltNameFT->IsVisible())
3009 : {
3010 0 : pAltNameFT->Hide();
3011 0 : pAltNameED->Hide();
3012 : }
3013 : else
3014 : {
3015 0 : pNameED->SetModifyHdl(LINK(this, SwFrmAddPage, EditModifyHdl));
3016 : }
3017 :
3018 0 : if (!bNew)
3019 : {
3020 0 : SwFrameFormat* pFormat = pWrtSh->GetFlyFrameFormat();
3021 :
3022 0 : if (pFormat)
3023 : {
3024 0 : const SwFormatChain &rChain = pFormat->GetChain();
3025 : const SwFlyFrameFormat* pFlyFormat;
3026 0 : OUString sNextChain, sPrevChain;
3027 0 : if ((pFlyFormat = rChain.GetPrev()) != 0)
3028 : {
3029 0 : sPrevChain = pFlyFormat->GetName();
3030 : }
3031 :
3032 0 : if ((pFlyFormat = rChain.GetNext()) != 0)
3033 : {
3034 0 : sNextChain = pFlyFormat->GetName();
3035 : }
3036 : //determine chainable frames
3037 0 : ::std::vector< OUString > aPrevPageFrames;
3038 0 : ::std::vector< OUString > aThisPageFrames;
3039 0 : ::std::vector< OUString > aNextPageFrames;
3040 0 : ::std::vector< OUString > aRemainFrames;
3041 : pWrtSh->GetConnectableFrameFormats(*pFormat, sNextChain, false,
3042 0 : aPrevPageFrames, aThisPageFrames, aNextPageFrames, aRemainFrames );
3043 0 : lcl_InsertVectors(*pPrevLB, aPrevPageFrames, aThisPageFrames, aNextPageFrames, aRemainFrames);
3044 0 : if(!sPrevChain.isEmpty())
3045 : {
3046 0 : if(LISTBOX_ENTRY_NOTFOUND == pPrevLB->GetEntryPos(sPrevChain))
3047 0 : pPrevLB->InsertEntry(sPrevChain, 1);
3048 0 : pPrevLB->SelectEntry(sPrevChain);
3049 : }
3050 : else
3051 0 : pPrevLB->SelectEntryPos(0);
3052 0 : aPrevPageFrames.erase(aPrevPageFrames.begin(), aPrevPageFrames.end());
3053 0 : aNextPageFrames.erase(aNextPageFrames.begin(), aNextPageFrames.end());
3054 0 : aThisPageFrames.erase(aThisPageFrames.begin(), aThisPageFrames.end());
3055 0 : aRemainFrames.erase(aRemainFrames.begin(), aRemainFrames.end());
3056 :
3057 : pWrtSh->GetConnectableFrameFormats(*pFormat, sPrevChain, true,
3058 0 : aPrevPageFrames, aThisPageFrames, aNextPageFrames, aRemainFrames );
3059 0 : lcl_InsertVectors(*pNextLB, aPrevPageFrames, aThisPageFrames, aNextPageFrames, aRemainFrames);
3060 0 : if(!sNextChain.isEmpty())
3061 : {
3062 0 : if(LISTBOX_ENTRY_NOTFOUND == pNextLB->GetEntryPos(sNextChain))
3063 0 : pNextLB->InsertEntry(sNextChain, 1);
3064 0 : pNextLB->SelectEntry(sNextChain);
3065 : }
3066 : else
3067 0 : pNextLB->SelectEntryPos(0);
3068 0 : Link<> aLink(LINK(this, SwFrmAddPage, ChainModifyHdl));
3069 0 : pPrevLB->SetSelectHdl(aLink);
3070 0 : pNextLB->SetSelectHdl(aLink);
3071 : }
3072 : }
3073 : // Pos Protected
3074 0 : const SvxProtectItem& rProt = static_cast<const SvxProtectItem& >(rSet->Get(RES_PROTECT));
3075 0 : pProtectFrameCB->Check(rProt.IsPosProtected());
3076 0 : pProtectContentCB->Check(rProt.IsContentProtected());
3077 0 : pProtectSizeCB->Check(rProt.IsSizeProtected());
3078 :
3079 0 : const SwFormatEditInReadonly& rEdit = static_cast<const SwFormatEditInReadonly& >(rSet->Get(RES_EDIT_IN_READONLY));
3080 0 : pEditInReadonlyCB->Check(rEdit.GetValue()); pEditInReadonlyCB->SaveValue();
3081 :
3082 : // print
3083 0 : const SvxPrintItem& rPrt = static_cast<const SvxPrintItem&>(rSet->Get(RES_PRINT));
3084 0 : pPrintFrameCB->Check(rPrt.GetValue()); pPrintFrameCB->SaveValue();
3085 :
3086 : // textflow
3087 : SfxItemState eState;
3088 0 : if( (!bHtmlMode || (0 != (nHtmlMode&HTMLMODE_SOME_STYLES)))
3089 0 : && sDlgType != "PictureDialog" && sDlgType != "ObjectDialog" &&
3090 : SfxItemState::UNKNOWN != ( eState = rSet->GetItemState(
3091 : RES_FRAMEDIR, true )) )
3092 : {
3093 0 : pTextFlowFT->Show();
3094 0 : pTextFlowLB->Show();
3095 :
3096 : //vertical text flow is not possible in HTML
3097 0 : if(bHtmlMode)
3098 : {
3099 0 : sal_uLong nData = FRMDIR_VERT_TOP_RIGHT;
3100 0 : pTextFlowLB->RemoveEntry(pTextFlowLB->GetEntryPos(reinterpret_cast<void*>(nData)));
3101 : }
3102 0 : sal_uInt16 nVal = static_cast<const SvxFrameDirectionItem&>(rSet->Get(RES_FRAMEDIR)).GetValue();
3103 : sal_Int32 nPos;
3104 0 : for( nPos = pTextFlowLB->GetEntryCount(); nPos; )
3105 0 : if( (sal_uInt16)reinterpret_cast<sal_IntPtr>(pTextFlowLB->GetEntryData( --nPos )) == nVal )
3106 0 : break;
3107 0 : pTextFlowLB->SelectEntryPos( nPos );
3108 0 : pTextFlowLB->SaveValue();
3109 : }
3110 : else
3111 : {
3112 0 : pTextFlowFT->Hide();
3113 0 : pTextFlowLB->Hide();
3114 : }
3115 :
3116 : // Content alignment
3117 0 : if ( rSet->GetItemState(RES_TEXT_VERT_ADJUST) > SfxItemState::DEFAULT )
3118 : {
3119 0 : SdrTextVertAdjust nAdjust = static_cast<const SdrTextVertAdjustItem&>(rSet->Get(RES_TEXT_VERT_ADJUST)).GetValue();
3120 0 : sal_Int32 nPos = 0;
3121 0 : switch(nAdjust)
3122 : {
3123 0 : case SDRTEXTVERTADJUST_TOP: nPos = 0; break;
3124 : case SDRTEXTVERTADJUST_CENTER:
3125 0 : case SDRTEXTVERTADJUST_BLOCK: nPos = 1; break;
3126 0 : case SDRTEXTVERTADJUST_BOTTOM: nPos = 2; break;
3127 : }
3128 0 : m_pVertAlignLB->SelectEntryPos(nPos);
3129 : }
3130 0 : m_pVertAlignLB->SaveValue();
3131 0 : }
3132 :
3133 0 : bool SwFrmAddPage::FillItemSet(SfxItemSet *rSet)
3134 : {
3135 0 : bool bRet = false;
3136 0 : if (pNameED->IsValueChangedFromSaved())
3137 0 : bRet |= 0 != rSet->Put(SfxStringItem(FN_SET_FRM_NAME, pNameED->GetText()));
3138 0 : if (pAltNameED->IsValueChangedFromSaved())
3139 0 : bRet |= 0 != rSet->Put(SfxStringItem(FN_SET_FRM_ALT_NAME, pAltNameED->GetText()));
3140 :
3141 : const SfxPoolItem* pOldItem;
3142 0 : SvxProtectItem aProt ( static_cast<const SvxProtectItem& >(GetItemSet().Get(RES_PROTECT)) );
3143 0 : aProt.SetContentProtect( pProtectContentCB->IsChecked() );
3144 0 : aProt.SetSizeProtect ( pProtectSizeCB->IsChecked() );
3145 0 : aProt.SetPosProtect ( pProtectFrameCB->IsChecked() );
3146 0 : if ( 0 == (pOldItem = GetOldItem(*rSet, FN_SET_PROTECT)) ||
3147 0 : aProt != *pOldItem )
3148 0 : bRet |= 0 != rSet->Put( aProt);
3149 :
3150 0 : if ( pEditInReadonlyCB->IsValueChangedFromSaved() )
3151 0 : bRet |= 0 != rSet->Put( SwFormatEditInReadonly( RES_EDIT_IN_READONLY, pEditInReadonlyCB->IsChecked()));
3152 :
3153 0 : if ( pPrintFrameCB->IsValueChangedFromSaved() )
3154 0 : bRet |= 0 != rSet->Put( SvxPrintItem( RES_PRINT, pPrintFrameCB->IsChecked()));
3155 :
3156 : // textflow
3157 0 : if( pTextFlowLB->IsVisible() )
3158 : {
3159 0 : sal_Int32 nPos = pTextFlowLB->GetSelectEntryPos();
3160 0 : if( pTextFlowLB->IsValueChangedFromSaved() )
3161 : {
3162 0 : sal_uInt16 nData = (sal_uInt16)reinterpret_cast<sal_IntPtr>(pTextFlowLB->GetEntryData( nPos ));
3163 : bRet |= 0 != rSet->Put( SvxFrameDirectionItem(
3164 0 : (SvxFrameDirection)nData, RES_FRAMEDIR ));
3165 : }
3166 : }
3167 0 : if(pWrtSh)
3168 : {
3169 0 : const SwFrameFormat* pFormat = pWrtSh->GetFlyFrameFormat();
3170 0 : if (pFormat)
3171 : {
3172 0 : OUString sCurrentPrevChain, sCurrentNextChain;
3173 0 : if(pPrevLB->GetSelectEntryPos())
3174 0 : sCurrentPrevChain = pPrevLB->GetSelectEntry();
3175 0 : if(pNextLB->GetSelectEntryPos())
3176 0 : sCurrentNextChain = pNextLB->GetSelectEntry();
3177 0 : const SwFormatChain &rChain = pFormat->GetChain();
3178 : const SwFlyFrameFormat* pFlyFormat;
3179 0 : OUString sNextChain, sPrevChain;
3180 0 : if ((pFlyFormat = rChain.GetPrev()) != 0)
3181 0 : sPrevChain = pFlyFormat->GetName();
3182 :
3183 0 : if ((pFlyFormat = rChain.GetNext()) != 0)
3184 0 : sNextChain = pFlyFormat->GetName();
3185 0 : if(sPrevChain != sCurrentPrevChain)
3186 0 : bRet |= 0 != rSet->Put(SfxStringItem(FN_PARAM_CHAIN_PREVIOUS, sCurrentPrevChain));
3187 0 : if(sNextChain != sCurrentNextChain)
3188 0 : bRet |= 0 != rSet->Put(SfxStringItem(FN_PARAM_CHAIN_NEXT, sCurrentNextChain));
3189 : }
3190 : }
3191 :
3192 0 : if(m_pVertAlignLB->IsValueChangedFromSaved())
3193 : {
3194 : SdrTextVertAdjust nAdjust;
3195 0 : switch(m_pVertAlignLB->GetSelectEntryPos())
3196 : {
3197 : default:
3198 0 : case 0 : nAdjust = SDRTEXTVERTADJUST_TOP; break;
3199 0 : case 1 : nAdjust = SDRTEXTVERTADJUST_CENTER; break;
3200 0 : case 2 : nAdjust = SDRTEXTVERTADJUST_BOTTOM; break;
3201 : }
3202 0 : bRet |= 0 != rSet->Put(SdrTextVertAdjustItem(nAdjust, RES_TEXT_VERT_ADJUST));
3203 : }
3204 :
3205 0 : return bRet;
3206 : }
3207 :
3208 0 : IMPL_LINK_NOARG(SwFrmAddPage, EditModifyHdl)
3209 : {
3210 0 : bool bEnable = !pNameED->GetText().isEmpty();
3211 0 : pAltNameED->Enable(bEnable);
3212 0 : pAltNameFT->Enable(bEnable);
3213 :
3214 0 : return 0;
3215 : }
3216 :
3217 0 : void SwFrmAddPage::SetFormatUsed(bool bFormatUsed)
3218 : {
3219 0 : bFormat = bFormatUsed;
3220 0 : if (bFormat)
3221 : {
3222 0 : pNameFrame->Hide();
3223 : }
3224 0 : }
3225 :
3226 0 : IMPL_LINK(SwFrmAddPage, ChainModifyHdl, ListBox*, pBox)
3227 : {
3228 0 : OUString sCurrentPrevChain, sCurrentNextChain;
3229 0 : if(pPrevLB->GetSelectEntryPos())
3230 0 : sCurrentPrevChain = pPrevLB->GetSelectEntry();
3231 0 : if(pNextLB->GetSelectEntryPos())
3232 0 : sCurrentNextChain = pNextLB->GetSelectEntry();
3233 0 : SwFrameFormat* pFormat = pWrtSh->GetFlyFrameFormat();
3234 0 : if (pFormat)
3235 : {
3236 0 : bool bNextBox = pNextLB == pBox;
3237 0 : ListBox& rChangeLB = bNextBox ? *pPrevLB : *pNextLB;
3238 0 : for(sal_Int32 nEntry = rChangeLB.GetEntryCount(); nEntry > 1; nEntry--)
3239 0 : rChangeLB.RemoveEntry(nEntry - 1);
3240 : //determine chainable frames
3241 0 : ::std::vector< OUString > aPrevPageFrames;
3242 0 : ::std::vector< OUString > aThisPageFrames;
3243 0 : ::std::vector< OUString > aNextPageFrames;
3244 0 : ::std::vector< OUString > aRemainFrames;
3245 0 : pWrtSh->GetConnectableFrameFormats(*pFormat, bNextBox ? sCurrentNextChain : sCurrentPrevChain, !bNextBox,
3246 0 : aPrevPageFrames, aThisPageFrames, aNextPageFrames, aRemainFrames );
3247 : lcl_InsertVectors(rChangeLB,
3248 0 : aPrevPageFrames, aThisPageFrames, aNextPageFrames, aRemainFrames);
3249 0 : const OUString sToSelect = bNextBox ? sCurrentPrevChain : sCurrentNextChain;
3250 0 : if(rChangeLB.GetEntryPos(sToSelect) != LISTBOX_ENTRY_NOTFOUND)
3251 0 : rChangeLB.SelectEntry(sToSelect);
3252 : else
3253 0 : rChangeLB.SelectEntryPos(0);
3254 :
3255 : }
3256 0 : return 0;
3257 0 : }
3258 :
3259 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|