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