xref: /aoo41x/main/svx/source/svdraw/svdoutl.cxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_svx.hxx"
30 #include <svx/svdoutl.hxx>
31 #include <editeng/outliner.hxx>
32 #include <svx/svdotext.hxx>
33 #include <editeng/editstat.hxx>
34 #include <svx/svdmodel.hxx>
35 #include <editeng/eeitem.hxx>
36 #include <svl/itempool.hxx>
37 
38 DBG_NAME(SdrOutliner)
39 /*************************************************************************
40 |*
41 |* Ctor
42 |*
43 \************************************************************************/
44 SdrOutliner::SdrOutliner( SfxItemPool* pItemPool, sal_uInt16 nMode )
45 :	Outliner( pItemPool, nMode ),
46 	//mpPaintInfoRec( NULL )
47 	mpVisualizedPage(0)
48 {
49     DBG_CTOR(SdrOutliner,NULL);
50 }
51 
52 
53 /*************************************************************************
54 |*
55 |* Dtor
56 |*
57 \************************************************************************/
58 SdrOutliner::~SdrOutliner()
59 {
60     DBG_DTOR(SdrOutliner,NULL);
61 }
62 
63 
64 /*************************************************************************
65 |*
66 |*
67 |*
68 \************************************************************************/
69 void SdrOutliner::SetTextObj( const SdrTextObj* pObj )
70 {
71 	if( pObj && pObj != mpTextObj.get() )
72 	{
73 		SetUpdateMode(sal_False);
74 		sal_uInt16 nOutlinerMode2 = OUTLINERMODE_OUTLINEOBJECT;
75 		if ( !pObj->IsOutlText() )
76 			nOutlinerMode2 = OUTLINERMODE_TEXTOBJECT;
77 		Init( nOutlinerMode2 );
78 
79 		SetGlobalCharStretching(100,100);
80 
81 		sal_uIntPtr nStat = GetControlWord();
82 		nStat &= ~( EE_CNTRL_STRETCHING | EE_CNTRL_AUTOPAGESIZE );
83 		SetControlWord(nStat);
84 
85 		Size aNullSize;
86 		Size aMaxSize( 100000,100000 );
87 		SetMinAutoPaperSize( aNullSize );
88 		SetMaxAutoPaperSize( aMaxSize );
89 		SetPaperSize( aMaxSize );
90 		ClearPolygon();
91 	}
92 
93 	mpTextObj.reset( const_cast< SdrTextObj* >(pObj) );
94 }
95 
96 /*************************************************************************
97 |*
98 |*
99 |*
100 \************************************************************************/
101 void SdrOutliner::SetTextObjNoInit( const SdrTextObj* pObj )
102 {
103 	mpTextObj.reset( const_cast< SdrTextObj* >(pObj) );
104 }
105 
106 /*************************************************************************
107 |*
108 |*
109 |*
110 \************************************************************************/
111 XubString SdrOutliner::CalcFieldValue(const SvxFieldItem& rField, sal_uInt16 nPara, sal_uInt16 nPos,
112                                      Color*& rpTxtColor, Color*& rpFldColor)
113 {
114 	FASTBOOL bOk = sal_False;
115 	XubString aRet;
116 
117 	if(mpTextObj.is())
118 		bOk = static_cast< SdrTextObj* >( mpTextObj.get())->CalcFieldValue(rField, nPara, nPos, sal_False, rpTxtColor, rpFldColor, aRet);
119 
120 	if (!bOk)
121 		aRet = Outliner::CalcFieldValue(rField, nPara, nPos, rpTxtColor, rpFldColor);
122 
123 	return aRet;
124 }
125 
126 const SdrTextObj* SdrOutliner::GetTextObj() const
127 {
128 	if( mpTextObj.is() )
129 		return static_cast< SdrTextObj* >( mpTextObj.get() );
130 	else
131 		return 0;
132 }
133