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