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