xref: /aoo41x/main/sw/source/ui/envelp/labfmt.cxx (revision cdf0e10c)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_sw.hxx"
30*cdf0e10cSrcweir #ifdef SW_DLLIMPLEMENTATION
31*cdf0e10cSrcweir #undef SW_DLLIMPLEMENTATION
32*cdf0e10cSrcweir #endif
33*cdf0e10cSrcweir 
34*cdf0e10cSrcweir 
35*cdf0e10cSrcweir #include <tools/poly.hxx>
36*cdf0e10cSrcweir #include <viewopt.hxx>
37*cdf0e10cSrcweir 
38*cdf0e10cSrcweir #include "swtypes.hxx"
39*cdf0e10cSrcweir #include "cmdid.h"
40*cdf0e10cSrcweir #include "label.hxx"
41*cdf0e10cSrcweir #include "labimp.hxx"
42*cdf0e10cSrcweir #include "labimg.hxx"
43*cdf0e10cSrcweir #include "labfmt.hxx"
44*cdf0e10cSrcweir #include "uitool.hxx"
45*cdf0e10cSrcweir 
46*cdf0e10cSrcweir #include "label.hrc"
47*cdf0e10cSrcweir #include "labfmt.hrc"
48*cdf0e10cSrcweir #include <unomid.h>
49*cdf0e10cSrcweir 
50*cdf0e10cSrcweir using namespace utl;
51*cdf0e10cSrcweir using namespace rtl;
52*cdf0e10cSrcweir using namespace ::com::sun::star::uno;
53*cdf0e10cSrcweir using namespace ::com::sun::star::beans;
54*cdf0e10cSrcweir 
55*cdf0e10cSrcweir // #define ------------------------------------------------------------------
56*cdf0e10cSrcweir 
57*cdf0e10cSrcweir #define ROUND(x) ((sal_uInt16) ((x) + .5))
58*cdf0e10cSrcweir 
59*cdf0e10cSrcweir // --------------------------------------------------------------------------
60*cdf0e10cSrcweir SwLabPreview::SwLabPreview( const SwLabFmtPage* pParent, const ResId& rResID ) :
61*cdf0e10cSrcweir 
62*cdf0e10cSrcweir 	Window((Window*) pParent, rResID),
63*cdf0e10cSrcweir 
64*cdf0e10cSrcweir     aGrayColor(COL_LIGHTGRAY),
65*cdf0e10cSrcweir 
66*cdf0e10cSrcweir     aHDistStr (SW_RES(STR_HDIST )),
67*cdf0e10cSrcweir 	aVDistStr (SW_RES(STR_VDIST )),
68*cdf0e10cSrcweir 	aWidthStr (SW_RES(STR_WIDTH )),
69*cdf0e10cSrcweir 	aHeightStr(SW_RES(STR_HEIGHT)),
70*cdf0e10cSrcweir 	aLeftStr  (SW_RES(STR_LEFT  )),
71*cdf0e10cSrcweir 	aUpperStr (SW_RES(STR_UPPER )),
72*cdf0e10cSrcweir 	aColsStr  (SW_RES(STR_COLS  )),
73*cdf0e10cSrcweir     aRowsStr  (SW_RES(STR_ROWS  ))
74*cdf0e10cSrcweir {
75*cdf0e10cSrcweir 	SetMapMode(MAP_PIXEL);
76*cdf0e10cSrcweir 
77*cdf0e10cSrcweir     const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
78*cdf0e10cSrcweir     const Color& rWinColor = rStyleSettings.GetWindowColor();
79*cdf0e10cSrcweir     SetBackground(Wallpaper(rWinColor));
80*cdf0e10cSrcweir 
81*cdf0e10cSrcweir     Font aFont = GetFont();
82*cdf0e10cSrcweir     aFont.SetTransparent(sal_True);
83*cdf0e10cSrcweir 	aFont.SetWeight	 (WEIGHT_NORMAL);
84*cdf0e10cSrcweir 	SetFont(aFont);
85*cdf0e10cSrcweir 
86*cdf0e10cSrcweir     const Size aSz(GetOutputSizePixel());
87*cdf0e10cSrcweir 
88*cdf0e10cSrcweir 	lOutWPix   = aSz.Width ();
89*cdf0e10cSrcweir 	lOutHPix   = aSz.Height();
90*cdf0e10cSrcweir 
91*cdf0e10cSrcweir 
92*cdf0e10cSrcweir 	lHDistWidth  = GetTextWidth(aHDistStr );
93*cdf0e10cSrcweir 	lVDistWidth  = GetTextWidth(aVDistStr );
94*cdf0e10cSrcweir 	lHeightWidth = GetTextWidth(aHeightStr);
95*cdf0e10cSrcweir 	lLeftWidth	 = GetTextWidth(aLeftStr  );
96*cdf0e10cSrcweir 	lUpperWidth  = GetTextWidth(aUpperStr );
97*cdf0e10cSrcweir 	lColsWidth	 = GetTextWidth(aColsStr  );
98*cdf0e10cSrcweir 
99*cdf0e10cSrcweir 	lXHeight = GetTextHeight();
100*cdf0e10cSrcweir 	lXWidth  = GetTextWidth('X');
101*cdf0e10cSrcweir 
102*cdf0e10cSrcweir 	// Skalierungsfaktor
103*cdf0e10cSrcweir 	float fx = (float)(lOutWPix - (2 * (lLeftWidth + 15))) / (float)lOutWPix;
104*cdf0e10cSrcweir 
105*cdf0e10cSrcweir 	lOutWPix23 = (long)((float)lOutWPix * fx);
106*cdf0e10cSrcweir 	lOutHPix23 = (long)((float)lOutHPix * fx);
107*cdf0e10cSrcweir }
108*cdf0e10cSrcweir 
109*cdf0e10cSrcweir // --------------------------------------------------------------------------
110*cdf0e10cSrcweir SwLabPreview::~SwLabPreview()
111*cdf0e10cSrcweir {
112*cdf0e10cSrcweir }
113*cdf0e10cSrcweir // --------------------------------------------------------------------------
114*cdf0e10cSrcweir void SwLabPreview::Paint(const Rectangle &)
115*cdf0e10cSrcweir {
116*cdf0e10cSrcweir     const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
117*cdf0e10cSrcweir     const Color& rWinColor = rStyleSettings.GetWindowColor();
118*cdf0e10cSrcweir     const Color& rFieldTextColor = SwViewOption::GetFontColor();
119*cdf0e10cSrcweir 
120*cdf0e10cSrcweir     Font aFont = GetFont();
121*cdf0e10cSrcweir     aFont.SetFillColor( rWinColor );
122*cdf0e10cSrcweir     aFont.SetColor(rFieldTextColor);
123*cdf0e10cSrcweir 	SetFont(aFont);
124*cdf0e10cSrcweir 
125*cdf0e10cSrcweir     SetBackground(Wallpaper(rWinColor));
126*cdf0e10cSrcweir 
127*cdf0e10cSrcweir     SetLineColor(rWinColor);
128*cdf0e10cSrcweir 	SetFillColor(aGrayColor);
129*cdf0e10cSrcweir 	Font aPaintFont(GetFont());
130*cdf0e10cSrcweir 	aPaintFont.SetTransparent(sal_False);
131*cdf0e10cSrcweir 	SetFont(aPaintFont);
132*cdf0e10cSrcweir 
133*cdf0e10cSrcweir 	// Groesse des darzustellenden Bereichs
134*cdf0e10cSrcweir 	long lDispW = ROUND(aItem.lLeft  + aItem.lHDist);
135*cdf0e10cSrcweir 	long lDispH = ROUND(aItem.lUpper + aItem.lVDist);
136*cdf0e10cSrcweir 	if (aItem.nCols == 1)
137*cdf0e10cSrcweir 		lDispW += ROUND(aItem.lLeft );
138*cdf0e10cSrcweir 	else
139*cdf0e10cSrcweir 		lDispW += ROUND(aItem.lHDist / 10);
140*cdf0e10cSrcweir 	if (aItem.nRows == 1)
141*cdf0e10cSrcweir 		lDispH += ROUND(aItem.lUpper);
142*cdf0e10cSrcweir 	else
143*cdf0e10cSrcweir 		lDispH += ROUND(aItem.lVDist / 10);
144*cdf0e10cSrcweir 
145*cdf0e10cSrcweir 	// Skalierungsfaktor
146*cdf0e10cSrcweir 	float fx = (float) lOutWPix23 / Max(1L, lDispW),
147*cdf0e10cSrcweir 		  fy = (float) lOutHPix23 / Max(1L, lDispH),
148*cdf0e10cSrcweir 		  f  = fx < fy ? fx : fy;
149*cdf0e10cSrcweir 
150*cdf0e10cSrcweir 	// Nullpunkt
151*cdf0e10cSrcweir 	long lOutlineW = ROUND(f * lDispW);
152*cdf0e10cSrcweir 	long lOutlineH = ROUND(f * lDispH);
153*cdf0e10cSrcweir 
154*cdf0e10cSrcweir 	long lX0 = (lOutWPix - lOutlineW) / 2;
155*cdf0e10cSrcweir 	long lY0 = (lOutHPix - lOutlineH) / 2;
156*cdf0e10cSrcweir 	long lX1 = ROUND(lX0 + f *	aItem.lLeft );
157*cdf0e10cSrcweir 	long lY1 = ROUND(lY0 + f *	aItem.lUpper);
158*cdf0e10cSrcweir 	long lX2 = ROUND(lX0 + f * (aItem.lLeft  + aItem.lWidth ));
159*cdf0e10cSrcweir 	long lY2 = ROUND(lY0 + f * (aItem.lUpper + aItem.lHeight));
160*cdf0e10cSrcweir 	long lX3 = ROUND(lX0 + f * (aItem.lLeft  + aItem.lHDist ));
161*cdf0e10cSrcweir 	long lY3 = ROUND(lY0 + f * (aItem.lUpper + aItem.lVDist ));
162*cdf0e10cSrcweir 
163*cdf0e10cSrcweir 	// Umriss zeichnen (Flaeche)
164*cdf0e10cSrcweir 	DrawRect(Rectangle(Point(lX0, lY0), Size(lOutlineW, lOutlineH)));
165*cdf0e10cSrcweir 
166*cdf0e10cSrcweir 	// Umriss zeichnen (Umrandung)
167*cdf0e10cSrcweir     SetLineColor(rFieldTextColor);
168*cdf0e10cSrcweir 	DrawLine(Point(lX0, lY0), Point(lX0 + lOutlineW - 1, lY0)); // Oben
169*cdf0e10cSrcweir 	DrawLine(Point(lX0, lY0), Point(lX0, lY0 + lOutlineH - 1)); // Links
170*cdf0e10cSrcweir 	if (aItem.nCols == 1)
171*cdf0e10cSrcweir 		DrawLine(Point(lX0 + lOutlineW - 1, lY0), Point(lX0 + lOutlineW - 1, lY0 + lOutlineH - 1)); // Rechts
172*cdf0e10cSrcweir 	if (aItem.nRows == 1)
173*cdf0e10cSrcweir 		DrawLine(Point(lX0, lY0 + lOutlineH - 1), Point(lX0 + lOutlineW - 1, lY0 + lOutlineH - 1)); // Unten
174*cdf0e10cSrcweir 
175*cdf0e10cSrcweir 	// Etiketten
176*cdf0e10cSrcweir 	SetClipRegion (Rectangle(Point(lX0, lY0), Size(lOutlineW, lOutlineH)));
177*cdf0e10cSrcweir     SetFillColor(rWinColor);
178*cdf0e10cSrcweir 	for (sal_uInt16 nRow = 0; nRow < Min((sal_uInt16) 2, (sal_uInt16) aItem.nRows); nRow++)
179*cdf0e10cSrcweir 		for (sal_uInt16 nCol = 0; nCol < Min((sal_uInt16) 2, (sal_uInt16) aItem.nCols); nCol++)
180*cdf0e10cSrcweir 			DrawRect(Rectangle(
181*cdf0e10cSrcweir 			  Point(ROUND(lX0 + f * (aItem.lLeft  + nCol * aItem.lHDist)),
182*cdf0e10cSrcweir 					ROUND(lY0 + f * (aItem.lUpper + nRow * aItem.lVDist))),
183*cdf0e10cSrcweir 			  Size (ROUND(f * aItem.lWidth ),
184*cdf0e10cSrcweir 					ROUND(f * aItem.lHeight))));
185*cdf0e10cSrcweir 	SetClipRegion();
186*cdf0e10cSrcweir 
187*cdf0e10cSrcweir 	// Beschritung: Rand links
188*cdf0e10cSrcweir 	if (aItem.lLeft)
189*cdf0e10cSrcweir 	{
190*cdf0e10cSrcweir 		long lX = (lX0 + lX1) / 2;
191*cdf0e10cSrcweir 		DrawArrow(Point(lX0, lY0 - 5), Point(lX1, lY0 - 5), sal_False);
192*cdf0e10cSrcweir 		DrawArrow(Point(lX, lY0 - 10), Point(lX, lY0 - 5), sal_True);
193*cdf0e10cSrcweir 		DrawText(Point(lX1 - lLeftWidth, lY0 - 10 - lXHeight), aLeftStr);
194*cdf0e10cSrcweir 	}
195*cdf0e10cSrcweir 
196*cdf0e10cSrcweir 	// Beschriftung: Rand oben
197*cdf0e10cSrcweir 	if (aItem.lUpper)
198*cdf0e10cSrcweir 	{
199*cdf0e10cSrcweir 		DrawArrow(Point(lX0 - 5, lY0), Point(lX0 - 5, lY1), sal_False);
200*cdf0e10cSrcweir 		DrawText(Point(lX0 - 10 - lUpperWidth, ROUND(lY0 + f * aItem.lUpper / 2 - lXHeight / 2)), aUpperStr);
201*cdf0e10cSrcweir 	}
202*cdf0e10cSrcweir 
203*cdf0e10cSrcweir 	// Beschriftung: Breite und Hoehe
204*cdf0e10cSrcweir 	{
205*cdf0e10cSrcweir 		long lX = lX2 - lXWidth / 2 - lHeightWidth / 2;
206*cdf0e10cSrcweir 		long lY = lY1 + lXHeight;
207*cdf0e10cSrcweir 
208*cdf0e10cSrcweir 		DrawLine(Point(lX1, lY), Point(lX2 - 1, lY));
209*cdf0e10cSrcweir 		DrawLine(Point(lX, lY1), Point(lX, lY2 - 1));
210*cdf0e10cSrcweir 
211*cdf0e10cSrcweir 		DrawText(Point(lX1 + lXWidth / 2, lY - lXHeight / 2), aWidthStr);
212*cdf0e10cSrcweir 		DrawText(Point(lX - lHeightWidth / 2, lY2 - lXHeight - lXHeight / 2), aHeightStr);
213*cdf0e10cSrcweir 	}
214*cdf0e10cSrcweir 
215*cdf0e10cSrcweir 	// Beschriftung: Horz. Abstand
216*cdf0e10cSrcweir 	if (aItem.nCols > 1)
217*cdf0e10cSrcweir 	{
218*cdf0e10cSrcweir 		long lX = (lX1 + lX3) / 2;
219*cdf0e10cSrcweir 		DrawArrow(Point(lX1, lY0 - 5), Point(lX3, lY0 - 5), sal_False);
220*cdf0e10cSrcweir 		DrawArrow(Point(lX, lY0 - 10), Point(lX, lY0 - 5), sal_True);
221*cdf0e10cSrcweir 		DrawText(Point(lX - lHDistWidth / 2, lY0 - 10 - lXHeight), aHDistStr);
222*cdf0e10cSrcweir 	}
223*cdf0e10cSrcweir 
224*cdf0e10cSrcweir 	// Beschriftung: Vertikaler Abstand
225*cdf0e10cSrcweir 	if (aItem.nRows > 1)
226*cdf0e10cSrcweir 	{
227*cdf0e10cSrcweir 		DrawArrow(Point(lX0 - 5, lY1), Point(lX0 - 5, lY3), sal_False);
228*cdf0e10cSrcweir 		DrawText(Point(lX0 - 10 - lVDistWidth, ROUND(lY1 + f * aItem.lVDist / 2 - lXHeight / 2)), aVDistStr);
229*cdf0e10cSrcweir 	}
230*cdf0e10cSrcweir 
231*cdf0e10cSrcweir 	// Beschriftung: Spalten
232*cdf0e10cSrcweir 	{
233*cdf0e10cSrcweir 		long lY = lY0 + lOutlineH + 4;
234*cdf0e10cSrcweir 		DrawArrow(Point(lX0, lY), Point(lX0 + lOutlineW - 1, lY), sal_True);
235*cdf0e10cSrcweir 		DrawText(Point((lX0 + lX0 + lOutlineW - 1) / 2 - lColsWidth / 2, lY + 5), aColsStr);
236*cdf0e10cSrcweir 	}
237*cdf0e10cSrcweir 
238*cdf0e10cSrcweir 	// Beschriftung: Zeilen
239*cdf0e10cSrcweir 	{
240*cdf0e10cSrcweir 		long lX = lX0 + lOutlineW + 4;
241*cdf0e10cSrcweir 		DrawArrow(Point(lX, lY0), Point(lX, lY0 + lOutlineH - 1), sal_True);
242*cdf0e10cSrcweir 		DrawText(Point(lX + 5, (lY0 + lY0 + lOutlineH - 1 - lXHeight / 2) / 2), aRowsStr);
243*cdf0e10cSrcweir 	}
244*cdf0e10cSrcweir }
245*cdf0e10cSrcweir 
246*cdf0e10cSrcweir // Pfeil bzw. Intervall zeichnen --------------------------------------------
247*cdf0e10cSrcweir 
248*cdf0e10cSrcweir 
249*cdf0e10cSrcweir 
250*cdf0e10cSrcweir void SwLabPreview::DrawArrow(const Point &rP1, const Point &rP2, sal_Bool bArrow)
251*cdf0e10cSrcweir {
252*cdf0e10cSrcweir 	DrawLine(rP1, rP2);
253*cdf0e10cSrcweir 
254*cdf0e10cSrcweir 	if (bArrow)
255*cdf0e10cSrcweir 	{
256*cdf0e10cSrcweir 		Point aArr[3];
257*cdf0e10cSrcweir 
258*cdf0e10cSrcweir 		// Pfeil zeichnen
259*cdf0e10cSrcweir 		if (rP1.Y() == rP2.Y())
260*cdf0e10cSrcweir 		{
261*cdf0e10cSrcweir 			// Waagerecht
262*cdf0e10cSrcweir 			aArr[0].X() = rP2.X() - 5;
263*cdf0e10cSrcweir 			aArr[0].Y() = rP2.Y() - 2;
264*cdf0e10cSrcweir 			aArr[1].X() = rP2.X();
265*cdf0e10cSrcweir 			aArr[1].Y() = rP2.Y();
266*cdf0e10cSrcweir 			aArr[2].X() = rP2.X() - 5;
267*cdf0e10cSrcweir 			aArr[2].Y() = rP2.Y() + 2;
268*cdf0e10cSrcweir 		}
269*cdf0e10cSrcweir 		else
270*cdf0e10cSrcweir 		{
271*cdf0e10cSrcweir 			// Senkrecht
272*cdf0e10cSrcweir 			aArr[0].X() = rP2.X() - 2;
273*cdf0e10cSrcweir 			aArr[0].Y() = rP2.Y() - 5;
274*cdf0e10cSrcweir 			aArr[1].X() = rP2.X() + 2;
275*cdf0e10cSrcweir 			aArr[1].Y() = rP2.Y() - 5;
276*cdf0e10cSrcweir 			aArr[2].X() = rP2.X();
277*cdf0e10cSrcweir 			aArr[2].Y() = rP2.Y();
278*cdf0e10cSrcweir 		}
279*cdf0e10cSrcweir 
280*cdf0e10cSrcweir         const Color& rFieldTextColor = SwViewOption::GetFontColor();
281*cdf0e10cSrcweir         SetFillColor(rFieldTextColor);
282*cdf0e10cSrcweir 		DrawPolygon(Polygon(3, aArr));
283*cdf0e10cSrcweir 	}
284*cdf0e10cSrcweir 	else
285*cdf0e10cSrcweir 	{
286*cdf0e10cSrcweir 		// Intervall zeichnen
287*cdf0e10cSrcweir 		if (rP1.Y() == rP2.Y())
288*cdf0e10cSrcweir 		{
289*cdf0e10cSrcweir 			// Waagerecht
290*cdf0e10cSrcweir 			DrawLine(Point(rP1.X(), rP1.Y() - 2), Point(rP1.X(), rP1.Y() + 2));
291*cdf0e10cSrcweir 			DrawLine(Point(rP2.X(), rP2.Y() - 2), Point(rP2.X(), rP2.Y() + 2));
292*cdf0e10cSrcweir 		}
293*cdf0e10cSrcweir 		else
294*cdf0e10cSrcweir 		{
295*cdf0e10cSrcweir 			// Senkrecht
296*cdf0e10cSrcweir 			DrawLine(Point(rP1.X() - 2, rP1.Y()), Point(rP1.X() + 2, rP1.Y()));
297*cdf0e10cSrcweir 			DrawLine(Point(rP2.X() - 2, rP2.Y()), Point(rP2.X() + 2, rP2.Y()));
298*cdf0e10cSrcweir 		}
299*cdf0e10cSrcweir 	}
300*cdf0e10cSrcweir }
301*cdf0e10cSrcweir 
302*cdf0e10cSrcweir // --------------------------------------------------------------------------
303*cdf0e10cSrcweir 
304*cdf0e10cSrcweir void SwLabPreview::Update(const SwLabItem& rItem)
305*cdf0e10cSrcweir {
306*cdf0e10cSrcweir 	aItem = rItem;
307*cdf0e10cSrcweir 	Invalidate();
308*cdf0e10cSrcweir }
309*cdf0e10cSrcweir 
310*cdf0e10cSrcweir // --------------------------------------------------------------------------
311*cdf0e10cSrcweir 
312*cdf0e10cSrcweir 
313*cdf0e10cSrcweir 
314*cdf0e10cSrcweir SwLabFmtPage::SwLabFmtPage(Window* pParent, const SfxItemSet& rSet) :
315*cdf0e10cSrcweir 
316*cdf0e10cSrcweir 	SfxTabPage(pParent, SW_RES(TP_LAB_FMT), rSet),
317*cdf0e10cSrcweir     aMakeFI      (this, SW_RES(FI_MAKE)),
318*cdf0e10cSrcweir     aTypeFI      (this, SW_RES(FI_TYPE)),
319*cdf0e10cSrcweir     aPreview     (this, SW_RES(WIN_PREVIEW)),
320*cdf0e10cSrcweir     aHDistText   (this, SW_RES(TXT_HDIST  )),
321*cdf0e10cSrcweir     aHDistField  (this, SW_RES(FLD_HDIST  )),
322*cdf0e10cSrcweir     aVDistText   (this, SW_RES(TXT_VDIST  )),
323*cdf0e10cSrcweir     aVDistField  (this, SW_RES(FLD_VDIST  )),
324*cdf0e10cSrcweir     aWidthText   (this, SW_RES(TXT_WIDTH  )),
325*cdf0e10cSrcweir     aWidthField  (this, SW_RES(FLD_WIDTH  )),
326*cdf0e10cSrcweir     aHeightText  (this, SW_RES(TXT_HEIGHT )),
327*cdf0e10cSrcweir     aHeightField (this, SW_RES(FLD_HEIGHT )),
328*cdf0e10cSrcweir     aLeftText    (this, SW_RES(TXT_LEFT  )),
329*cdf0e10cSrcweir     aLeftField   (this, SW_RES(FLD_LEFT  )),
330*cdf0e10cSrcweir     aUpperText   (this, SW_RES(TXT_UPPER  )),
331*cdf0e10cSrcweir     aUpperField  (this, SW_RES(FLD_UPPER  )),
332*cdf0e10cSrcweir     aColsText    (this, SW_RES(TXT_COLUMNS)),
333*cdf0e10cSrcweir     aColsField   (this, SW_RES(FLD_COLUMNS)),
334*cdf0e10cSrcweir     aRowsText    (this, SW_RES(TXT_ROWS  )),
335*cdf0e10cSrcweir     aRowsField   (this, SW_RES(FLD_ROWS  )),
336*cdf0e10cSrcweir     aSavePB      (this, SW_RES(PB_SAVE  )),
337*cdf0e10cSrcweir     bModified(sal_False),
338*cdf0e10cSrcweir     aItem        ((const SwLabItem&) rSet.Get(FN_LABEL))
339*cdf0e10cSrcweir {
340*cdf0e10cSrcweir 	FreeResource();
341*cdf0e10cSrcweir 	SetExchangeSupport();
342*cdf0e10cSrcweir 
343*cdf0e10cSrcweir 	// Metriken
344*cdf0e10cSrcweir 	FieldUnit aMetric = ::GetDfltMetric(sal_False);
345*cdf0e10cSrcweir 	SetMetric(aHDistField , aMetric);
346*cdf0e10cSrcweir 	SetMetric(aVDistField , aMetric);
347*cdf0e10cSrcweir 	SetMetric(aWidthField , aMetric);
348*cdf0e10cSrcweir 	SetMetric(aHeightField, aMetric);
349*cdf0e10cSrcweir 	SetMetric(aLeftField  , aMetric);
350*cdf0e10cSrcweir 	SetMetric(aUpperField , aMetric);
351*cdf0e10cSrcweir 
352*cdf0e10cSrcweir 	// Handler installieren
353*cdf0e10cSrcweir 	Link aLk = LINK(this, SwLabFmtPage, ModifyHdl);
354*cdf0e10cSrcweir 	aHDistField .SetModifyHdl( aLk );
355*cdf0e10cSrcweir 	aVDistField .SetModifyHdl( aLk );
356*cdf0e10cSrcweir 	aWidthField .SetModifyHdl( aLk );
357*cdf0e10cSrcweir 	aHeightField.SetModifyHdl( aLk );
358*cdf0e10cSrcweir 	aLeftField	.SetModifyHdl( aLk );
359*cdf0e10cSrcweir 	aUpperField .SetModifyHdl( aLk );
360*cdf0e10cSrcweir 	aColsField	.SetModifyHdl( aLk );
361*cdf0e10cSrcweir 	aRowsField	.SetModifyHdl( aLk );
362*cdf0e10cSrcweir 
363*cdf0e10cSrcweir 	aLk = LINK(this, SwLabFmtPage, LoseFocusHdl);
364*cdf0e10cSrcweir 	aHDistField .SetLoseFocusHdl( aLk );
365*cdf0e10cSrcweir 	aVDistField .SetLoseFocusHdl( aLk );
366*cdf0e10cSrcweir 	aWidthField .SetLoseFocusHdl( aLk );
367*cdf0e10cSrcweir 	aHeightField.SetLoseFocusHdl( aLk );
368*cdf0e10cSrcweir 	aLeftField	.SetLoseFocusHdl( aLk );
369*cdf0e10cSrcweir 	aUpperField .SetLoseFocusHdl( aLk );
370*cdf0e10cSrcweir 	aColsField	.SetLoseFocusHdl( aLk );
371*cdf0e10cSrcweir 	aRowsField	.SetLoseFocusHdl( aLk );
372*cdf0e10cSrcweir 
373*cdf0e10cSrcweir 	aSavePB.SetClickHdl( LINK (this, SwLabFmtPage, SaveHdl));
374*cdf0e10cSrcweir 	// Timer einstellen
375*cdf0e10cSrcweir 	aPreviewTimer.SetTimeout(1000);
376*cdf0e10cSrcweir 	aPreviewTimer.SetTimeoutHdl(LINK(this, SwLabFmtPage, PreviewHdl));
377*cdf0e10cSrcweir }
378*cdf0e10cSrcweir 
379*cdf0e10cSrcweir // --------------------------------------------------------------------------
380*cdf0e10cSrcweir 
381*cdf0e10cSrcweir 
382*cdf0e10cSrcweir 
383*cdf0e10cSrcweir SwLabFmtPage::~SwLabFmtPage()
384*cdf0e10cSrcweir {
385*cdf0e10cSrcweir }
386*cdf0e10cSrcweir 
387*cdf0e10cSrcweir // Modify-Handler der MetricFields. Preview-Timer starten -------------------
388*cdf0e10cSrcweir 
389*cdf0e10cSrcweir 
390*cdf0e10cSrcweir 
391*cdf0e10cSrcweir IMPL_LINK_INLINE_START( SwLabFmtPage, ModifyHdl, Edit *, EMPTYARG )
392*cdf0e10cSrcweir {
393*cdf0e10cSrcweir 	bModified = sal_True;
394*cdf0e10cSrcweir 	aPreviewTimer.Start();
395*cdf0e10cSrcweir 	return 0;
396*cdf0e10cSrcweir }
397*cdf0e10cSrcweir IMPL_LINK_INLINE_END( SwLabFmtPage, ModifyHdl, Edit *, EMPTYARG )
398*cdf0e10cSrcweir 
399*cdf0e10cSrcweir // Preview invalidaten ------------------------------------------------------
400*cdf0e10cSrcweir 
401*cdf0e10cSrcweir 
402*cdf0e10cSrcweir 
403*cdf0e10cSrcweir IMPL_LINK_INLINE_START( SwLabFmtPage, PreviewHdl, Timer *, EMPTYARG )
404*cdf0e10cSrcweir {
405*cdf0e10cSrcweir 	aPreviewTimer.Stop();
406*cdf0e10cSrcweir 	ChangeMinMax();
407*cdf0e10cSrcweir 	FillItem( aItem );
408*cdf0e10cSrcweir 	aPreview.Update( aItem );
409*cdf0e10cSrcweir 
410*cdf0e10cSrcweir 	return 0;
411*cdf0e10cSrcweir }
412*cdf0e10cSrcweir IMPL_LINK_INLINE_END( SwLabFmtPage, PreviewHdl, Timer *, EMPTYARG )
413*cdf0e10cSrcweir 
414*cdf0e10cSrcweir // LoseFocus-Handler: Bei Aenderung sofort updaten --------------------------
415*cdf0e10cSrcweir 
416*cdf0e10cSrcweir 
417*cdf0e10cSrcweir 
418*cdf0e10cSrcweir IMPL_LINK_INLINE_START( SwLabFmtPage, LoseFocusHdl, Control *, pControl )
419*cdf0e10cSrcweir {
420*cdf0e10cSrcweir 	if (((Edit*) pControl)->IsModified())
421*cdf0e10cSrcweir 		PreviewHdl(0);
422*cdf0e10cSrcweir 	return 0;
423*cdf0e10cSrcweir }
424*cdf0e10cSrcweir IMPL_LINK_INLINE_END( SwLabFmtPage, LoseFocusHdl, Control *, pControl )
425*cdf0e10cSrcweir 
426*cdf0e10cSrcweir // Minima und Maxima fuer Fields festlegen ----------------------------------
427*cdf0e10cSrcweir 
428*cdf0e10cSrcweir 
429*cdf0e10cSrcweir void SwLabFmtPage::ChangeMinMax()
430*cdf0e10cSrcweir {
431*cdf0e10cSrcweir 	long lMax = 31748; // 56 cm
432*cdf0e10cSrcweir 
433*cdf0e10cSrcweir 	// Min und Max
434*cdf0e10cSrcweir 
435*cdf0e10cSrcweir     long lLeft  = static_cast< long >(GETFLDVAL(aLeftField )),
436*cdf0e10cSrcweir          lUpper = static_cast< long >(GETFLDVAL(aUpperField)),
437*cdf0e10cSrcweir          lHDist = static_cast< long >(GETFLDVAL(aHDistField)),
438*cdf0e10cSrcweir          lVDist = static_cast< long >(GETFLDVAL(aVDistField));
439*cdf0e10cSrcweir 
440*cdf0e10cSrcweir 	long nMinSize = 10;	// 0,1cm
441*cdf0e10cSrcweir 
442*cdf0e10cSrcweir 	aHDistField .SetMin(nMinSize, FUNIT_CM);
443*cdf0e10cSrcweir 	aVDistField .SetMin(nMinSize, FUNIT_CM);
444*cdf0e10cSrcweir 
445*cdf0e10cSrcweir 	aHDistField .SetMax((long) 100 * ((lMax - lLeft ) / Max(1L, (long) aColsField.GetValue())), FUNIT_TWIP);
446*cdf0e10cSrcweir 	aVDistField .SetMax((long) 100 * ((lMax - lUpper) / Max(1L, (long) aRowsField.GetValue())), FUNIT_TWIP);
447*cdf0e10cSrcweir 
448*cdf0e10cSrcweir 	aWidthField .SetMin(nMinSize, FUNIT_CM);
449*cdf0e10cSrcweir 	aHeightField.SetMin(nMinSize, FUNIT_CM);
450*cdf0e10cSrcweir 
451*cdf0e10cSrcweir 	aWidthField .SetMax((long) 100 * (lHDist), FUNIT_TWIP);
452*cdf0e10cSrcweir 	aHeightField.SetMax((long) 100 * (lVDist), FUNIT_TWIP);
453*cdf0e10cSrcweir 
454*cdf0e10cSrcweir 	aLeftField	.SetMax((long) 100 * (lMax - (long) aColsField.GetValue() * GETFLDVAL(aHDistField)), FUNIT_TWIP);
455*cdf0e10cSrcweir 	aUpperField .SetMax((long) 100 * (lMax - (long) aRowsField.GetValue() * GETFLDVAL(aVDistField)), FUNIT_TWIP);
456*cdf0e10cSrcweir 
457*cdf0e10cSrcweir 	aColsField	.SetMax((lMax - lLeft ) / Max(1L, lHDist));
458*cdf0e10cSrcweir 	aRowsField	.SetMax((lMax - lUpper) / Max(1L, lVDist));
459*cdf0e10cSrcweir 
460*cdf0e10cSrcweir 	// First und Last
461*cdf0e10cSrcweir 
462*cdf0e10cSrcweir 	aHDistField .SetFirst(aHDistField .GetMin());
463*cdf0e10cSrcweir 	aVDistField .SetFirst(aVDistField .GetMin());
464*cdf0e10cSrcweir 
465*cdf0e10cSrcweir 	aHDistField .SetLast (aHDistField .GetMax());
466*cdf0e10cSrcweir 	aVDistField .SetLast (aVDistField .GetMax());
467*cdf0e10cSrcweir 
468*cdf0e10cSrcweir 	aWidthField .SetFirst(aWidthField .GetMin());
469*cdf0e10cSrcweir 	aHeightField.SetFirst(aHeightField.GetMin());
470*cdf0e10cSrcweir 
471*cdf0e10cSrcweir 	aWidthField .SetLast (aWidthField .GetMax());
472*cdf0e10cSrcweir 	aHeightField.SetLast (aHeightField.GetMax());
473*cdf0e10cSrcweir 
474*cdf0e10cSrcweir 	aLeftField	.SetLast (aLeftField  .GetMax());
475*cdf0e10cSrcweir 	aUpperField .SetLast (aUpperField .GetMax());
476*cdf0e10cSrcweir 
477*cdf0e10cSrcweir 	aColsField	.SetLast (aColsField  .GetMax());
478*cdf0e10cSrcweir 	aRowsField	.SetLast (aRowsField  .GetMax());
479*cdf0e10cSrcweir 
480*cdf0e10cSrcweir 	aHDistField .Reformat();
481*cdf0e10cSrcweir 	aVDistField .Reformat();
482*cdf0e10cSrcweir 	aWidthField .Reformat();
483*cdf0e10cSrcweir 	aHeightField.Reformat();
484*cdf0e10cSrcweir 	aLeftField	.Reformat();
485*cdf0e10cSrcweir 	aUpperField .Reformat();
486*cdf0e10cSrcweir 	aColsField	.Reformat();
487*cdf0e10cSrcweir 	aRowsField	.Reformat();
488*cdf0e10cSrcweir }
489*cdf0e10cSrcweir 
490*cdf0e10cSrcweir // --------------------------------------------------------------------------
491*cdf0e10cSrcweir 
492*cdf0e10cSrcweir 
493*cdf0e10cSrcweir 
494*cdf0e10cSrcweir SfxTabPage* SwLabFmtPage::Create(Window* pParent, const SfxItemSet& rSet)
495*cdf0e10cSrcweir {
496*cdf0e10cSrcweir 	return new SwLabFmtPage(pParent, rSet);
497*cdf0e10cSrcweir }
498*cdf0e10cSrcweir 
499*cdf0e10cSrcweir // ----------------------------------------------------------------------------
500*cdf0e10cSrcweir 
501*cdf0e10cSrcweir 
502*cdf0e10cSrcweir 
503*cdf0e10cSrcweir void SwLabFmtPage::ActivatePage(const SfxItemSet& rSet)
504*cdf0e10cSrcweir {
505*cdf0e10cSrcweir 	SfxItemSet aSet(rSet);
506*cdf0e10cSrcweir 	Reset(aSet);
507*cdf0e10cSrcweir }
508*cdf0e10cSrcweir 
509*cdf0e10cSrcweir // ----------------------------------------------------------------------------
510*cdf0e10cSrcweir 
511*cdf0e10cSrcweir 
512*cdf0e10cSrcweir 
513*cdf0e10cSrcweir int SwLabFmtPage::DeactivatePage(SfxItemSet* _pSet)
514*cdf0e10cSrcweir {
515*cdf0e10cSrcweir     if (_pSet)
516*cdf0e10cSrcweir         FillItemSet(*_pSet);
517*cdf0e10cSrcweir 
518*cdf0e10cSrcweir 	return sal_True;
519*cdf0e10cSrcweir }
520*cdf0e10cSrcweir 
521*cdf0e10cSrcweir // --------------------------------------------------------------------------
522*cdf0e10cSrcweir 
523*cdf0e10cSrcweir 
524*cdf0e10cSrcweir 
525*cdf0e10cSrcweir void SwLabFmtPage::FillItem(SwLabItem& rItem)
526*cdf0e10cSrcweir {
527*cdf0e10cSrcweir 	if (bModified)
528*cdf0e10cSrcweir 	{
529*cdf0e10cSrcweir 		rItem.aMake = rItem.aType = SW_RESSTR(STR_CUSTOM);
530*cdf0e10cSrcweir 
531*cdf0e10cSrcweir 		SwLabRec& rRec = *GetParent()->Recs()[0];
532*cdf0e10cSrcweir         rItem.lHDist  = rRec.lHDist  = static_cast< long >(GETFLDVAL(aHDistField ));
533*cdf0e10cSrcweir         rItem.lVDist  = rRec.lVDist  = static_cast< long >(GETFLDVAL(aVDistField ));
534*cdf0e10cSrcweir         rItem.lWidth  = rRec.lWidth  = static_cast< long >(GETFLDVAL(aWidthField ));
535*cdf0e10cSrcweir         rItem.lHeight = rRec.lHeight = static_cast< long >(GETFLDVAL(aHeightField));
536*cdf0e10cSrcweir         rItem.lLeft   = rRec.lLeft   = static_cast< long >(GETFLDVAL(aLeftField  ));
537*cdf0e10cSrcweir         rItem.lUpper  = rRec.lUpper  = static_cast< long >(GETFLDVAL(aUpperField ));
538*cdf0e10cSrcweir 		rItem.nCols   = rRec.nCols	 = (sal_uInt16) aColsField.GetValue();
539*cdf0e10cSrcweir 		rItem.nRows   = rRec.nRows	 = (sal_uInt16) aRowsField.GetValue();
540*cdf0e10cSrcweir 	}
541*cdf0e10cSrcweir }
542*cdf0e10cSrcweir 
543*cdf0e10cSrcweir // --------------------------------------------------------------------------
544*cdf0e10cSrcweir 
545*cdf0e10cSrcweir 
546*cdf0e10cSrcweir 
547*cdf0e10cSrcweir sal_Bool SwLabFmtPage::FillItemSet(SfxItemSet& rSet)
548*cdf0e10cSrcweir {
549*cdf0e10cSrcweir 	FillItem(aItem);
550*cdf0e10cSrcweir 	rSet.Put(aItem);
551*cdf0e10cSrcweir 
552*cdf0e10cSrcweir 	return sal_True;
553*cdf0e10cSrcweir }
554*cdf0e10cSrcweir 
555*cdf0e10cSrcweir // --------------------------------------------------------------------------
556*cdf0e10cSrcweir void SwLabFmtPage::Reset(const SfxItemSet& )
557*cdf0e10cSrcweir {
558*cdf0e10cSrcweir 	// Fields initialisieren
559*cdf0e10cSrcweir 	GetParent()->GetLabItem(aItem);
560*cdf0e10cSrcweir 
561*cdf0e10cSrcweir 	aHDistField .SetMax(100 * aItem.lHDist , FUNIT_TWIP);
562*cdf0e10cSrcweir 	aVDistField .SetMax(100 * aItem.lVDist , FUNIT_TWIP);
563*cdf0e10cSrcweir 	aWidthField .SetMax(100 * aItem.lWidth , FUNIT_TWIP);
564*cdf0e10cSrcweir 	aHeightField.SetMax(100 * aItem.lHeight, FUNIT_TWIP);
565*cdf0e10cSrcweir 	aLeftField	.SetMax(100 * aItem.lLeft  , FUNIT_TWIP);
566*cdf0e10cSrcweir 	aUpperField .SetMax(100 * aItem.lUpper , FUNIT_TWIP);
567*cdf0e10cSrcweir 
568*cdf0e10cSrcweir 	SETFLDVAL(aHDistField , aItem.lHDist );
569*cdf0e10cSrcweir 	SETFLDVAL(aVDistField , aItem.lVDist );
570*cdf0e10cSrcweir 	SETFLDVAL(aWidthField , aItem.lWidth );
571*cdf0e10cSrcweir 	SETFLDVAL(aHeightField, aItem.lHeight);
572*cdf0e10cSrcweir 	SETFLDVAL(aLeftField  , aItem.lLeft  );
573*cdf0e10cSrcweir 	SETFLDVAL(aUpperField , aItem.lUpper );
574*cdf0e10cSrcweir 
575*cdf0e10cSrcweir 	aColsField.SetMax(aItem.nCols);
576*cdf0e10cSrcweir 	aRowsField.SetMax(aItem.nRows);
577*cdf0e10cSrcweir 
578*cdf0e10cSrcweir 	aColsField	.SetValue(aItem.nCols);
579*cdf0e10cSrcweir 	aRowsField	.SetValue(aItem.nRows);
580*cdf0e10cSrcweir 	aMakeFI.SetText(aItem.aMake);
581*cdf0e10cSrcweir 	aTypeFI.SetText(aItem.aType);
582*cdf0e10cSrcweir 	PreviewHdl(0);
583*cdf0e10cSrcweir }
584*cdf0e10cSrcweir /* -----------------------------22.01.01 15:11--------------------------------
585*cdf0e10cSrcweir 
586*cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
587*cdf0e10cSrcweir 
588*cdf0e10cSrcweir IMPL_LINK( SwLabFmtPage, SaveHdl, PushButton *, EMPTYARG )
589*cdf0e10cSrcweir {
590*cdf0e10cSrcweir 	SwLabRec aRec;
591*cdf0e10cSrcweir     aRec.lHDist  = static_cast< long >(GETFLDVAL(aHDistField ));
592*cdf0e10cSrcweir     aRec.lVDist  = static_cast< long >(GETFLDVAL(aVDistField ));
593*cdf0e10cSrcweir     aRec.lWidth  = static_cast< long >(GETFLDVAL(aWidthField ));
594*cdf0e10cSrcweir     aRec.lHeight = static_cast< long >(GETFLDVAL(aHeightField));
595*cdf0e10cSrcweir     aRec.lLeft   = static_cast< long >(GETFLDVAL(aLeftField  ));
596*cdf0e10cSrcweir     aRec.lUpper  = static_cast< long >(GETFLDVAL(aUpperField ));
597*cdf0e10cSrcweir 	aRec.nCols	 = (sal_uInt16) aColsField.GetValue();
598*cdf0e10cSrcweir 	aRec.nRows	 = (sal_uInt16) aRowsField.GetValue();
599*cdf0e10cSrcweir 	aRec.bCont = aItem.bCont;
600*cdf0e10cSrcweir 	SwSaveLabelDlg* pSaveDlg = new SwSaveLabelDlg(this, aRec);
601*cdf0e10cSrcweir 	pSaveDlg->SetLabel(aItem.aLstMake, aItem.aLstType);
602*cdf0e10cSrcweir 	pSaveDlg->Execute();
603*cdf0e10cSrcweir 	if(pSaveDlg->GetLabel(aItem))
604*cdf0e10cSrcweir 	{
605*cdf0e10cSrcweir 		bModified = sal_False;
606*cdf0e10cSrcweir 		const Sequence<OUString>& rMan = GetParent()->GetLabelsConfig().GetManufacturers();
607*cdf0e10cSrcweir 		SvStringsDtor& rMakes = GetParent()->Makes();
608*cdf0e10cSrcweir 		if(rMakes.Count() < (sal_uInt16)rMan.getLength())
609*cdf0e10cSrcweir 		{
610*cdf0e10cSrcweir 			rMakes.DeleteAndDestroy(0, rMakes.Count());
611*cdf0e10cSrcweir 			const OUString* pMan = rMan.getConstArray();
612*cdf0e10cSrcweir 			for(sal_Int32 nMan = 0; nMan < rMan.getLength(); nMan++)
613*cdf0e10cSrcweir 			{
614*cdf0e10cSrcweir 				rMakes.Insert( new String(pMan[nMan]), rMakes.Count() );
615*cdf0e10cSrcweir 			}
616*cdf0e10cSrcweir 		}
617*cdf0e10cSrcweir 		aMakeFI.SetText(aItem.aMake);
618*cdf0e10cSrcweir 		aTypeFI.SetText(aItem.aType);
619*cdf0e10cSrcweir 	}
620*cdf0e10cSrcweir 	delete pSaveDlg;
621*cdf0e10cSrcweir 	return 0;
622*cdf0e10cSrcweir }
623*cdf0e10cSrcweir /* -----------------------------23.01.01 10:41--------------------------------
624*cdf0e10cSrcweir 
625*cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
626*cdf0e10cSrcweir SwSaveLabelDlg::SwSaveLabelDlg(SwLabFmtPage* pParent, SwLabRec& rRec) :
627*cdf0e10cSrcweir 	ModalDialog(pParent, SW_RES(DLG_SAVE_LABEL)),
628*cdf0e10cSrcweir     aOptionsFL(this,SW_RES(FL_OPTIONS  )),
629*cdf0e10cSrcweir     aMakeFT(this,   SW_RES(FT_MAKE     )),
630*cdf0e10cSrcweir     aMakeCB(this,   SW_RES(CB_MAKE     )),
631*cdf0e10cSrcweir     aTypeFT(this,   SW_RES(FT_TYPE     )),
632*cdf0e10cSrcweir     aTypeED(this,   SW_RES(ED_TYPE     )),
633*cdf0e10cSrcweir 
634*cdf0e10cSrcweir     aOKPB(this,     SW_RES(PB_OK     )),
635*cdf0e10cSrcweir     aCancelPB(this, SW_RES(PB_CANCEL )),
636*cdf0e10cSrcweir     aHelpPB(this,   SW_RES(PB_HELP      )),
637*cdf0e10cSrcweir 
638*cdf0e10cSrcweir     aQueryMB(this,  SW_RES(MB_QUERY )),
639*cdf0e10cSrcweir 
640*cdf0e10cSrcweir     bSuccess(sal_False),
641*cdf0e10cSrcweir     pLabPage(pParent),
642*cdf0e10cSrcweir     rLabRec(rRec)
643*cdf0e10cSrcweir {
644*cdf0e10cSrcweir 	FreeResource();
645*cdf0e10cSrcweir 
646*cdf0e10cSrcweir 	aOKPB.SetClickHdl(LINK(this, SwSaveLabelDlg, OkHdl));
647*cdf0e10cSrcweir 	Link aLk(LINK(this, SwSaveLabelDlg, ModifyHdl));
648*cdf0e10cSrcweir 	aMakeCB.SetModifyHdl(aLk);
649*cdf0e10cSrcweir 	aTypeED.SetModifyHdl(aLk);
650*cdf0e10cSrcweir 
651*cdf0e10cSrcweir 	SwLabelConfig& rCfg = pLabPage->GetParent()->GetLabelsConfig();
652*cdf0e10cSrcweir 	const Sequence<OUString>& rMan = rCfg.GetManufacturers();
653*cdf0e10cSrcweir 	const OUString* pMan = rMan.getConstArray();
654*cdf0e10cSrcweir 	for(sal_Int32 i = 0; i < rMan.getLength(); i++)
655*cdf0e10cSrcweir 		aMakeCB.InsertEntry(pMan[i]);
656*cdf0e10cSrcweir }
657*cdf0e10cSrcweir /* -----------------------------23.01.01 10:40--------------------------------
658*cdf0e10cSrcweir 
659*cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
660*cdf0e10cSrcweir IMPL_LINK(SwSaveLabelDlg, OkHdl, OKButton*, EMPTYARG)
661*cdf0e10cSrcweir {
662*cdf0e10cSrcweir 	SwLabelConfig& rCfg = pLabPage->GetParent()->GetLabelsConfig();
663*cdf0e10cSrcweir 	String sMake(aMakeCB.GetText());
664*cdf0e10cSrcweir 	String sType(aTypeED.GetText());
665*cdf0e10cSrcweir 	if(rCfg.HasLabel(sMake, sType))
666*cdf0e10cSrcweir 	{
667*cdf0e10cSrcweir 		String sTmp(aQueryMB.GetMessText());
668*cdf0e10cSrcweir 		String sQuery(sTmp);
669*cdf0e10cSrcweir 		sQuery.SearchAndReplace(C2S("%1"), sMake);
670*cdf0e10cSrcweir 		sQuery.SearchAndReplace(C2S("%2"), sType);
671*cdf0e10cSrcweir 		aQueryMB.SetMessText(sQuery);
672*cdf0e10cSrcweir 
673*cdf0e10cSrcweir 		short eRet = aQueryMB.Execute();
674*cdf0e10cSrcweir 		aQueryMB.SetMessText(sTmp);
675*cdf0e10cSrcweir 		if(RET_YES != eRet)
676*cdf0e10cSrcweir 			return 0;
677*cdf0e10cSrcweir 	}
678*cdf0e10cSrcweir 	rLabRec.aType = sType;
679*cdf0e10cSrcweir 	rCfg.SaveLabel(sMake, sType, rLabRec);
680*cdf0e10cSrcweir 	bSuccess = sal_True;
681*cdf0e10cSrcweir 	EndDialog(RET_OK);
682*cdf0e10cSrcweir 	return 0;
683*cdf0e10cSrcweir }
684*cdf0e10cSrcweir /* -----------------------------23.01.01 11:22--------------------------------
685*cdf0e10cSrcweir 
686*cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
687*cdf0e10cSrcweir IMPL_LINK(SwSaveLabelDlg, ModifyHdl, Edit*, EMPTYARG)
688*cdf0e10cSrcweir {
689*cdf0e10cSrcweir 	aOKPB.Enable(aMakeCB.GetText().Len() && aTypeED.GetText().Len());
690*cdf0e10cSrcweir 	return 0;
691*cdf0e10cSrcweir }
692*cdf0e10cSrcweir /* -----------------------------23.01.01 16:06--------------------------------
693*cdf0e10cSrcweir 
694*cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
695*cdf0e10cSrcweir sal_Bool SwSaveLabelDlg::GetLabel(SwLabItem& rItem)
696*cdf0e10cSrcweir {
697*cdf0e10cSrcweir 	if(bSuccess)
698*cdf0e10cSrcweir 	{
699*cdf0e10cSrcweir 		rItem.aMake = aMakeCB.GetText();
700*cdf0e10cSrcweir 		rItem.aType = aTypeED.GetText();
701*cdf0e10cSrcweir 		rItem.lHDist  = rLabRec.lHDist;
702*cdf0e10cSrcweir 		rItem.lVDist  = rLabRec.lVDist;
703*cdf0e10cSrcweir 		rItem.lWidth  = rLabRec.lWidth;
704*cdf0e10cSrcweir 		rItem.lHeight = rLabRec.lHeight;
705*cdf0e10cSrcweir 		rItem.lLeft   = rLabRec.lLeft;
706*cdf0e10cSrcweir 		rItem.lUpper  = rLabRec.lUpper;
707*cdf0e10cSrcweir 		rItem.nCols   = rLabRec.nCols;
708*cdf0e10cSrcweir 		rItem.nRows   = rLabRec.nRows;
709*cdf0e10cSrcweir 	}
710*cdf0e10cSrcweir 	return bSuccess;
711*cdf0e10cSrcweir }
712*cdf0e10cSrcweir 
713