1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_svtools.hxx"
26 
27 
28 #ifndef GCC
29 #endif
30 
31 //------------------------------------------------------------------
32 
33 //#include "Svitems.hxx"
34 
35 #include "property.hxx"
36 /*
37 #include "property.hrc"
38 #include "Scresid.hxx"
39 */
40 #define FRAME_OFFSET 4
41 
42 
SvXPropertyControl(Window * pParent,WinBits nWinStyle)43 SvXPropertyControl::SvXPropertyControl( Window* pParent, WinBits nWinStyle)
44 			:	Control(pParent,nWinStyle)
45 {
46 }
47 
SvXPropertyControl(Window * pParent,const ResId & rResId)48 SvXPropertyControl::SvXPropertyControl( Window* pParent, const ResId& rResId )
49 			:	Control(pParent,rResId )
50 {
51 }
52 
53 //------------------------------------------------------------------
54 
SvXPropertyEdit(Window * pParent,WinBits nWinStyle)55 SvXPropertyEdit::SvXPropertyEdit( Window* pParent, WinBits nWinStyle)
56 		:		SvXPropertyControl(pParent,nWinStyle),
57 				aEdit(this,WB_BORDER | WB_TABSTOP)
58 {
59 	pListener=NULL;
60 	aEdit.SetModifyHdl(
61 		LINK( this, SvXPropertyEdit, ModifiedHdl ));
62 	aEdit.SetGetFocusHdl(
63 		LINK( this, SvXPropertyEdit, GetFocusHdl));
64 	aEdit.SetLoseFocusHdl(
65 		LINK( this, SvXPropertyEdit, LoseFocusHdl));
66 
67 	aEdit.Show();
68 }
69 
SvXPropertyEdit(Window * pParent,const ResId & rResId)70 SvXPropertyEdit::SvXPropertyEdit( Window* pParent, const ResId& rResId)
71 		:		SvXPropertyControl(pParent,rResId),
72 				aEdit(this,WB_BORDER | WB_TABSTOP)
73 {
74 	pListener=NULL;
75 	aEdit.SetModifyHdl(
76 		LINK( this, SvXPropertyEdit, ModifiedHdl ));
77 	aEdit.SetGetFocusHdl(
78 		LINK( this, SvXPropertyEdit, GetFocusHdl));
79 	aEdit.SetLoseFocusHdl(
80 		LINK( this, SvXPropertyEdit, LoseFocusHdl));
81 
82 	Size aSize=GetSizePixel();
83 	SetCtrSize(aSize);
84 	aEdit.Show();
85 }
86 
SetSvXPropertyCtrListener(SvXPropertyCtrListener * pCtrListener)87 void SvXPropertyEdit::SetSvXPropertyCtrListener(SvXPropertyCtrListener* pCtrListener)
88 {
89 	pListener=pCtrListener;
90 }
91 
GetSvXPropertyCtrListener()92 SvXPropertyCtrListener* SvXPropertyEdit::GetSvXPropertyCtrListener()
93 {
94 	return pListener;
95 }
96 
97 
SetCtrSize(const Size & rSize)98 void SvXPropertyEdit::SetCtrSize(const Size& rSize)
99 {
100 	SetSizePixel(rSize);
101 	Size aSize=GetOutputSizePixel();
102 	Point aPos(0,0);
103 	aEdit.SetPosPixel(aPos);
104 	aEdit.SetSizePixel(aSize);
105 }
106 
SetLocked(sal_Bool bLocked)107 void SvXPropertyEdit::SetLocked(sal_Bool bLocked)
108 {
109 	if(bLocked)
110 		Disable();
111 	else
112 		Enable();
113 }
114 
SetProperty(const String & rString)115 void SvXPropertyEdit::SetProperty(const String &rString)
116 {
117 	aEdit.SetText(rString);
118 }
119 
GetProperty() const120 String SvXPropertyEdit::GetProperty() const
121 {
122 	return aEdit.GetText();
123 }
124 
HasList()125 sal_Bool SvXPropertyEdit::HasList()
126 {
127 	return sal_False;
128 };
129 
130 
ClearList()131 void SvXPropertyEdit::ClearList()
132 {
133 	return;
134 }
InsertEntry(const String &,sal_uInt16)135 void SvXPropertyEdit::InsertEntry( const String&,sal_uInt16 )
136 {
137 	return;
138 }
139 
SetMyName(const String & rString)140 void SvXPropertyEdit::SetMyName(const String &rString)
141 {
142 	aName=rString;
143 }
144 
GetMyName() const145 String SvXPropertyEdit::GetMyName()const
146 {
147 	return aName;
148 }
149 
SetMyData(void * pDat)150 void SvXPropertyEdit::SetMyData(void* pDat)
151 {
152 	pData=pDat;
153 }
154 
GetMyData()155 void* SvXPropertyEdit::GetMyData()
156 {
157 	return pData;
158 }
159 
160 
IMPL_LINK(SvXPropertyEdit,ModifiedHdl,Edit *,EMPTYARG)161 IMPL_LINK( SvXPropertyEdit, ModifiedHdl, Edit*, EMPTYARG )
162 {
163 	if(pListener!=NULL)
164 		pListener->Modified(this);
165 	return 0;
166 }
167 
IMPL_LINK(SvXPropertyEdit,GetFocusHdl,Edit *,EMPTYARG)168 IMPL_LINK( SvXPropertyEdit, GetFocusHdl, Edit*, EMPTYARG )
169 {
170 	if(pListener!=NULL)
171 		pListener->GetFocus(this);
172 	return 0;
173 }
174 
IMPL_LINK(SvXPropertyEdit,LoseFocusHdl,Edit *,EMPTYARG)175 IMPL_LINK( SvXPropertyEdit, LoseFocusHdl, Edit*, EMPTYARG )
176 {
177 	if(pListener!=NULL)
178 		pListener->LoseFocus(this);
179 	return 0;
180 }
181 
182 //------------------------------------------------------------------
183 
SvXPropertyListBox(Window * pParent,WinBits nWinStyle)184 SvXPropertyListBox::SvXPropertyListBox( Window* pParent, WinBits nWinStyle)
185 		:		SvXPropertyControl(pParent,nWinStyle),
186 				aListBox(this,WB_BORDER | WB_DROPDOWN | WB_TABSTOP)
187 {
188 	pListener=NULL;
189 	aListBox.SetSelectHdl(
190 		LINK( this, SvXPropertyListBox, ModifiedHdl ));
191 	aListBox.SetGetFocusHdl(
192 		LINK( this, SvXPropertyListBox, GetFocusHdl));
193 	aListBox.SetLoseFocusHdl(
194 		LINK( this, SvXPropertyListBox, LoseFocusHdl));
195 	aListBox.Show();
196 }
197 
SvXPropertyListBox(Window * pParent,const ResId & rResId)198 SvXPropertyListBox::SvXPropertyListBox( Window* pParent, const ResId& rResId)
199 		:		SvXPropertyControl(pParent,rResId),
200 				aListBox(this,WB_BORDER | WB_DROPDOWN | WB_TABSTOP)
201 {
202 	pListener=NULL;
203 	aListBox.SetSelectHdl(
204 		LINK( this, SvXPropertyListBox, ModifiedHdl ));
205 	aListBox.SetGetFocusHdl(
206 		LINK( this, SvXPropertyListBox, GetFocusHdl));
207 	aListBox.SetLoseFocusHdl(
208 		LINK( this, SvXPropertyListBox, LoseFocusHdl));
209 
210 	Size aSize=GetSizePixel();
211 	SetCtrSize(aSize);
212 	aListBox.Show();
213 }
214 
SetSvXPropertyCtrListener(SvXPropertyCtrListener * pCtrListener)215 void SvXPropertyListBox::SetSvXPropertyCtrListener(SvXPropertyCtrListener* pCtrListener)
216 {
217 	pListener=pCtrListener;
218 }
219 
GetSvXPropertyCtrListener()220 SvXPropertyCtrListener* SvXPropertyListBox::GetSvXPropertyCtrListener()
221 {
222 	return pListener;
223 }
224 
225 
SetCtrSize(const Size & rSize)226 void SvXPropertyListBox::SetCtrSize(const Size& rSize)
227 {
228 	SetSizePixel(rSize);
229 	Size aSize=GetOutputSizePixel();
230 	Point aPos(0,0);
231 	aListBox.SetPosPixel(aPos);
232 	aListBox.SetSizePixel(aSize);
233 }
234 
SetLocked(sal_Bool bLocked)235 void SvXPropertyListBox::SetLocked(sal_Bool bLocked)
236 {
237 	if(bLocked)
238 		Disable();
239 	else
240 		Enable();
241 }
242 
SetProperty(const String & rString)243 void SvXPropertyListBox::SetProperty(const String &rString)
244 {
245 	aListBox.SelectEntry(rString);
246 }
247 
GetProperty() const248 String SvXPropertyListBox::GetProperty()const
249 {
250 	return aListBox.GetSelectEntry();
251 }
252 
HasList()253 sal_Bool SvXPropertyListBox::HasList()
254 {
255 	return sal_True;
256 }
257 
258 
ClearList()259 void SvXPropertyListBox::ClearList()
260 {
261 	aListBox.Clear();
262 }
263 
InsertEntry(const String & rString,sal_uInt16 nPos)264 void SvXPropertyListBox::InsertEntry( const String& rString,sal_uInt16 nPos)
265 {
266 	aListBox.InsertEntry(rString,nPos);
267 }
268 
SetMyName(const String & rString)269 void SvXPropertyListBox::SetMyName(const String &rString)
270 {
271 	aName=rString;
272 }
273 
GetMyName() const274 String SvXPropertyListBox::GetMyName()const
275 {
276 	return aName;
277 }
278 
SetMyData(void * pDat)279 void SvXPropertyListBox::SetMyData(void* pDat)
280 {
281 	pData=pDat;
282 }
283 
GetMyData()284 void* SvXPropertyListBox::GetMyData()
285 {
286 	return pData;
287 }
288 
IMPL_LINK(SvXPropertyListBox,ModifiedHdl,ListBox *,EMPTYARG)289 IMPL_LINK( SvXPropertyListBox, ModifiedHdl, ListBox*, EMPTYARG )
290 {
291 	if(pListener!=NULL)
292 		pListener->Modified(this);
293 	return 0;
294 }
295 
IMPL_LINK(SvXPropertyListBox,GetFocusHdl,ListBox *,EMPTYARG)296 IMPL_LINK( SvXPropertyListBox, GetFocusHdl, ListBox*, EMPTYARG )
297 {
298 	if(pListener!=NULL)
299 		pListener->GetFocus(this);
300 	return 0;
301 }
302 
IMPL_LINK(SvXPropertyListBox,LoseFocusHdl,ListBox *,EMPTYARG)303 IMPL_LINK( SvXPropertyListBox, LoseFocusHdl, ListBox*, EMPTYARG )
304 {
305 	if(pListener!=NULL)
306 		pListener->LoseFocus(this);
307 	return 0;
308 }
309 
310 //------------------------------------------------------------------
311 
312 
SvXPropertyComboBox(Window * pParent,WinBits nWinStyle)313 SvXPropertyComboBox::SvXPropertyComboBox( Window* pParent, WinBits nWinStyle)
314 		:		SvXPropertyControl(pParent,nWinStyle),
315 				aComboBox(this,WB_BORDER | WB_DROPDOWN | WB_TABSTOP)
316 {
317 	pListener=NULL;
318 	aComboBox.SetModifyHdl(
319 		LINK( this, SvXPropertyComboBox, ModifiedHdl ));
320 	aComboBox.SetGetFocusHdl(
321 		LINK( this, SvXPropertyComboBox, GetFocusHdl));
322 	aComboBox.SetLoseFocusHdl(
323 		LINK( this, SvXPropertyComboBox, LoseFocusHdl));
324 	aComboBox.Show();
325 }
326 
SvXPropertyComboBox(Window * pParent,const ResId & rResId)327 SvXPropertyComboBox::SvXPropertyComboBox( Window* pParent, const ResId& rResId)
328 		:		SvXPropertyControl(pParent,rResId),
329 				aComboBox(this,WB_BORDER | WB_DROPDOWN | WB_TABSTOP)
330 {
331 	pListener=NULL;
332 	aComboBox.SetModifyHdl(
333 		LINK( this, SvXPropertyComboBox, ModifiedHdl ));
334 	aComboBox.SetGetFocusHdl(
335 		LINK( this, SvXPropertyComboBox, GetFocusHdl));
336 	aComboBox.SetLoseFocusHdl(
337 		LINK( this, SvXPropertyComboBox, LoseFocusHdl));
338 
339 	Size aSize=GetSizePixel();
340 	SetCtrSize(aSize);
341 	aComboBox.Show();
342 }
343 
SetLocked(sal_Bool bLocked)344 void SvXPropertyComboBox::SetLocked(sal_Bool bLocked)
345 {
346 	if(bLocked)
347 		Disable();
348 	else
349 		Enable();
350 }
351 
SetSvXPropertyCtrListener(SvXPropertyCtrListener * pCtrListener)352 void SvXPropertyComboBox::SetSvXPropertyCtrListener(SvXPropertyCtrListener* pCtrListener)
353 {
354 	pListener=pCtrListener;
355 }
356 
GetSvXPropertyCtrListener()357 SvXPropertyCtrListener* SvXPropertyComboBox::GetSvXPropertyCtrListener()
358 {
359 	return pListener;
360 }
361 
362 
SetCtrSize(const Size & rSize)363 void SvXPropertyComboBox::SetCtrSize(const Size& rSize)
364 {
365 	SetSizePixel(rSize);
366 	Size aSize=GetOutputSizePixel();
367 	Point aPos(0,0);
368 	aComboBox.SetPosPixel(aPos);
369 	aComboBox.SetSizePixel(aSize);
370 }
371 
372 
SetProperty(const String & rString)373 void SvXPropertyComboBox::SetProperty(const String &rString)
374 {
375 	aComboBox.SetText(rString);
376 }
377 
GetProperty() const378 String SvXPropertyComboBox::GetProperty()	const
379 {
380 	return aComboBox.GetText();
381 }
382 
HasList()383 sal_Bool SvXPropertyComboBox::HasList()
384 {
385 	return sal_True;
386 }
387 
ClearList()388 void SvXPropertyComboBox::ClearList()
389 {
390 	aComboBox.Clear();
391 }
392 
InsertEntry(const String & rString,sal_uInt16 nPos)393 void SvXPropertyComboBox::InsertEntry( const String& rString,sal_uInt16 nPos)
394 {
395 	aComboBox.InsertEntry(rString,nPos);
396 }
397 
SetMyName(const String & rString)398 void SvXPropertyComboBox::SetMyName(const String &rString)
399 {
400 	aName=rString;
401 }
402 
GetMyName() const403 String SvXPropertyComboBox::GetMyName()const
404 {
405 	return aName;
406 }
407 
SetMyData(void * pDat)408 void SvXPropertyComboBox::SetMyData(void* pDat)
409 {
410 	pData=pDat;
411 }
412 
GetMyData()413 void* SvXPropertyComboBox::GetMyData()
414 {
415 	return pData;
416 }
417 
IMPL_LINK(SvXPropertyComboBox,ModifiedHdl,ComboBox *,EMPTYARG)418 IMPL_LINK( SvXPropertyComboBox, ModifiedHdl, ComboBox*, EMPTYARG )
419 {
420 	if(pListener!=NULL)
421 		pListener->Modified(this);
422 	return 0;
423 }
424 
IMPL_LINK(SvXPropertyComboBox,GetFocusHdl,ComboBox *,EMPTYARG)425 IMPL_LINK( SvXPropertyComboBox, GetFocusHdl, ComboBox*, EMPTYARG )
426 {
427 	if(pListener!=NULL)
428 		pListener->GetFocus(this);
429 	return 0;
430 }
431 
IMPL_LINK(SvXPropertyComboBox,LoseFocusHdl,ComboBox *,EMPTYARG)432 IMPL_LINK( SvXPropertyComboBox, LoseFocusHdl, ComboBox*, EMPTYARG )
433 {
434 	if(pListener!=NULL)
435 		pListener->LoseFocus(this);
436 	return 0;
437 }
438 //------------------------------------------------------------------
439 
SvPropertyLine(Window * pParent,WinBits nWinStyle)440 SvPropertyLine::SvPropertyLine( Window* pParent,WinBits nWinStyle)
441 		:	Control(pParent,nWinStyle),
442 			aName(this,WB_BORDER),
443 			pSvXPropertyControl(NULL),
444 			aXButton(this,WB_BORDER),
445 			bIsLocked(sal_False),
446 			bIsHyperlink(sal_False)
447 {
448 	bNeedsRepaint = sal_True;
449 	bHasXButton = sal_False;
450 	aXButton.SetText( XubString( RTL_CONSTASCII_USTRINGPARAM( "..." ) ) );
451 	aName.Show();
452 	aXButton.Show();
453 	eKindOfCtr = KOC_UNDEFINED;
454 	Wallpaper aWall = GetBackground();
455 	aWall.SetColor( Color( COL_TRANSPARENT ) );
456 	SetBackground( aWall );
457 }
458 
SvPropertyLine(Window * pParent,const ResId & rResId)459 SvPropertyLine::SvPropertyLine( Window* pParent,const ResId& rResId )
460 		:	Control(pParent,rResId),
461 			aName		(this,WB_BORDER),
462 			pSvXPropertyControl(NULL),
463 			aXButton	(this,WB_BORDER),
464 			bIsLocked(sal_False),
465 			bIsHyperlink(sal_False)
466 {
467 	bNeedsRepaint = sal_True;
468 	bHasXButton = sal_False;
469 	eKindOfCtr = KOC_UNDEFINED;
470 	aXButton.SetText( XubString( RTL_CONSTASCII_USTRINGPARAM( "..." ) ) );
471 	aName.Show();
472 	aXButton.Show();
473 	Wallpaper aWall = GetBackground();
474 	aWall.SetColor( Color( COL_TRANSPARENT ) );
475 	SetBackground( aWall );
476 	Resize();
477 }
478 
SetSvXPropertyControl(SvXPropertyControl * pXControl)479 void SvPropertyLine::SetSvXPropertyControl(SvXPropertyControl* pXControl)
480 {
481 	pSvXPropertyControl=pXControl;
482 	pSvXPropertyControl->Show();
483 	Resize();
484 }
485 
GetSvXPropertyControl()486 SvXPropertyControl* SvPropertyLine::GetSvXPropertyControl()
487 {
488 	return pSvXPropertyControl;
489 }
490 
Resize()491 void SvPropertyLine::Resize()
492 {
493 	Size aSize=GetOutputSizePixel();
494 	Size a2Size=aSize;
495 
496 	aSize.Width()=nNameWidth;
497 	a2Size.Width()-=nNameWidth;
498 
499 	Point aPos(0,0);
500 	aName.SetPosPixel(aPos);
501 	aName.SetSizePixel(aSize);
502 
503 	sal_uInt16 nXButtonWidth=0;
504 
505 	if(bHasXButton)
506 	{
507 		nXButtonWidth=(sal_uInt16)aSize.Height();
508 	}
509 	a2Size.Width()=a2Size.Width()-nXButtonWidth;
510 
511 	aPos.X()+=aSize.Width();
512 
513 	if(pSvXPropertyControl!=NULL)
514 	{
515 		pSvXPropertyControl->SetPosPixel(aPos);
516 		pSvXPropertyControl->SetCtrSize(a2Size);
517 	}
518 
519 	if(bHasXButton)
520 	{
521 		aPos.X()=GetOutputSizePixel().Width()
522 					-nXButtonWidth;
523 		aSize.Width()=nXButtonWidth;
524 		aXButton	.SetSizePixel(aSize);
525 		aXButton	.SetPosPixel(aPos);
526 	}
527 }
528 
SetNeedsRepaint(sal_Bool bFlag)529 void SvPropertyLine::SetNeedsRepaint(sal_Bool bFlag)
530 {
531 	bNeedsRepaint=bFlag;
532 }
533 
NeedsRepaint()534 sal_Bool SvPropertyLine::NeedsRepaint()
535 {
536 	return bNeedsRepaint;
537 }
538 
SetName(const String & rString)539 void SvPropertyLine::SetName(const String& rString )
540 {
541 	aName.SetText(rString);
542 	aName.Invalidate();
543 }
544 
GetName() const545 String SvPropertyLine::GetName() const
546 {
547 	return aName.GetText();
548 }
549 
SetKindOfControl(eKindOfControl eKOC)550 void SvPropertyLine::SetKindOfControl(eKindOfControl eKOC)
551 {
552 	eKindOfCtr=eKOC;
553 }
554 
GetKindOfControl()555 eKindOfControl SvPropertyLine::GetKindOfControl()
556 {
557 	return eKindOfCtr;
558 }
559 
ShowXButton()560 void SvPropertyLine::ShowXButton()
561 {
562 	bHasXButton=sal_True;
563 	aXButton.Show();
564 	Resize();
565 }
HideXButton()566 void SvPropertyLine::HideXButton()
567 {
568 	bHasXButton=sal_False;
569 	aXButton.Hide();
570 	Resize();
571 }
IsVisibleXButton()572 sal_Bool SvPropertyLine::IsVisibleXButton()
573 {
574 	return bHasXButton;
575 }
576 
ShowAsHyperLink(sal_Bool nFlag)577 void SvPropertyLine::ShowAsHyperLink(sal_Bool nFlag)
578 {
579 	bIsHyperlink=nFlag;
580 	if(nFlag)
581 	{
582 		Font aFont=GetFont();
583 		aFont.SetUnderline(UNDERLINE_SINGLE);
584 		aFont.SetColor(Color(COL_BLUE));
585 		aName.SetFont(aFont);
586 	}
587 	else
588 	{
589 		Font aFont=GetFont();
590 		aName.SetFont(aFont);
591 	}
592 }
593 
IsShownAsHyperlink()594 sal_Bool SvPropertyLine::IsShownAsHyperlink()
595 {
596 	return bIsHyperlink;
597 }
598 
Locked(sal_Bool nFlag)599 void SvPropertyLine::Locked(sal_Bool nFlag)
600 {
601 	bIsLocked=nFlag;
602 	if(pSvXPropertyControl!=NULL)
603 		pSvXPropertyControl->SetLocked(nFlag);
604 }
605 
IsLineLocked()606 sal_Bool SvPropertyLine::IsLineLocked()
607 {
608 	return bIsLocked;
609 }
610 
SetNameWidth(sal_uInt16 nWidth)611 void SvPropertyLine::SetNameWidth(sal_uInt16 nWidth)
612 {
613 	nNameWidth=nWidth;
614 	Resize();
615 }
616 
SetClickHdl(const Link & rLink)617 void SvPropertyLine::SetClickHdl(const Link& rLink)
618 {
619 	aXButton.SetClickHdl(rLink );
620 }
621 
622 //----------------------------------------------------------
623 
SvXPropEvListener()624 SvXPropEvListener::SvXPropEvListener()
625 {
626 	pTheActiveControl=NULL;
627 }
628 
~SvXPropEvListener()629 SvXPropEvListener::~SvXPropEvListener()
630 {
631 }
632 
Modified(SvXPropertyControl * pSvXPCtr)633 void SvXPropEvListener::Modified (SvXPropertyControl *pSvXPCtr)
634 {
635 	pTheActiveControl=pSvXPCtr;
636 	aModifyLink.Call(this);
637 }
638 
GetFocus(SvXPropertyControl * pSvXPCtr)639 void SvXPropEvListener::GetFocus (SvXPropertyControl *pSvXPCtr)
640 {
641 	pTheActiveControl=pSvXPCtr;
642 	aGetFocusLink.Call(this);
643 }
644 
LoseFocus(SvXPropertyControl * pSvXPCtr)645 void SvXPropEvListener::LoseFocus (SvXPropertyControl *pSvXPCtr)
646 {
647 	pTheActiveControl=pSvXPCtr;
648 	aLoseFocusLink.Call(this);
649 }
650 
KeyInput(SvXPropertyControl * pSvXPCtr,const KeyCode & theKeyCode)651 void SvXPropEvListener::KeyInput (SvXPropertyControl *pSvXPCtr,const KeyCode& theKeyCode)
652 {
653 	pTheActiveControl=pSvXPCtr;
654 	aKeyCode=theKeyCode;
655 	aKeyInputLink.Call(this);
656 }
657 
GetPropertyControl()658 SvXPropertyControl *	SvXPropEvListener::GetPropertyControl()
659 {
660 	return pTheActiveControl;
661 }
662 
GetKeyCode() const663 KeyCode SvXPropEvListener::GetKeyCode() const
664 {
665 	return aKeyCode;
666 }
667 
668 //------------------------------------------------------------------
669 
SvListBoxForProperties(Window * pParent,WinBits nWinStyle)670 SvListBoxForProperties::SvListBoxForProperties( Window* pParent, WinBits nWinStyle)
671 		:	Control(pParent,nWinStyle),
672 			aPlayGround(this,WB_DIALOGCONTROL),
673 			aVScroll(this,WB_VSCROLL|WB_REPEAT|WB_DRAG),
674 			pPropDataControl(NULL)
675 {
676 
677 	aListener.SetModifyHdl	 (LINK( this, SvListBoxForProperties,	ModifyHdl));
678 	aListener.SetGetFocusHdl (LINK( this, SvListBoxForProperties, GetFocusHdl));
679 	aListener.SetLoseFocusHdl(LINK( this, SvListBoxForProperties,LoseFocusHdl));
680 	aListener.SetKeyInputHdl (LINK( this, SvListBoxForProperties, KeyInputHdl));
681 
682 	nYOffset=0;
683 	nTheNameSize=0;
684 	ListBox aListBox(this,WB_DROPDOWN);
685 	aListBox.SetPosSizePixel(Point(0,0),Size(100,100));
686 	nRowHeight=(sal_uInt16)aListBox.GetSizePixel().Height();
687 	Wallpaper aWall = aPlayGround.GetBackground();
688 	aWall.SetColor( Color( COL_TRANSPARENT ) );
689 	aPlayGround.SetBackground( aWall );
690 	aPlayGround.Show();
691 	aVScroll.Hide();
692 	aVScroll.SetScrollHdl(
693 		LINK( this, SvListBoxForProperties, ScrollHdl ));
694 
695 }
696 
697 
SvListBoxForProperties(Window * pParent,const ResId & rResId)698 SvListBoxForProperties::SvListBoxForProperties( Window* pParent, const ResId& rResId )
699 			:		Control(pParent,rResId),
700 					aPlayGround(this,0),
701 					aVScroll(this,WB_VSCROLL|WB_REPEAT|WB_DRAG),
702 					pPropDataControl(NULL)
703 {
704 	nTheNameSize=0;
705 	nYOffset=0;
706 	ListBox aListBox(this,WB_DROPDOWN);
707 	aListBox.SetPosSizePixel(Point(0,0),Size(100,100));
708 	nRowHeight=(sal_uInt16)aListBox.GetSizePixel().Height();
709 	Wallpaper aWall = aPlayGround.GetBackground();
710 	aWall.SetColor( Color( COL_TRANSPARENT ) );
711 	aPlayGround.SetBackground( aWall );
712 	aPlayGround.Show();
713 	aVScroll.Hide();
714 	aVScroll.SetScrollHdl( LINK( this, SvListBoxForProperties, ScrollHdl ) );
715 	UpdateVScroll();
716 	Resize();
717 }
718 
~SvListBoxForProperties()719 SvListBoxForProperties::~SvListBoxForProperties()
720 {
721 	Clear();
722 }
723 
Clear()724 void SvListBoxForProperties::Clear()
725 {
726 	for(sal_uInt16 i=0;i<PLineArray.Count();i++)
727 	{
728 		SvPropertyLine* pPropLine=PLineArray[i];
729 
730 		switch(pPropLine->GetKindOfControl())
731 		{
732 			case	KOC_LISTBOX:
733 			case	KOC_COMBOBOX:
734 			case	KOC_EDIT:		delete pPropLine->GetSvXPropertyControl();
735 									break;
736 			default:
737 									break;
738 		}
739 		delete pPropLine;
740 	}
741 	PLineArray.Remove(0,PLineArray.Count());
742 }
743 
744 
Resize()745 void SvListBoxForProperties::Resize()
746 {
747 	Size aSize=GetOutputSizePixel();
748 	Size a2Size=aSize;
749 	Size aVScrollSize;
750 
751 	if(aVScroll.IsVisible())
752 	{
753 		Point aPos(0,0);
754 		aVScrollSize=aVScroll.GetSizePixel();
755 		aVScrollSize.Height()=aSize.Height();
756 		a2Size.Width()-=aVScrollSize.Width();
757 		aPos.X()=a2Size.Width();
758 		aVScroll.SetPosPixel(aPos);
759 		aVScroll.SetSizePixel(aVScrollSize);
760 	}
761 
762 	aPlayGround.SetPosPixel(Point(0,0));
763 	aPlayGround.SetSizePixel(a2Size);
764 	UpdatePosNSize();
765 }
766 
SetController(SvPropertyDataControl * pPDC)767 void SvListBoxForProperties::SetController( SvPropertyDataControl *pPDC)
768 {
769 	pPropDataControl=pPDC;
770 }
771 
CalcVisibleLines()772 sal_uInt16 SvListBoxForProperties::CalcVisibleLines()
773 {
774 	Size aSize=aPlayGround.GetOutputSizePixel();
775 	sal_uInt16 nResult=0;
776 	if(nRowHeight!=0)
777 		nResult=(sal_uInt16) aSize.Height()/nRowHeight;
778 
779 	return nResult;
780 }
781 
UpdateVScroll()782 void SvListBoxForProperties::UpdateVScroll()
783 {
784 	sal_uInt16 nLines=CalcVisibleLines();
785 	aVScroll.SetPageSize(nLines-1);
786 	aVScroll.SetVisibleSize(nLines-1);
787 	aVScroll.SetRange(Range(0,PLineArray.Count()-1));
788 	if(PLineArray.Count()<=nLines)
789 	{
790 		aVScroll.Hide();
791 	}
792 	else
793 	{
794 		sal_Bool bFlag=aVScroll.IsVisible();
795 		aVScroll.Show();
796 		if(!bFlag)Resize();
797 	}
798 
799 
800 }
801 
UpdatePosNSize()802 void SvListBoxForProperties::UpdatePosNSize()
803 {
804 	Point aPos(0,nYOffset);
805 
806 	for(sal_uInt16 i=0; i<PLineArray.Count();i++)
807 	{
808 		if((PLineArray[i])->NeedsRepaint())
809 		{
810 			(PLineArray[i])->SetPosPixel(aPos);
811 			Size aSize=aPlayGround.GetOutputSizePixel();
812 			aSize.Height()=nRowHeight;
813 			(PLineArray[i])->SetSizePixel(aSize);
814 			(PLineArray[i])->SetNameWidth(nTheNameSize+2*FRAME_OFFSET);
815 			(PLineArray[i])->Invalidate();
816 			(PLineArray[i])->Update();
817 			(PLineArray[i])->Show();
818 			(PLineArray[i])->SetNeedsRepaint(sal_False);
819 		}
820 		else
821 		{
822 			if((PLineArray[i])->IsVisible())
823 			{
824 				Size aSize=aPlayGround.GetOutputSizePixel();
825 				aSize.Height()=nRowHeight;
826 				(PLineArray[i])->SetSizePixel(aSize);
827 				(PLineArray[i])->SetNameWidth(nTheNameSize+2*FRAME_OFFSET);
828 				(PLineArray[i])->Invalidate();
829 			}
830 		}
831 
832 		aPos.Y()+=nRowHeight;
833 	}
834 	aPlayGround.Invalidate();
835 	aPlayGround.Update();
836 }
837 
UpdatePlayGround()838 void SvListBoxForProperties::UpdatePlayGround()
839 {
840 	Point aPos(0,0);
841 	long nThumbPos=aVScroll.GetThumbPos();
842 	long nLines=aVScroll.GetPageSize();
843 	long nDelta=aVScroll.GetDelta();
844 
845 	sal_uInt16 nStart,nEnd;
846 	Size aSize=aPlayGround.GetOutputSizePixel();
847 	Point aPEnd;
848 	aPEnd.X()=aSize.Width();
849 
850 	if(nDelta>0)
851 	{
852 		nStart=(sal_uInt16)(nThumbPos+nLines+1-nDelta);
853 		nEnd=(sal_uInt16)(nThumbPos+nLines);
854 		aPos.Y()=(nLines+1-nDelta)*nRowHeight;
855 	}
856 	else
857 	{
858 		nStart=(sal_uInt16)nThumbPos;
859 		nEnd=(sal_uInt16)(nThumbPos-nDelta);
860 		aPEnd.Y()=(nThumbPos-nDelta)*nRowHeight;;
861 	}
862 
863 	aSize.Height()=nRowHeight;
864 
865 	nDelta=-nDelta*nRowHeight;
866 
867 	aPlayGround.Scroll(0,nDelta,SCROLL_CHILDREN);
868 
869 	for(sal_uInt16 i=nStart; i<=nEnd;i++)
870 	{
871 		(PLineArray[i])->SetPosSizePixel(aPos,aSize);
872 		(PLineArray[i])->SetNameWidth(nTheNameSize+2*FRAME_OFFSET);
873 		(PLineArray[i])->Show();
874 		aPos.Y()+=nRowHeight;
875 	}
876 	aPlayGround.Update();
877 }
878 
UpdateAll()879 void SvListBoxForProperties::UpdateAll()
880 {
881 	UpdatePosNSize();
882 	UpdatePlayGround();
883 	//UpdateVScroll();
884 }
885 
DisableUpdate()886 void SvListBoxForProperties::DisableUpdate()
887 {
888 	bUpdate=sal_False;
889 }
890 
EnableUpdate()891 void SvListBoxForProperties::EnableUpdate()
892 {
893 	bUpdate=sal_True;
894 	UpdateAll();
895 }
896 
SetPropertyValue(const String & rEntryName,const String & rValue)897 void SvListBoxForProperties::SetPropertyValue( const String & rEntryName, const String & rValue )
898 {
899 	sal_uInt16 i, iEnd = PLineArray.Count();
900 	for( i = 0 ; i < iEnd ; i++ )
901 	{
902 		SvPropertyLine* pPropLine = PLineArray[ i ];
903 		SvXPropertyControl* pSvXPCtr=pPropLine->GetSvXPropertyControl();
904 		if( pSvXPCtr && pSvXPCtr->GetMyName() == rEntryName )
905 		{
906 			pSvXPCtr->SetProperty( rValue );
907 		}
908 	}
909 }
910 
AppendEntry(const SvPropertyData & aPropData)911 sal_uInt16 SvListBoxForProperties::AppendEntry( const SvPropertyData& aPropData)
912 {
913 	return InsertEntry(aPropData);
914 }
915 
InsertEntry(const SvPropertyData & aPropData,sal_uInt16 nPos)916 sal_uInt16 SvListBoxForProperties::InsertEntry( const SvPropertyData& aPropData, sal_uInt16 nPos)
917 {
918 	sal_uInt16 nInsPos=nPos;
919 	SvPropertyLine* pPropLine=new SvPropertyLine(&aPlayGround,WB_TABSTOP | WB_DIALOGCONTROL);
920 
921 	if(nPos==LISTBOX_APPEND)
922 	{
923 		nInsPos=PLineArray.Count();
924 		PLineArray.Insert(pPropLine,nInsPos);
925 	}
926 	else
927 	{
928 		PLineArray.Insert(pPropLine,nPos);
929 	}
930 	pPropLine->SetNameWidth(nTheNameSize);
931 	UpdateVScroll();
932 	UpdatePosNSize();
933 	ChangeEntry(aPropData,nInsPos);
934 	return nInsPos;
935 }
936 
ChangeEntry(const SvPropertyData & aPropData,sal_uInt16 nPos)937 void SvListBoxForProperties::ChangeEntry( const SvPropertyData& aPropData, sal_uInt16 nPos)
938 {
939 	if(nPos<PLineArray.Count())
940 	{
941 		SvPropertyLine* pPropLine=PLineArray[nPos];
942 
943 		switch(pPropLine->GetKindOfControl())
944 		{
945 			case	KOC_LISTBOX:
946 			case	KOC_COMBOBOX:
947 			case	KOC_EDIT:		delete pPropLine->GetSvXPropertyControl();
948 									break;
949 			default:
950 									break;
951 		}
952 
953 		switch(aPropData.eKind)
954 		{
955 			case	KOC_LISTBOX:
956 									pPropLine->SetSvXPropertyControl(
957 											new SvXPropertyComboBox(pPropLine,WB_TABSTOP));
958 									pPropLine->SetKindOfControl(aPropData.eKind);
959 									break;
960 			case	KOC_COMBOBOX:
961 									pPropLine->SetSvXPropertyControl(
962 											new SvXPropertyComboBox(pPropLine,WB_TABSTOP));
963 									pPropLine->SetKindOfControl(aPropData.eKind);
964 									break;
965 			case	KOC_EDIT:
966 									pPropLine->SetSvXPropertyControl(
967 											new SvXPropertyEdit(pPropLine,WB_TABSTOP));
968 									pPropLine->SetKindOfControl(aPropData.eKind);
969 									break;
970 			case	KOC_USERDEFINED:
971 									pPropLine->SetSvXPropertyControl(aPropData.pControl);
972 									aPropData.pControl->SetParent(pPropLine);
973 									pPropLine->SetKindOfControl(aPropData.eKind);
974 									break;
975 			default:
976 									pPropLine->SetSvXPropertyControl(NULL);
977 									pPropLine->SetKindOfControl(KOC_UNDEFINED);
978 									break;
979 		}
980 
981 		SvXPropertyControl* pSvXPCtr=pPropLine->GetSvXPropertyControl();
982 
983 		if(pSvXPCtr!=NULL)
984 		{
985 			pSvXPCtr->SetSvXPropertyCtrListener(&aListener);
986 			pSvXPCtr->SetProperty(aPropData.aValue);
987 			pSvXPCtr->SetMyData(aPropData.pDataPtr);
988 			pSvXPCtr->SetMyName(aPropData.aName);
989 
990 			if(pSvXPCtr->HasList())
991 			{
992 				for(sal_uInt16 i=0;i<aPropData.theValues.Count();i++)
993 				{
994 					pSvXPCtr->InsertEntry(*(aPropData.theValues[i]));
995 				}
996 			}
997 		}
998 
999 		pPropLine->SetName(aPropData.aName);
1000 
1001 		sal_uInt16 nTextWidth=(sal_uInt16)aPlayGround.GetTextWidth(aPropData.aName);
1002 
1003 		if ( nTheNameSize < nTextWidth )
1004 			nTheNameSize = nTextWidth;
1005 
1006 		if ( aPropData.bHasVisibleXButton )
1007 		{
1008 			pPropLine->SetClickHdl(LINK( this, SvListBoxForProperties, ClickHdl ) );
1009 			pPropLine->ShowXButton();
1010 		}
1011 		else
1012 			pPropLine->HideXButton();
1013 
1014 		pPropLine->Locked(aPropData.bIsLocked);
1015 
1016 		pPropLine->ShowAsHyperLink(aPropData.bIsHyperLink);
1017 		pPropLine->SetData(aPropData.pDataPtr);
1018 	}
1019 }
1020 
GetFirstVisibleEntry()1021 sal_uInt16 SvListBoxForProperties::GetFirstVisibleEntry()
1022 {
1023 	return 0;
1024 }
SetFirstVisibleEntry(sal_uInt16)1025 void SvListBoxForProperties::SetFirstVisibleEntry(sal_uInt16)
1026 {
1027 	return;
1028 }
1029 
SetSelectedEntry(sal_uInt16)1030 void SvListBoxForProperties::SetSelectedEntry(sal_uInt16)
1031 {
1032 	return;
1033 }
1034 
GetSelectedEntry()1035 sal_uInt16 SvListBoxForProperties::GetSelectedEntry()
1036 {
1037 	return 0;
1038 }
1039 
IMPL_LINK(SvListBoxForProperties,ScrollHdl,ScrollBar *,pSB)1040 IMPL_LINK( SvListBoxForProperties, ScrollHdl, ScrollBar*, pSB )
1041 {
1042 	if(pSB!=NULL)
1043 	{
1044 		long nDelta=aVScroll.GetDelta();
1045 		nYOffset=-aVScroll.GetThumbPos()*nRowHeight;
1046 		//aPlayGround.SetUpdateMode(sal_False);
1047 
1048 		long nThumbPos=aVScroll.GetThumbPos();
1049 		long nLines=aVScroll.GetPageSize();
1050 
1051 		UpdatePlayGround();
1052 
1053 		for(long i=nThumbPos-nDelta; i<nThumbPos+nLines-nDelta;i++)
1054 		{
1055 			if(i>=nThumbPos && i<=nThumbPos+nLines)
1056 			{
1057 				(PLineArray[sal::static_int_cast< sal_uInt16 >(i)])->
1058                     SetNeedsRepaint(sal_True);
1059 			}
1060 			else
1061 			{
1062 				(PLineArray[sal::static_int_cast< sal_uInt16 >(i)])->Hide();
1063 				(PLineArray[sal::static_int_cast< sal_uInt16 >(i)])->
1064                     SetNeedsRepaint(sal_False);
1065 			}
1066 		}
1067 	}
1068 	return 0;
1069 }
1070 
IMPL_LINK(SvListBoxForProperties,ClickHdl,PushButton *,pPB)1071 IMPL_LINK( SvListBoxForProperties, ClickHdl, PushButton*,pPB)
1072 {
1073 	if(pPB!=NULL)
1074 	{
1075 	   SvPropertyLine *pPropLine=(SvPropertyLine *)pPB->GetParent();
1076 	   SvXPropertyControl* pSvXPCtr=pPropLine->GetSvXPropertyControl();
1077 	   pPropDataControl->Clicked(pSvXPCtr->GetMyName(),
1078 							pSvXPCtr->GetProperty(),pSvXPCtr->GetMyData());
1079 	}
1080 	return 0;
1081 }
1082 
IMPL_LINK(SvListBoxForProperties,ModifyHdl,SvXPropEvListener *,pSvXPEvL)1083 IMPL_LINK( SvListBoxForProperties, ModifyHdl,SvXPropEvListener*, pSvXPEvL)
1084 {
1085 	if(pSvXPEvL!=NULL && pPropDataControl!=NULL)
1086 	{
1087 
1088 		SvXPropertyControl* pSvXPCtr=aListener.GetPropertyControl();
1089 
1090 		pPropDataControl->Modified(pSvXPCtr->GetMyName(),
1091 							pSvXPCtr->GetProperty(),pSvXPCtr->GetMyData());
1092 
1093 	}
1094 	return 0;
1095 }
1096 
IMPL_LINK(SvListBoxForProperties,GetFocusHdl,SvXPropEvListener *,pSvXPEvL)1097 IMPL_LINK( SvListBoxForProperties, GetFocusHdl,SvXPropEvListener*, pSvXPEvL)
1098 {
1099 	if(pSvXPEvL!=NULL && pPropDataControl!=NULL)
1100 	{
1101 		SvXPropertyControl* pSvXPCtr=aListener.GetPropertyControl();
1102 
1103 		pPropDataControl->Select(pSvXPCtr->GetMyName(),pSvXPCtr->GetMyData());
1104 	}
1105 	return 0;
1106 }
1107 
IMPL_LINK(SvListBoxForProperties,LoseFocusHdl,SvXPropEvListener *,pSvXPEvL)1108 IMPL_LINK( SvListBoxForProperties, LoseFocusHdl,SvXPropEvListener*, pSvXPEvL)
1109 {
1110 	if(pSvXPEvL!=NULL && pPropDataControl!=NULL)
1111 	{
1112 		SvXPropertyControl* pSvXPCtr=aListener.GetPropertyControl();
1113 
1114 		pPropDataControl->Commit(pSvXPCtr->GetMyName(),
1115 					pSvXPCtr->GetProperty(),pSvXPCtr->GetMyData());
1116 		/*
1117 		{
1118 			pSvXPCtr->SetProperty(
1119 				pPropDataControl->GetTheCorrectProperty());
1120 		}
1121 		*/
1122 	}
1123 	return 0;
1124 }
1125 
IMPL_LINK(SvListBoxForProperties,KeyInputHdl,SvXPropEvListener *,pSvXPEvL)1126 IMPL_LINK( SvListBoxForProperties, KeyInputHdl,SvXPropEvListener*, pSvXPEvL)
1127 {
1128 		//  FIXME  - This code does not make a lot of sense.
1129 	if(pSvXPEvL!=NULL && pPropDataControl!=NULL)
1130 	{
1131 		/*SvXPropertyControl* pSvXPCtr=*/aListener.GetPropertyControl();
1132 	}
1133 	return 0;
1134 }
1135 
1136 
1137 
1138 
SvTabPageForProperties(Window * pParent,WinBits nWinStyle)1139 SvTabPageForProperties::SvTabPageForProperties(Window* pParent,WinBits nWinStyle)
1140 			:	TabPage(pParent,nWinStyle),
1141 				aLbProp(this)
1142 {
1143 	aLbProp.Show();
1144 }
1145 
Resize()1146 void SvTabPageForProperties::Resize()
1147 {
1148 	Point aPos(3,3);
1149 	Size aSize=GetOutputSizePixel();
1150 	aSize.Width()-=6;
1151 	aSize.Height()-=6;
1152 
1153 	aLbProp.SetPosSizePixel(aPos,aSize);
1154 }
1155 
GetTheListBox()1156 SvListBoxForProperties* SvTabPageForProperties::GetTheListBox()
1157 {
1158 	return &aLbProp;
1159 }
1160 
1161 
SvPropertyBox(Window * pParent,WinBits nWinStyle)1162 SvPropertyBox::SvPropertyBox( Window* pParent, WinBits nWinStyle)
1163 			: Control(pParent,nWinStyle),
1164 			  aTabControl(this)
1165 {
1166 	aTabControl.Show();
1167 }
1168 
SvPropertyBox(Window * pParent,const ResId & rResId)1169 SvPropertyBox::SvPropertyBox( Window* pParent, const ResId& rResId )
1170 			: Control(pParent,rResId),
1171 			  aTabControl(this)
1172 {
1173 	aTabControl.Show();
1174 	Resize();
1175 }
1176 
~SvPropertyBox()1177 SvPropertyBox::~SvPropertyBox()
1178 {
1179 	ClearAll();
1180 }
1181 
1182 
ClearAll()1183 void SvPropertyBox::ClearAll()
1184 {
1185 	sal_uInt16 nCount=aTabControl.GetPageCount();
1186 
1187 	for(sal_uInt16 i=nCount;i>=1;i--)
1188 	{
1189 		SvTabPageForProperties* pPage=(SvTabPageForProperties*)
1190 									aTabControl.GetTabPage(i);
1191 		aTabControl.RemovePage(i);
1192 		delete pPage;
1193 	}
1194 }
1195 
1196 
Resize()1197 void SvPropertyBox::Resize()
1198 {
1199 	Point aPos(3,3);
1200 	Size aSize=GetOutputSizePixel();
1201 	aSize.Width()-=6;
1202 	aSize.Height()-=6;
1203 
1204 	aTabControl.SetPosSizePixel(aPos,aSize);
1205 
1206 	sal_uInt16 nCount=aTabControl.GetPageCount();
1207 
1208 	aSize=aTabControl.GetTabPageSizePixel();
1209 	for(sal_uInt16 i=1;i<=nCount;i++)
1210 	{
1211 		SvTabPageForProperties* pPage=(SvTabPageForProperties*)
1212 									aTabControl.GetTabPage(i);
1213 		pPage->SetSizePixel(aSize);
1214 	}
1215 
1216 }
1217 
1218 
AppendPage(const String & rText)1219 sal_uInt16 SvPropertyBox::AppendPage( const String & rText )
1220 {
1221 	sal_uInt16 nId=aTabControl.GetPageCount()+1;
1222 	aTabControl.InsertPage( nId,rText);
1223 	SvTabPageForProperties* pPage=new SvTabPageForProperties(&aTabControl);
1224 	pPage->SetSizePixel(aTabControl.GetTabPageSizePixel());
1225 	pPage->GetTheListBox()->SetController(pThePropDataCtr);
1226 	aTabControl.SetTabPage( nId, pPage);
1227 	aTabControl.SetCurPageId(nId);
1228 	return nId;
1229 }
1230 
SetPage(sal_uInt16 nId)1231 void SvPropertyBox::SetPage( sal_uInt16 nId)
1232 {
1233 	aTabControl.SetCurPageId(nId);
1234 }
1235 
GetCurPage()1236 sal_uInt16 SvPropertyBox::GetCurPage()
1237 {
1238 	return aTabControl.GetCurPageId();
1239 }
1240 
CalcVisibleLines()1241 sal_uInt16 SvPropertyBox::CalcVisibleLines()
1242 {
1243 	SvTabPageForProperties* pPage=(SvTabPageForProperties*)
1244 				aTabControl.GetTabPage(aTabControl.GetCurPageId());
1245 	return pPage->GetTheListBox()->CalcVisibleLines();
1246 }
EnableUpdate()1247 void SvPropertyBox::EnableUpdate()
1248 {
1249 	SvTabPageForProperties* pPage=(SvTabPageForProperties*)
1250 				aTabControl.GetTabPage(aTabControl.GetCurPageId());
1251 	pPage->GetTheListBox()->EnableUpdate();
1252 }
1253 
DisableUpdate()1254 void SvPropertyBox::DisableUpdate()
1255 {
1256 	SvTabPageForProperties* pPage=(SvTabPageForProperties*)
1257 				aTabControl.GetTabPage(aTabControl.GetCurPageId());
1258 	pPage->GetTheListBox()->DisableUpdate();
1259 }
1260 
SetController(SvPropertyDataControl * pDataCtr)1261 void SvPropertyBox::SetController(SvPropertyDataControl *pDataCtr)
1262 {
1263 	pThePropDataCtr=pDataCtr;
1264 	sal_uInt16 nCount=aTabControl.GetPageCount();
1265 
1266 	for(sal_uInt16 i=1;i<=nCount;i++)
1267 	{
1268 		SvTabPageForProperties* pPage=(SvTabPageForProperties*)
1269 									aTabControl.GetTabPage(i);
1270 
1271 		pPage->GetTheListBox()->SetController(pThePropDataCtr);
1272 	}
1273 
1274 }
1275 
InsertEntry(const SvPropertyData & rData,sal_uInt16 nPos)1276 sal_uInt16 SvPropertyBox::InsertEntry( const SvPropertyData& rData, sal_uInt16 nPos)
1277 {
1278 	SvTabPageForProperties* pPage=(SvTabPageForProperties*)
1279 				aTabControl.GetTabPage(aTabControl.GetCurPageId());
1280 	return pPage->GetTheListBox()->InsertEntry(rData,nPos);
1281 }
1282 
ChangeEntry(const SvPropertyData & rData,sal_uInt16 nPos)1283 void SvPropertyBox::ChangeEntry( const SvPropertyData& rData, sal_uInt16 nPos)
1284 {
1285 	SvTabPageForProperties* pPage=(SvTabPageForProperties*)
1286 				aTabControl.GetTabPage(aTabControl.GetCurPageId());
1287 	pPage->GetTheListBox()->ChangeEntry(rData,nPos);
1288 }
1289 
AppendEntry(const SvPropertyData & rData)1290 sal_uInt16 SvPropertyBox::AppendEntry( const SvPropertyData& rData)
1291 {
1292 	SvTabPageForProperties* pPage=(SvTabPageForProperties*)
1293 				aTabControl.GetTabPage(aTabControl.GetCurPageId());
1294 	return pPage->GetTheListBox()->AppendEntry(rData);
1295 }
1296 
SetPropertyValue(const String & rEntryName,const String & rValue)1297 void SvPropertyBox::SetPropertyValue( const String & rEntryName, const String & rValue )
1298 {
1299 	SvTabPageForProperties* pPage=(SvTabPageForProperties*)
1300 				aTabControl.GetTabPage(aTabControl.GetCurPageId());
1301 	pPage->GetTheListBox()->SetPropertyValue( rEntryName, rValue );
1302 }
1303 
SetFirstVisibleEntry(sal_uInt16 nPos)1304 void SvPropertyBox::SetFirstVisibleEntry(sal_uInt16 nPos)
1305 {
1306 	SvTabPageForProperties* pPage=(SvTabPageForProperties*)
1307 				aTabControl.GetTabPage(aTabControl.GetCurPageId());
1308 	pPage->GetTheListBox()->SetFirstVisibleEntry(nPos);
1309 }
GetFirstVisibleEntry()1310 sal_uInt16 SvPropertyBox::GetFirstVisibleEntry()
1311 {
1312 	SvTabPageForProperties* pPage=(SvTabPageForProperties*)
1313 				aTabControl.GetTabPage(aTabControl.GetCurPageId());
1314 	return pPage->GetTheListBox()->GetFirstVisibleEntry();
1315 }
1316 
SetSelectedEntry(sal_uInt16 nPos)1317 void SvPropertyBox::SetSelectedEntry(sal_uInt16 nPos)
1318 {
1319 	SvTabPageForProperties* pPage=(SvTabPageForProperties*)
1320 				aTabControl.GetTabPage(aTabControl.GetCurPageId());
1321 	pPage->GetTheListBox()->SetSelectedEntry(nPos);
1322 }
GetSelectedEntry()1323 sal_uInt16 SvPropertyBox::GetSelectedEntry()
1324 {
1325 	SvTabPageForProperties* pPage=(SvTabPageForProperties*)
1326 				aTabControl.GetTabPage(aTabControl.GetCurPageId());
1327 	return pPage->GetTheListBox()->GetSelectedEntry();
1328 }
1329 
ClearTable()1330 void SvPropertyBox::ClearTable()
1331 {
1332 	SvTabPageForProperties* pPage=(SvTabPageForProperties*)
1333 				aTabControl.GetTabPage(aTabControl.GetCurPageId());
1334 	pPage->GetTheListBox()->Clear();
1335 }
1336 
~SvBasicPropertyDataControl()1337 SvBasicPropertyDataControl::~SvBasicPropertyDataControl()
1338 {
1339 }
1340 
Modified(const String & aName,const String & aVal,void * pData)1341 void SvBasicPropertyDataControl::Modified(const String& aName,
1342 								const String& aVal,void* pData)
1343 {
1344 	aEntryName=aName;
1345 	aEntryProperty=aVal;
1346 	pTheData=pData;
1347 	aModifyLink.Call(this);
1348 }
1349 
Clicked(const String & aName,const String & aVal,void * pData)1350 void SvBasicPropertyDataControl::Clicked(	const String& aName,
1351 									const String& aVal,
1352 									void* pData)		//Xtension-Button pressed
1353 {
1354 	aEntryName=aName;
1355 	aEntryProperty=aVal;
1356 	pTheData=pData;
1357 	aClickedLink.Call(this);
1358 }
1359 
Commit(const String & aName,const String & aVal,void * pData)1360 void SvBasicPropertyDataControl::Commit(		const String& aName,
1361 									const String& aVal,
1362 									void* pData)		//User accept changes
1363 {
1364 	aEntryName=aName;
1365 	aEntryProperty=aVal;
1366 	pTheData=pData;
1367 	aCommitLink.Call(this);
1368 }
1369 
Select(const String & aName,void * pData)1370 void SvBasicPropertyDataControl::Select(		const String& aName,
1371 									void* pData)		//User select new Row
1372 {
1373 	aEntryName=aName;
1374 	pTheData=pData;
1375 	aSelectLink.Call(this);
1376 }
1377 
LinkClicked(const String &,void *)1378 void SvBasicPropertyDataControl::LinkClicked(const String&, void*)
1379 {
1380 }
1381 
1382 
GetName() const1383 String	SvBasicPropertyDataControl::GetName() const //Tell's the name of the Property
1384 {
1385 	return aEntryName;
1386 }
1387 
GetProperty() const1388 String	SvBasicPropertyDataControl::GetProperty() const //Tell's the content of the Property
1389 {
1390 	return aEntryProperty;
1391 }
1392 
GetData()1393 void*	SvBasicPropertyDataControl::GetData() //Tell's the storage
1394 {
1395 	return pTheData;
1396 }
1397 
1398 /*
1399 String SvBasicPropertyDataControl::GetTheCorrectProperty() const
1400 {
1401 	return aCorrectProperty;
1402 }
1403 */
1404 
SetTheCorrectProperty(const String & aString)1405 void SvBasicPropertyDataControl::SetTheCorrectProperty(const String& aString)
1406 {
1407 	aCorrectProperty=aString;
1408 }
1409 
SetIsCorrect(sal_Bool nFlag)1410 void SvBasicPropertyDataControl::SetIsCorrect(sal_Bool nFlag)
1411 {
1412 	bCorrectness=nFlag;
1413 }
1414 
1415 
1416 
1417 //========================================================================
1418 // Property-Dialog:
1419 /* zum TESTEN im CALC*/
1420 //========================================================================
1421 /*
1422 ScPropertyDlg::ScPropertyDlg( Window* pParent) :
1423 	ModalDialog 	( pParent, ScResId( RID_SCDLG_PROPERTIES) ),
1424 	aPropListBox	( this, ResId( CTR_PROPLINE) ),
1425 	aKindOfListBox	(this,ResId( LB_KIND_OF_PROP)),
1426 	aModAnswer		(this,ResId(FT_ANSMOD	)),
1427 	aClickAnswer	(this,ResId(FT_ANSCLICK )),
1428 	aCommitAnswer	(this,ResId(FT_ANSCOMMIT)),
1429 	aSelectAnswer	(this,ResId(FT_ANSSELECT)),
1430 	anOk(this,ResId( BTN_OK)),
1431 	aCancel(this,ResId( BTN_CANCEL))
1432 {
1433 	FreeResource();
1434 
1435 	aKindOfListBox.SelectEntryPos(0);
1436 	aKindOfListBox.SetSelectHdl(
1437 		LINK( this, ScPropertyDlg, ModifiedHdl ));
1438 	nCount=0;
1439 	nClickCount=0;
1440 
1441 	String aString("Don't know ");
1442 
1443 	aBaProDatCtr.SetModifyHdl (LINK( this, ScPropertyDlg, RowModifiedHdl ));
1444 	aBaProDatCtr.SetClickedHdl(LINK( this, ScPropertyDlg, ClickHdl		 ));
1445 	aBaProDatCtr.SetCommitHdl (LINK( this, ScPropertyDlg, SelectHdl 	 ));
1446 	aBaProDatCtr.SetSelectHdl (LINK( this, ScPropertyDlg, CommitHdl 	 ));
1447 
1448 	aPropListBox.SetController(&aBaProDatCtr);
1449 
1450 	sal_uInt16 nPageId=aPropListBox.AppendPage("YabbaDabbaDo");
1451 	aPropListBox.SetPage(nPageId);
1452 	aProperty.eKind=KOC_EDIT;
1453 	aProperty.aName=aString;
1454 	aProperty.aName+=String((sal_uInt16)++nCount);
1455 	aProperty.aValue=sizeof ComboBox;
1456 	aProperty.bHasVisibleXButton=sal_False;
1457 	aProperty.bIsHyperLink=sal_False;
1458 	aProperty.bIsLocked=sal_False;
1459 	aProperty.pDataPtr=NULL;
1460 	aProperty.pControl=NULL;
1461 	aProperty.theValues.Insert(new String("1"),aProperty.theValues.Count());
1462 	aProperty.theValues.Insert(new String("2"),aProperty.theValues.Count());
1463 	aProperty.theValues.Insert(new String("3"),aProperty.theValues.Count());
1464 	aProperty.theValues.Insert(new String("4"),aProperty.theValues.Count());
1465 	aPropListBox.InsertEntry(aProperty);
1466 	aProperty.bHasVisibleXButton=sal_True;
1467 	aProperty.aName=aString;
1468 	aProperty.aName+=String((sal_uInt16)++nCount);
1469 	aProperty.aValue="42";
1470 	aProperty.eKind=KOC_LISTBOX;
1471 	aPropListBox.InsertEntry(aProperty);
1472 	aProperty.aName=aString;
1473 	aProperty.aName+=String((sal_uInt16)++nCount);
1474 	aProperty.eKind=KOC_COMBOBOX;
1475 	aProperty.bHasVisibleXButton=sal_False;
1476 	aPropListBox.InsertEntry(aProperty);
1477 }
1478 
1479 ScPropertyDlg::~ScPropertyDlg()
1480 {
1481 	delete aProperty.theValues[0];
1482 	delete aProperty.theValues[1];
1483 	delete aProperty.theValues[2];
1484 	delete aProperty.theValues[3];
1485 }
1486 
1487 IMPL_LINK( ScPropertyDlg, ModifiedHdl, ListBox*, pLB )
1488 {
1489 	if(pLB!=NULL)
1490 	{
1491 		String aString("Don't know ");
1492 		aProperty.aName=aString;
1493 		aProperty.aName+=String((sal_uInt16)++nCount);
1494 		if(nCount>20)
1495 		{
1496 			String aStr("Yabba ");
1497 			aStr+=aPropListBox.GetCurPage();
1498 			sal_uInt16 nPageId=aPropListBox.AppendPage(aStr);
1499 			aPropListBox.SetPage(nPageId);
1500 			nCount=0;
1501 		}
1502 
1503 		aProperty.eKind=(eKindOfControl)(aKindOfListBox.GetSelectEntryPos()+1);
1504 		aProperty.bHasVisibleXButton=sal_False;
1505 		if((nCount % 5)==0) aProperty.bHasVisibleXButton=sal_True;
1506 		aPropListBox.InsertEntry(aProperty);
1507 	}
1508 	return 0;
1509 }
1510 
1511 IMPL_LINK( ScPropertyDlg, RowModifiedHdl, SvBasicPropertyDataControl* ,pProCtr)
1512 {
1513 	if(pProCtr!=NULL)
1514 	{
1515 		aModAnswer.SetText(aBaProDatCtr.GetProperty());
1516 		aModAnswer.Invalidate();
1517 		aBaProDatCtr.SetIsCorrect(sal_True);
1518 	}
1519 	return 0;
1520 }
1521 
1522 IMPL_LINK( ScPropertyDlg, CommitHdl, SvBasicPropertyDataControl*,pProCtr)
1523 {
1524 	if(pProCtr!=NULL)
1525 	{
1526 		aCommitAnswer.SetText(aBaProDatCtr.GetProperty());
1527 		aCommitAnswer.Invalidate();
1528 		aBaProDatCtr.SetIsCorrect(sal_True);
1529 	}
1530 	return 0;
1531 }
1532 
1533 IMPL_LINK( ScPropertyDlg, ClickHdl, SvBasicPropertyDataControl*,pProCtr)
1534 {
1535 	if(pProCtr!=NULL)
1536 	{
1537 		aClickAnswer.SetText(aBaProDatCtr.GetName());
1538 		aClickAnswer.Invalidate();
1539 		aBaProDatCtr.SetIsCorrect(sal_True);
1540 	}
1541 	return 0;
1542 }
1543 
1544 IMPL_LINK( ScPropertyDlg, SelectHdl, SvBasicPropertyDataControl*,pProCtr)
1545 {
1546 	if(pProCtr!=NULL)
1547 	{
1548 		aSelectAnswer.SetText(aBaProDatCtr.GetName());
1549 		aSelectAnswer.Invalidate();
1550 		aBaProDatCtr.SetIsCorrect(sal_True);
1551 	}
1552 	return 0;
1553 }
1554 */
1555 
1556 
1557