1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: labfmt.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sw.hxx"
33 #ifdef SW_DLLIMPLEMENTATION
34 #undef SW_DLLIMPLEMENTATION
38 #include <tools/poly.hxx>
39 #include <viewopt.hxx>
41 #include "swtypes.hxx"
55 using namespace ::com::sun::star::uno
;
56 using namespace ::com::sun::star::beans
;
58 // #define ------------------------------------------------------------------
60 #define ROUND(x) ((USHORT) ((x) + .5))
62 // --------------------------------------------------------------------------
63 SwLabPreview::SwLabPreview( const SwLabFmtPage
* pParent
, const ResId
& rResID
) :
65 Window((Window
*) pParent
, rResID
),
67 aGrayColor(COL_LIGHTGRAY
),
69 aHDistStr (SW_RES(STR_HDIST
)),
70 aVDistStr (SW_RES(STR_VDIST
)),
71 aWidthStr (SW_RES(STR_WIDTH
)),
72 aHeightStr(SW_RES(STR_HEIGHT
)),
73 aLeftStr (SW_RES(STR_LEFT
)),
74 aUpperStr (SW_RES(STR_UPPER
)),
75 aColsStr (SW_RES(STR_COLS
)),
76 aRowsStr (SW_RES(STR_ROWS
))
78 SetMapMode(MAP_PIXEL
);
80 const StyleSettings
& rStyleSettings
= GetSettings().GetStyleSettings();
81 const Color
& rWinColor
= rStyleSettings
.GetWindowColor();
82 SetBackground(Wallpaper(rWinColor
));
84 Font aFont
= GetFont();
85 aFont
.SetTransparent(TRUE
);
86 aFont
.SetWeight (WEIGHT_NORMAL
);
89 const Size
aSz(GetOutputSizePixel());
91 lOutWPix
= aSz
.Width ();
92 lOutHPix
= aSz
.Height();
95 lHDistWidth
= GetTextWidth(aHDistStr
);
96 lVDistWidth
= GetTextWidth(aVDistStr
);
97 lHeightWidth
= GetTextWidth(aHeightStr
);
98 lLeftWidth
= GetTextWidth(aLeftStr
);
99 lUpperWidth
= GetTextWidth(aUpperStr
);
100 lColsWidth
= GetTextWidth(aColsStr
);
102 lXHeight
= GetTextHeight();
103 lXWidth
= GetTextWidth('X');
106 float fx
= (float)(lOutWPix
- (2 * (lLeftWidth
+ 15))) / (float)lOutWPix
;
108 lOutWPix23
= (long)((float)lOutWPix
* fx
);
109 lOutHPix23
= (long)((float)lOutHPix
* fx
);
112 // --------------------------------------------------------------------------
113 SwLabPreview::~SwLabPreview()
116 // --------------------------------------------------------------------------
117 void SwLabPreview::Paint(const Rectangle
&)
119 const StyleSettings
& rStyleSettings
= GetSettings().GetStyleSettings();
120 const Color
& rWinColor
= rStyleSettings
.GetWindowColor();
121 const Color
& rFieldTextColor
= SwViewOption::GetFontColor();
123 Font aFont
= GetFont();
124 aFont
.SetFillColor( rWinColor
);
125 aFont
.SetColor(rFieldTextColor
);
128 SetBackground(Wallpaper(rWinColor
));
130 SetLineColor(rWinColor
);
131 SetFillColor(aGrayColor
);
132 Font
aPaintFont(GetFont());
133 aPaintFont
.SetTransparent(FALSE
);
136 // Groesse des darzustellenden Bereichs
137 long lDispW
= ROUND(aItem
.lLeft
+ aItem
.lHDist
);
138 long lDispH
= ROUND(aItem
.lUpper
+ aItem
.lVDist
);
139 if (aItem
.nCols
== 1)
140 lDispW
+= ROUND(aItem
.lLeft
);
142 lDispW
+= ROUND(aItem
.lHDist
/ 10);
143 if (aItem
.nRows
== 1)
144 lDispH
+= ROUND(aItem
.lUpper
);
146 lDispH
+= ROUND(aItem
.lVDist
/ 10);
149 float fx
= (float) lOutWPix23
/ Max(1L, lDispW
),
150 fy
= (float) lOutHPix23
/ Max(1L, lDispH
),
151 f
= fx
< fy
? fx
: fy
;
154 long lOutlineW
= ROUND(f
* lDispW
);
155 long lOutlineH
= ROUND(f
* lDispH
);
157 long lX0
= (lOutWPix
- lOutlineW
) / 2;
158 long lY0
= (lOutHPix
- lOutlineH
) / 2;
159 long lX1
= ROUND(lX0
+ f
* aItem
.lLeft
);
160 long lY1
= ROUND(lY0
+ f
* aItem
.lUpper
);
161 long lX2
= ROUND(lX0
+ f
* (aItem
.lLeft
+ aItem
.lWidth
));
162 long lY2
= ROUND(lY0
+ f
* (aItem
.lUpper
+ aItem
.lHeight
));
163 long lX3
= ROUND(lX0
+ f
* (aItem
.lLeft
+ aItem
.lHDist
));
164 long lY3
= ROUND(lY0
+ f
* (aItem
.lUpper
+ aItem
.lVDist
));
166 // Umriss zeichnen (Flaeche)
167 DrawRect(Rectangle(Point(lX0
, lY0
), Size(lOutlineW
, lOutlineH
)));
169 // Umriss zeichnen (Umrandung)
170 SetLineColor(rFieldTextColor
);
171 DrawLine(Point(lX0
, lY0
), Point(lX0
+ lOutlineW
- 1, lY0
)); // Oben
172 DrawLine(Point(lX0
, lY0
), Point(lX0
, lY0
+ lOutlineH
- 1)); // Links
173 if (aItem
.nCols
== 1)
174 DrawLine(Point(lX0
+ lOutlineW
- 1, lY0
), Point(lX0
+ lOutlineW
- 1, lY0
+ lOutlineH
- 1)); // Rechts
175 if (aItem
.nRows
== 1)
176 DrawLine(Point(lX0
, lY0
+ lOutlineH
- 1), Point(lX0
+ lOutlineW
- 1, lY0
+ lOutlineH
- 1)); // Unten
179 SetClipRegion (Rectangle(Point(lX0
, lY0
), Size(lOutlineW
, lOutlineH
)));
180 SetFillColor(rWinColor
);
181 for (USHORT nRow
= 0; nRow
< Min((USHORT
) 2, (USHORT
) aItem
.nRows
); nRow
++)
182 for (USHORT nCol
= 0; nCol
< Min((USHORT
) 2, (USHORT
) aItem
.nCols
); nCol
++)
184 Point(ROUND(lX0
+ f
* (aItem
.lLeft
+ nCol
* aItem
.lHDist
)),
185 ROUND(lY0
+ f
* (aItem
.lUpper
+ nRow
* aItem
.lVDist
))),
186 Size (ROUND(f
* aItem
.lWidth
),
187 ROUND(f
* aItem
.lHeight
))));
190 // Beschritung: Rand links
193 long lX
= (lX0
+ lX1
) / 2;
194 DrawArrow(Point(lX0
, lY0
- 5), Point(lX1
, lY0
- 5), FALSE
);
195 DrawArrow(Point(lX
, lY0
- 10), Point(lX
, lY0
- 5), TRUE
);
196 DrawText(Point(lX1
- lLeftWidth
, lY0
- 10 - lXHeight
), aLeftStr
);
199 // Beschriftung: Rand oben
202 DrawArrow(Point(lX0
- 5, lY0
), Point(lX0
- 5, lY1
), FALSE
);
203 DrawText(Point(lX0
- 10 - lUpperWidth
, ROUND(lY0
+ f
* aItem
.lUpper
/ 2 - lXHeight
/ 2)), aUpperStr
);
206 // Beschriftung: Breite und Hoehe
208 long lX
= lX2
- lXWidth
/ 2 - lHeightWidth
/ 2;
209 long lY
= lY1
+ lXHeight
;
211 DrawLine(Point(lX1
, lY
), Point(lX2
- 1, lY
));
212 DrawLine(Point(lX
, lY1
), Point(lX
, lY2
- 1));
214 DrawText(Point(lX1
+ lXWidth
/ 2, lY
- lXHeight
/ 2), aWidthStr
);
215 DrawText(Point(lX
- lHeightWidth
/ 2, lY2
- lXHeight
- lXHeight
/ 2), aHeightStr
);
218 // Beschriftung: Horz. Abstand
221 long lX
= (lX1
+ lX3
) / 2;
222 DrawArrow(Point(lX1
, lY0
- 5), Point(lX3
, lY0
- 5), FALSE
);
223 DrawArrow(Point(lX
, lY0
- 10), Point(lX
, lY0
- 5), TRUE
);
224 DrawText(Point(lX
- lHDistWidth
/ 2, lY0
- 10 - lXHeight
), aHDistStr
);
227 // Beschriftung: Vertikaler Abstand
230 DrawArrow(Point(lX0
- 5, lY1
), Point(lX0
- 5, lY3
), FALSE
);
231 DrawText(Point(lX0
- 10 - lVDistWidth
, ROUND(lY1
+ f
* aItem
.lVDist
/ 2 - lXHeight
/ 2)), aVDistStr
);
234 // Beschriftung: Spalten
236 long lY
= lY0
+ lOutlineH
+ 4;
237 DrawArrow(Point(lX0
, lY
), Point(lX0
+ lOutlineW
- 1, lY
), TRUE
);
238 DrawText(Point((lX0
+ lX0
+ lOutlineW
- 1) / 2 - lColsWidth
/ 2, lY
+ 5), aColsStr
);
241 // Beschriftung: Zeilen
243 long lX
= lX0
+ lOutlineW
+ 4;
244 DrawArrow(Point(lX
, lY0
), Point(lX
, lY0
+ lOutlineH
- 1), TRUE
);
245 DrawText(Point(lX
+ 5, (lY0
+ lY0
+ lOutlineH
- 1 - lXHeight
/ 2) / 2), aRowsStr
);
249 // Pfeil bzw. Intervall zeichnen --------------------------------------------
253 void SwLabPreview::DrawArrow(const Point
&rP1
, const Point
&rP2
, BOOL bArrow
)
262 if (rP1
.Y() == rP2
.Y())
265 aArr
[0].X() = rP2
.X() - 5;
266 aArr
[0].Y() = rP2
.Y() - 2;
267 aArr
[1].X() = rP2
.X();
268 aArr
[1].Y() = rP2
.Y();
269 aArr
[2].X() = rP2
.X() - 5;
270 aArr
[2].Y() = rP2
.Y() + 2;
275 aArr
[0].X() = rP2
.X() - 2;
276 aArr
[0].Y() = rP2
.Y() - 5;
277 aArr
[1].X() = rP2
.X() + 2;
278 aArr
[1].Y() = rP2
.Y() - 5;
279 aArr
[2].X() = rP2
.X();
280 aArr
[2].Y() = rP2
.Y();
283 const Color
& rFieldTextColor
= SwViewOption::GetFontColor();
284 SetFillColor(rFieldTextColor
);
285 DrawPolygon(Polygon(3, aArr
));
289 // Intervall zeichnen
290 if (rP1
.Y() == rP2
.Y())
293 DrawLine(Point(rP1
.X(), rP1
.Y() - 2), Point(rP1
.X(), rP1
.Y() + 2));
294 DrawLine(Point(rP2
.X(), rP2
.Y() - 2), Point(rP2
.X(), rP2
.Y() + 2));
299 DrawLine(Point(rP1
.X() - 2, rP1
.Y()), Point(rP1
.X() + 2, rP1
.Y()));
300 DrawLine(Point(rP2
.X() - 2, rP2
.Y()), Point(rP2
.X() + 2, rP2
.Y()));
305 // --------------------------------------------------------------------------
307 void SwLabPreview::Update(const SwLabItem
& rItem
)
313 // --------------------------------------------------------------------------
317 SwLabFmtPage::SwLabFmtPage(Window
* pParent
, const SfxItemSet
& rSet
) :
319 SfxTabPage(pParent
, SW_RES(TP_LAB_FMT
), rSet
),
320 aMakeFI (this, SW_RES(FI_MAKE
)),
321 aTypeFI (this, SW_RES(FI_TYPE
)),
322 aPreview (this, SW_RES(WIN_PREVIEW
)),
323 aHDistText (this, SW_RES(TXT_HDIST
)),
324 aHDistField (this, SW_RES(FLD_HDIST
)),
325 aVDistText (this, SW_RES(TXT_VDIST
)),
326 aVDistField (this, SW_RES(FLD_VDIST
)),
327 aWidthText (this, SW_RES(TXT_WIDTH
)),
328 aWidthField (this, SW_RES(FLD_WIDTH
)),
329 aHeightText (this, SW_RES(TXT_HEIGHT
)),
330 aHeightField (this, SW_RES(FLD_HEIGHT
)),
331 aLeftText (this, SW_RES(TXT_LEFT
)),
332 aLeftField (this, SW_RES(FLD_LEFT
)),
333 aUpperText (this, SW_RES(TXT_UPPER
)),
334 aUpperField (this, SW_RES(FLD_UPPER
)),
335 aColsText (this, SW_RES(TXT_COLUMNS
)),
336 aColsField (this, SW_RES(FLD_COLUMNS
)),
337 aRowsText (this, SW_RES(TXT_ROWS
)),
338 aRowsField (this, SW_RES(FLD_ROWS
)),
339 aSavePB (this, SW_RES(PB_SAVE
)),
341 aItem ((const SwLabItem
&) rSet
.Get(FN_LABEL
))
344 SetExchangeSupport();
347 FieldUnit aMetric
= ::GetDfltMetric(FALSE
);
348 SetMetric(aHDistField
, aMetric
);
349 SetMetric(aVDistField
, aMetric
);
350 SetMetric(aWidthField
, aMetric
);
351 SetMetric(aHeightField
, aMetric
);
352 SetMetric(aLeftField
, aMetric
);
353 SetMetric(aUpperField
, aMetric
);
355 // Handler installieren
356 Link aLk
= LINK(this, SwLabFmtPage
, ModifyHdl
);
357 aHDistField
.SetModifyHdl( aLk
);
358 aVDistField
.SetModifyHdl( aLk
);
359 aWidthField
.SetModifyHdl( aLk
);
360 aHeightField
.SetModifyHdl( aLk
);
361 aLeftField
.SetModifyHdl( aLk
);
362 aUpperField
.SetModifyHdl( aLk
);
363 aColsField
.SetModifyHdl( aLk
);
364 aRowsField
.SetModifyHdl( aLk
);
366 aLk
= LINK(this, SwLabFmtPage
, LoseFocusHdl
);
367 aHDistField
.SetLoseFocusHdl( aLk
);
368 aVDistField
.SetLoseFocusHdl( aLk
);
369 aWidthField
.SetLoseFocusHdl( aLk
);
370 aHeightField
.SetLoseFocusHdl( aLk
);
371 aLeftField
.SetLoseFocusHdl( aLk
);
372 aUpperField
.SetLoseFocusHdl( aLk
);
373 aColsField
.SetLoseFocusHdl( aLk
);
374 aRowsField
.SetLoseFocusHdl( aLk
);
376 aSavePB
.SetClickHdl( LINK (this, SwLabFmtPage
, SaveHdl
));
378 aPreviewTimer
.SetTimeout(1000);
379 aPreviewTimer
.SetTimeoutHdl(LINK(this, SwLabFmtPage
, PreviewHdl
));
382 // --------------------------------------------------------------------------
386 SwLabFmtPage::~SwLabFmtPage()
390 // Modify-Handler der MetricFields. Preview-Timer starten -------------------
394 IMPL_LINK_INLINE_START( SwLabFmtPage
, ModifyHdl
, Edit
*, EMPTYARG
)
397 aPreviewTimer
.Start();
400 IMPL_LINK_INLINE_END( SwLabFmtPage
, ModifyHdl
, Edit
*, EMPTYARG
)
402 // Preview invalidaten ------------------------------------------------------
406 IMPL_LINK_INLINE_START( SwLabFmtPage
, PreviewHdl
, Timer
*, EMPTYARG
)
408 aPreviewTimer
.Stop();
411 aPreview
.Update( aItem
);
415 IMPL_LINK_INLINE_END( SwLabFmtPage
, PreviewHdl
, Timer
*, EMPTYARG
)
417 // LoseFocus-Handler: Bei Aenderung sofort updaten --------------------------
421 IMPL_LINK_INLINE_START( SwLabFmtPage
, LoseFocusHdl
, Control
*, pControl
)
423 if (((Edit
*) pControl
)->IsModified())
427 IMPL_LINK_INLINE_END( SwLabFmtPage
, LoseFocusHdl
, Control
*, pControl
)
429 // Minima und Maxima fuer Fields festlegen ----------------------------------
432 void SwLabFmtPage::ChangeMinMax()
434 long lMax
= 31748; // 56 cm
438 long lLeft
= static_cast< long >(GETFLDVAL(aLeftField
)),
439 lUpper
= static_cast< long >(GETFLDVAL(aUpperField
)),
440 lHDist
= static_cast< long >(GETFLDVAL(aHDistField
)),
441 lVDist
= static_cast< long >(GETFLDVAL(aVDistField
));
443 long nMinSize
= 10; // 0,1cm
445 aHDistField
.SetMin(nMinSize
, FUNIT_CM
);
446 aVDistField
.SetMin(nMinSize
, FUNIT_CM
);
448 aHDistField
.SetMax((long) 100 * ((lMax
- lLeft
) / Max(1L, (long) aColsField
.GetValue())), FUNIT_TWIP
);
449 aVDistField
.SetMax((long) 100 * ((lMax
- lUpper
) / Max(1L, (long) aRowsField
.GetValue())), FUNIT_TWIP
);
451 aWidthField
.SetMin(nMinSize
, FUNIT_CM
);
452 aHeightField
.SetMin(nMinSize
, FUNIT_CM
);
454 aWidthField
.SetMax((long) 100 * (lHDist
), FUNIT_TWIP
);
455 aHeightField
.SetMax((long) 100 * (lVDist
), FUNIT_TWIP
);
457 aLeftField
.SetMax((long) 100 * (lMax
- (long) aColsField
.GetValue() * GETFLDVAL(aHDistField
)), FUNIT_TWIP
);
458 aUpperField
.SetMax((long) 100 * (lMax
- (long) aRowsField
.GetValue() * GETFLDVAL(aVDistField
)), FUNIT_TWIP
);
460 aColsField
.SetMax((lMax
- lLeft
) / Max(1L, lHDist
));
461 aRowsField
.SetMax((lMax
- lUpper
) / Max(1L, lVDist
));
465 aHDistField
.SetFirst(aHDistField
.GetMin());
466 aVDistField
.SetFirst(aVDistField
.GetMin());
468 aHDistField
.SetLast (aHDistField
.GetMax());
469 aVDistField
.SetLast (aVDistField
.GetMax());
471 aWidthField
.SetFirst(aWidthField
.GetMin());
472 aHeightField
.SetFirst(aHeightField
.GetMin());
474 aWidthField
.SetLast (aWidthField
.GetMax());
475 aHeightField
.SetLast (aHeightField
.GetMax());
477 aLeftField
.SetLast (aLeftField
.GetMax());
478 aUpperField
.SetLast (aUpperField
.GetMax());
480 aColsField
.SetLast (aColsField
.GetMax());
481 aRowsField
.SetLast (aRowsField
.GetMax());
483 aHDistField
.Reformat();
484 aVDistField
.Reformat();
485 aWidthField
.Reformat();
486 aHeightField
.Reformat();
487 aLeftField
.Reformat();
488 aUpperField
.Reformat();
489 aColsField
.Reformat();
490 aRowsField
.Reformat();
493 // --------------------------------------------------------------------------
497 SfxTabPage
* SwLabFmtPage::Create(Window
* pParent
, const SfxItemSet
& rSet
)
499 return new SwLabFmtPage(pParent
, rSet
);
502 // ----------------------------------------------------------------------------
506 void SwLabFmtPage::ActivatePage(const SfxItemSet
& rSet
)
508 SfxItemSet
aSet(rSet
);
512 // ----------------------------------------------------------------------------
516 int SwLabFmtPage::DeactivatePage(SfxItemSet
* _pSet
)
524 // --------------------------------------------------------------------------
528 void SwLabFmtPage::FillItem(SwLabItem
& rItem
)
532 rItem
.aMake
= rItem
.aType
= SW_RESSTR(STR_CUSTOM
);
534 SwLabRec
& rRec
= *GetParent()->Recs()[0];
535 rItem
.lHDist
= rRec
.lHDist
= static_cast< long >(GETFLDVAL(aHDistField
));
536 rItem
.lVDist
= rRec
.lVDist
= static_cast< long >(GETFLDVAL(aVDistField
));
537 rItem
.lWidth
= rRec
.lWidth
= static_cast< long >(GETFLDVAL(aWidthField
));
538 rItem
.lHeight
= rRec
.lHeight
= static_cast< long >(GETFLDVAL(aHeightField
));
539 rItem
.lLeft
= rRec
.lLeft
= static_cast< long >(GETFLDVAL(aLeftField
));
540 rItem
.lUpper
= rRec
.lUpper
= static_cast< long >(GETFLDVAL(aUpperField
));
541 rItem
.nCols
= rRec
.nCols
= (USHORT
) aColsField
.GetValue();
542 rItem
.nRows
= rRec
.nRows
= (USHORT
) aRowsField
.GetValue();
546 // --------------------------------------------------------------------------
550 BOOL
SwLabFmtPage::FillItemSet(SfxItemSet
& rSet
)
558 // --------------------------------------------------------------------------
559 void SwLabFmtPage::Reset(const SfxItemSet
& )
561 // Fields initialisieren
562 GetParent()->GetLabItem(aItem
);
564 aHDistField
.SetMax(100 * aItem
.lHDist
, FUNIT_TWIP
);
565 aVDistField
.SetMax(100 * aItem
.lVDist
, FUNIT_TWIP
);
566 aWidthField
.SetMax(100 * aItem
.lWidth
, FUNIT_TWIP
);
567 aHeightField
.SetMax(100 * aItem
.lHeight
, FUNIT_TWIP
);
568 aLeftField
.SetMax(100 * aItem
.lLeft
, FUNIT_TWIP
);
569 aUpperField
.SetMax(100 * aItem
.lUpper
, FUNIT_TWIP
);
571 SETFLDVAL(aHDistField
, aItem
.lHDist
);
572 SETFLDVAL(aVDistField
, aItem
.lVDist
);
573 SETFLDVAL(aWidthField
, aItem
.lWidth
);
574 SETFLDVAL(aHeightField
, aItem
.lHeight
);
575 SETFLDVAL(aLeftField
, aItem
.lLeft
);
576 SETFLDVAL(aUpperField
, aItem
.lUpper
);
578 aColsField
.SetMax(aItem
.nCols
);
579 aRowsField
.SetMax(aItem
.nRows
);
581 aColsField
.SetValue(aItem
.nCols
);
582 aRowsField
.SetValue(aItem
.nRows
);
583 aMakeFI
.SetText(aItem
.aMake
);
584 aTypeFI
.SetText(aItem
.aType
);
587 /* -----------------------------22.01.01 15:11--------------------------------
589 ---------------------------------------------------------------------------*/
591 IMPL_LINK( SwLabFmtPage
, SaveHdl
, PushButton
*, EMPTYARG
)
594 aRec
.lHDist
= static_cast< long >(GETFLDVAL(aHDistField
));
595 aRec
.lVDist
= static_cast< long >(GETFLDVAL(aVDistField
));
596 aRec
.lWidth
= static_cast< long >(GETFLDVAL(aWidthField
));
597 aRec
.lHeight
= static_cast< long >(GETFLDVAL(aHeightField
));
598 aRec
.lLeft
= static_cast< long >(GETFLDVAL(aLeftField
));
599 aRec
.lUpper
= static_cast< long >(GETFLDVAL(aUpperField
));
600 aRec
.nCols
= (USHORT
) aColsField
.GetValue();
601 aRec
.nRows
= (USHORT
) aRowsField
.GetValue();
602 aRec
.bCont
= aItem
.bCont
;
603 SwSaveLabelDlg
* pSaveDlg
= new SwSaveLabelDlg(this, aRec
);
604 pSaveDlg
->SetLabel(aItem
.aLstMake
, aItem
.aLstType
);
606 if(pSaveDlg
->GetLabel(aItem
))
609 const Sequence
<OUString
>& rMan
= GetParent()->GetLabelsConfig().GetManufacturers();
610 SvStringsDtor
& rMakes
= GetParent()->Makes();
611 if(rMakes
.Count() < (USHORT
)rMan
.getLength())
613 rMakes
.DeleteAndDestroy(0, rMakes
.Count());
614 const OUString
* pMan
= rMan
.getConstArray();
615 for(sal_Int32 nMan
= 0; nMan
< rMan
.getLength(); nMan
++)
617 rMakes
.Insert( new String(pMan
[nMan
]), rMakes
.Count() );
620 aMakeFI
.SetText(aItem
.aMake
);
621 aTypeFI
.SetText(aItem
.aType
);
626 /* -----------------------------23.01.01 10:41--------------------------------
628 ---------------------------------------------------------------------------*/
629 SwSaveLabelDlg::SwSaveLabelDlg(SwLabFmtPage
* pParent
, SwLabRec
& rRec
) :
630 ModalDialog(pParent
, SW_RES(DLG_SAVE_LABEL
)),
631 aOptionsFL(this,SW_RES(FL_OPTIONS
)),
632 aMakeFT(this, SW_RES(FT_MAKE
)),
633 aMakeCB(this, SW_RES(CB_MAKE
)),
634 aTypeFT(this, SW_RES(FT_TYPE
)),
635 aTypeED(this, SW_RES(ED_TYPE
)),
637 aOKPB(this, SW_RES(PB_OK
)),
638 aCancelPB(this, SW_RES(PB_CANCEL
)),
639 aHelpPB(this, SW_RES(PB_HELP
)),
641 aQueryMB(this, SW_RES(MB_QUERY
)),
649 aOKPB
.SetClickHdl(LINK(this, SwSaveLabelDlg
, OkHdl
));
650 Link
aLk(LINK(this, SwSaveLabelDlg
, ModifyHdl
));
651 aMakeCB
.SetModifyHdl(aLk
);
652 aTypeED
.SetModifyHdl(aLk
);
654 SwLabelConfig
& rCfg
= pLabPage
->GetParent()->GetLabelsConfig();
655 const Sequence
<OUString
>& rMan
= rCfg
.GetManufacturers();
656 const OUString
* pMan
= rMan
.getConstArray();
657 for(sal_Int32 i
= 0; i
< rMan
.getLength(); i
++)
658 aMakeCB
.InsertEntry(pMan
[i
]);
660 /* -----------------------------23.01.01 10:40--------------------------------
662 ---------------------------------------------------------------------------*/
663 IMPL_LINK(SwSaveLabelDlg
, OkHdl
, OKButton
*, EMPTYARG
)
665 SwLabelConfig
& rCfg
= pLabPage
->GetParent()->GetLabelsConfig();
666 String
sMake(aMakeCB
.GetText());
667 String
sType(aTypeED
.GetText());
668 if(rCfg
.HasLabel(sMake
, sType
))
670 String
sTmp(aQueryMB
.GetMessText());
672 sQuery
.SearchAndReplace(C2S("%1"), sMake
);
673 sQuery
.SearchAndReplace(C2S("%2"), sType
);
674 aQueryMB
.SetMessText(sQuery
);
676 short eRet
= aQueryMB
.Execute();
677 aQueryMB
.SetMessText(sTmp
);
681 rLabRec
.aType
= sType
;
682 rCfg
.SaveLabel(sMake
, sType
, rLabRec
);
687 /* -----------------------------23.01.01 11:22--------------------------------
689 ---------------------------------------------------------------------------*/
690 IMPL_LINK(SwSaveLabelDlg
, ModifyHdl
, Edit
*, EMPTYARG
)
692 aOKPB
.Enable(aMakeCB
.GetText().Len() && aTypeED
.GetText().Len());
695 /* -----------------------------23.01.01 16:06--------------------------------
697 ---------------------------------------------------------------------------*/
698 sal_Bool
SwSaveLabelDlg::GetLabel(SwLabItem
& rItem
)
702 rItem
.aMake
= aMakeCB
.GetText();
703 rItem
.aType
= aTypeED
.GetText();
704 rItem
.lHDist
= rLabRec
.lHDist
;
705 rItem
.lVDist
= rLabRec
.lVDist
;
706 rItem
.lWidth
= rLabRec
.lWidth
;
707 rItem
.lHeight
= rLabRec
.lHeight
;
708 rItem
.lLeft
= rLabRec
.lLeft
;
709 rItem
.lUpper
= rLabRec
.lUpper
;
710 rItem
.nCols
= rLabRec
.nCols
;
711 rItem
.nRows
= rLabRec
.nRows
;