Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : */
12 :
13 : #include <app.hrc>
14 : #include <docvw.hrc>
15 : #include <globals.hrc>
16 : #include <popup.hrc>
17 : #include <svtools/svtools.hrc>
18 :
19 : #include <cmdid.h>
20 : #include <DashedLine.hxx>
21 : #include <docsh.hxx>
22 : #include <edtwin.hxx>
23 : #include <fmthdft.hxx>
24 : #include <HeaderFooterWin.hxx>
25 : #include <pagedesc.hxx>
26 : #include <pagefrm.hxx>
27 : #include <SwRewriter.hxx>
28 : #include <view.hxx>
29 : #include <viewopt.hxx>
30 : #include <wrtsh.hxx>
31 :
32 : #include <basegfx/color/bcolortools.hxx>
33 : #include <basegfx/matrix/b2dhommatrixtools.hxx>
34 : #include <basegfx/polygon/b2dpolygon.hxx>
35 : #include <basegfx/range/b2drectangle.hxx>
36 : #include <basegfx/vector/b2dsize.hxx>
37 : #include <drawinglayer/attribute/fillgradientattribute.hxx>
38 : #include <drawinglayer/attribute/fontattribute.hxx>
39 : #include <drawinglayer/primitive2d/fillgradientprimitive2d.hxx>
40 : #include <drawinglayer/primitive2d/modifiedcolorprimitive2d.hxx>
41 : #include <drawinglayer/primitive2d/polygonprimitive2d.hxx>
42 : #include <drawinglayer/primitive2d/polypolygonprimitive2d.hxx>
43 : #include <drawinglayer/primitive2d/textlayoutdevice.hxx>
44 : #include <drawinglayer/primitive2d/textprimitive2d.hxx>
45 : #include <editeng/boxitem.hxx>
46 : #include <svtools/svtresid.hxx>
47 : #include <svx/hdft.hxx>
48 : #include <drawinglayer/processor2d/processorfromoutputdevice.hxx>
49 : #include <vcl/decoview.hxx>
50 : #include <vcl/gradient.hxx>
51 : #include <vcl/menubtn.hxx>
52 : #include <vcl/svapp.hxx>
53 :
54 : #define TEXT_PADDING 5
55 : #define BOX_DISTANCE 10
56 : #define BUTTON_WIDTH 18
57 :
58 : using namespace basegfx;
59 : using namespace basegfx::tools;
60 : using namespace drawinglayer::attribute;
61 :
62 : namespace
63 : {
64 0 : static basegfx::BColor lcl_GetFillColor( basegfx::BColor aLineColor )
65 : {
66 0 : basegfx::BColor aHslLine = basegfx::tools::rgb2hsl( aLineColor );
67 0 : double nLuminance = aHslLine.getZ() * 2.5;
68 0 : if ( nLuminance == 0 )
69 0 : nLuminance = 0.5;
70 0 : else if ( nLuminance >= 1.0 )
71 0 : nLuminance = aHslLine.getZ() * 0.4;
72 0 : aHslLine.setZ( nLuminance );
73 0 : return basegfx::tools::hsl2rgb( aHslLine );
74 : }
75 :
76 0 : static basegfx::BColor lcl_GetLighterGradientColor( basegfx::BColor aDarkColor )
77 : {
78 0 : basegfx::BColor aHslDark = basegfx::tools::rgb2hsl( aDarkColor );
79 0 : double nLuminance = aHslDark.getZ() * 255 + 20;
80 0 : aHslDark.setZ( nLuminance / 255.0 );
81 0 : return basegfx::tools::hsl2rgb( aHslDark );
82 : }
83 :
84 0 : static B2DPolygon lcl_GetPolygon( const Rectangle& rRect, bool bHeader )
85 : {
86 0 : const double nRadius = 3;
87 0 : const double nKappa((M_SQRT2 - 1.0) * 4.0 / 3.0);
88 :
89 0 : B2DPolygon aPolygon;
90 0 : aPolygon.append( B2DPoint( rRect.Left(), rRect.Top() ) );
91 :
92 : {
93 0 : B2DPoint aCorner( rRect.Left(), rRect.Bottom() );
94 0 : B2DPoint aStart( rRect.Left(), rRect.Bottom() - nRadius );
95 0 : B2DPoint aEnd( rRect.Left() + nRadius, rRect.Bottom() );
96 0 : aPolygon.append( aStart );
97 : aPolygon.appendBezierSegment(
98 : interpolate( aStart, aCorner, nKappa ),
99 : interpolate( aEnd, aCorner, nKappa ),
100 0 : aEnd );
101 : }
102 :
103 : {
104 0 : B2DPoint aCorner( rRect.Right(), rRect.Bottom() );
105 0 : B2DPoint aStart( rRect.Right() - nRadius, rRect.Bottom() );
106 0 : B2DPoint aEnd( rRect.Right(), rRect.Bottom() - nRadius );
107 0 : aPolygon.append( aStart );
108 : aPolygon.appendBezierSegment(
109 : interpolate( aStart, aCorner, nKappa ),
110 : interpolate( aEnd, aCorner, nKappa ),
111 0 : aEnd );
112 : }
113 :
114 0 : aPolygon.append( B2DPoint( rRect.Right(), rRect.Top() ) );
115 :
116 0 : if ( !bHeader )
117 : {
118 0 : B2DRectangle aBRect( rRect.Left(), rRect.Top(), rRect.Right(), rRect.Bottom() );
119 : B2DHomMatrix aRotation = createRotateAroundPoint(
120 0 : aBRect.getCenterX(), aBRect.getCenterY(), M_PI );
121 0 : aPolygon.transform( aRotation );
122 : }
123 :
124 0 : return aPolygon;
125 : }
126 : }
127 :
128 :
129 0 : SwHeaderFooterWin::SwHeaderFooterWin( SwEditWin* pEditWin, const SwPageFrm* pPageFrm, bool bHeader ) :
130 : MenuButton( pEditWin, WB_DIALOGCONTROL ),
131 : SwFrameControl( pEditWin, pPageFrm ),
132 : m_sLabel( ),
133 : m_bIsHeader( bHeader ),
134 : m_pPopupMenu( NULL ),
135 : m_pLine( NULL ),
136 : m_bIsAppearing( false ),
137 : m_nFadeRate( 100 ),
138 0 : m_aFadeTimer( )
139 : {
140 : // Get the font and configure it
141 0 : Font aFont = GetSettings().GetStyleSettings().GetToolFont();
142 0 : SetZoomedPointFont( aFont );
143 :
144 : // Use pixels for the rest of the drawing
145 0 : SetMapMode( MapMode ( MAP_PIXEL ) );
146 :
147 : // Create the line control
148 0 : m_pLine = new SwDashedLine( GetEditWin(), &SwViewOption::GetHeaderFooterMarkColor );
149 0 : m_pLine->SetZOrder( this, WINDOW_ZORDER_BEFOR );
150 :
151 : // Create and set the PopupMenu
152 0 : m_pPopupMenu = new PopupMenu( SW_RES( MN_HEADERFOOTER_BUTTON ) );
153 :
154 : // Rewrite the menu entries' text
155 0 : if ( m_bIsHeader )
156 : {
157 0 : m_pPopupMenu->SetItemText( FN_HEADERFOOTER_EDIT, SW_RESSTR( STR_FORMAT_HEADER ) );
158 0 : m_pPopupMenu->SetItemText( FN_HEADERFOOTER_DELETE, SW_RESSTR( STR_DELETE_HEADER ) );
159 : }
160 : else
161 : {
162 0 : m_pPopupMenu->SetItemText( FN_HEADERFOOTER_EDIT, SW_RESSTR( STR_FORMAT_FOOTER ) );
163 0 : m_pPopupMenu->SetItemText( FN_HEADERFOOTER_DELETE, SW_RESSTR( STR_DELETE_FOOTER ) );
164 : }
165 :
166 0 : SetPopupMenu( m_pPopupMenu );
167 :
168 0 : m_aFadeTimer.SetTimeout( 50 );
169 0 : m_aFadeTimer.SetTimeoutHdl( LINK( this, SwHeaderFooterWin, FadeHandler ) );
170 0 : }
171 :
172 0 : SwHeaderFooterWin::~SwHeaderFooterWin( )
173 : {
174 0 : delete m_pPopupMenu;
175 0 : delete m_pLine;
176 0 : }
177 :
178 0 : const SwPageFrm* SwHeaderFooterWin::GetPageFrame( )
179 : {
180 0 : return static_cast< const SwPageFrm * >( GetFrame( ) );
181 : }
182 :
183 0 : void SwHeaderFooterWin::SetOffset( Point aOffset, long nXLineStart, long nXLineEnd )
184 : {
185 : // Compute the text to show
186 0 : m_sLabel = SW_RESSTR( STR_HEADER_TITLE );
187 0 : if ( !m_bIsHeader )
188 0 : m_sLabel = SW_RESSTR( STR_FOOTER_TITLE );
189 0 : sal_Int32 nPos = m_sLabel.lastIndexOf( "%1" );
190 0 : m_sLabel = m_sLabel.replaceAt( nPos, 2, GetPageFrame()->GetPageDesc()->GetName() );
191 :
192 : // Compute the text size and get the box position & size from it
193 0 : Rectangle aTextRect;
194 0 : GetTextBoundRect( aTextRect, String( m_sLabel ) );
195 0 : Rectangle aTextPxRect = LogicToPixel( aTextRect );
196 :
197 0 : Size aBoxSize ( aTextPxRect.GetWidth() + BUTTON_WIDTH + TEXT_PADDING * 2,
198 0 : aTextPxRect.GetHeight() + TEXT_PADDING * 2 );
199 :
200 0 : long nYFooterOff = 0;
201 0 : if ( !m_bIsHeader )
202 0 : nYFooterOff = aBoxSize.Height();
203 :
204 0 : Point aBoxPos( aOffset.X() - aBoxSize.Width() - BOX_DISTANCE,
205 0 : aOffset.Y() - nYFooterOff );
206 :
207 0 : if ( Application::GetSettings().GetLayoutRTL() )
208 : {
209 0 : aBoxPos.setX( aOffset.X() + BOX_DISTANCE );
210 : }
211 :
212 : // Set the position & Size of the window
213 0 : SetPosSizePixel( aBoxPos, aBoxSize );
214 :
215 0 : double nYLinePos = aBoxPos.Y();
216 0 : if ( !m_bIsHeader )
217 0 : nYLinePos += aBoxSize.Height();
218 0 : Point aLinePos( nXLineStart, nYLinePos );
219 0 : Size aLineSize( nXLineEnd - nXLineStart, 1 );
220 0 : m_pLine->SetPosSizePixel( aLinePos, aLineSize );
221 0 : }
222 :
223 0 : void SwHeaderFooterWin::ShowAll( bool bShow )
224 : {
225 0 : if ( !PopupMenu::IsInExecute() )
226 : {
227 0 : m_bIsAppearing = bShow;
228 :
229 0 : if ( m_aFadeTimer.IsActive( ) )
230 0 : m_aFadeTimer.Stop();
231 0 : m_aFadeTimer.Start( );
232 : }
233 0 : }
234 :
235 0 : bool SwHeaderFooterWin::Contains( const Point &rDocPt ) const
236 : {
237 0 : Rectangle aRect( GetPosPixel(), GetSizePixel() );
238 0 : if ( aRect.IsInside( rDocPt ) )
239 0 : return true;
240 :
241 0 : Rectangle aLineRect( m_pLine->GetPosPixel(), m_pLine->GetSizePixel() );
242 0 : if ( aLineRect.IsInside( rDocPt ) )
243 0 : return true;
244 :
245 0 : return false;
246 : }
247 :
248 0 : void SwHeaderFooterWin::Paint( const Rectangle& )
249 : {
250 0 : const Rectangle aRect( Rectangle( Point( 0, 0 ), PixelToLogic( GetSizePixel() ) ) );
251 0 : drawinglayer::primitive2d::Primitive2DSequence aSeq( 3 );
252 :
253 0 : B2DPolygon aPolygon = lcl_GetPolygon( aRect, m_bIsHeader );
254 :
255 : // Colors
256 0 : basegfx::BColor aLineColor = SwViewOption::GetHeaderFooterMarkColor().getBColor();
257 0 : basegfx::BColor aFillColor = lcl_GetFillColor( aLineColor );
258 0 : basegfx::BColor aLighterColor = lcl_GetLighterGradientColor( aFillColor );
259 :
260 0 : const StyleSettings& rSettings = Application::GetSettings().GetStyleSettings();
261 0 : if ( rSettings.GetHighContrastMode() )
262 : {
263 0 : aFillColor = rSettings.GetDialogColor( ).getBColor();
264 0 : aLineColor = rSettings.GetDialogTextColor( ).getBColor();
265 :
266 0 : aSeq[0] = drawinglayer::primitive2d::Primitive2DReference( new drawinglayer::primitive2d::PolyPolygonColorPrimitive2D(
267 0 : B2DPolyPolygon( aPolygon ), aFillColor ) );
268 : }
269 : else
270 : {
271 0 : B2DRectangle aGradientRect( aRect.Left(), aRect.Top(), aRect.Right(), aRect.Bottom() );
272 0 : double nAngle = M_PI;
273 0 : if ( m_bIsHeader )
274 0 : nAngle = 0;
275 : FillGradientAttribute aFillAttrs( GRADIENTSTYLE_LINEAR, 0.0, 0.0, 0.0, nAngle,
276 0 : aLighterColor, aFillColor, 10 );
277 0 : aSeq[0] = drawinglayer::primitive2d::Primitive2DReference( new drawinglayer::primitive2d::FillGradientPrimitive2D(
278 0 : aGradientRect, aFillAttrs ) );
279 : }
280 :
281 : // Create the border lines primitive
282 0 : aSeq[1] = drawinglayer::primitive2d::Primitive2DReference( new drawinglayer::primitive2d::PolygonHairlinePrimitive2D(
283 0 : aPolygon, aLineColor ) );
284 :
285 : // Create the text primitive
286 0 : B2DVector aFontSize;
287 : FontAttribute aFontAttr = drawinglayer::primitive2d::getFontAttributeFromVclFont(
288 0 : aFontSize, GetFont(), false, false );
289 :
290 0 : Rectangle aTextRect;
291 0 : GetTextBoundRect( aTextRect, String( m_sLabel ) );
292 :
293 0 : FontMetric aFontMetric = GetFontMetric( GetFont() );
294 0 : double nTextOffsetY = aFontMetric.GetAscent() + TEXT_PADDING;
295 0 : Point aTextPos( TEXT_PADDING, nTextOffsetY );
296 :
297 : basegfx::B2DHomMatrix aTextMatrix( createScaleTranslateB2DHomMatrix(
298 : aFontSize.getX(), aFontSize.getY(),
299 0 : double( aTextPos.X() ), double( aTextPos.Y() ) ) );
300 :
301 0 : aSeq[2] = drawinglayer::primitive2d::Primitive2DReference( new drawinglayer::primitive2d::TextSimplePortionPrimitive2D(
302 : aTextMatrix,
303 0 : String( m_sLabel ), 0, m_sLabel.getLength(),
304 : std::vector< double >( ),
305 : aFontAttr,
306 : com::sun::star::lang::Locale(),
307 0 : aLineColor ) );
308 :
309 : // Create the 'plus' or 'arrow' primitive
310 0 : B2DRectangle aSignArea( B2DPoint( aRect.Right() - BUTTON_WIDTH, 0.0 ),
311 0 : B2DSize( aRect.Right(), aRect.getHeight() ) );
312 :
313 0 : B2DPolygon aSign;
314 0 : if ( IsEmptyHeaderFooter( ) )
315 : {
316 : // Create the + polygon
317 0 : double nLeft = aSignArea.getMinX() + TEXT_PADDING;
318 0 : double nRight = aSignArea.getMaxX() - TEXT_PADDING;
319 0 : double nHalfW = ( nRight - nLeft ) / 2.0;
320 :
321 0 : double nTop = aSignArea.getCenterY() - nHalfW;
322 0 : double nBottom = aSignArea.getCenterY() + nHalfW;
323 :
324 0 : aSign.append( B2DPoint( nLeft, aSignArea.getCenterY() - 1.0 ) );
325 0 : aSign.append( B2DPoint( aSignArea.getCenterX() - 1.0, aSignArea.getCenterY() - 1.0 ) );
326 0 : aSign.append( B2DPoint( aSignArea.getCenterX() - 1.0, nTop ) );
327 0 : aSign.append( B2DPoint( aSignArea.getCenterX() + 1.0, nTop ) );
328 0 : aSign.append( B2DPoint( aSignArea.getCenterX() + 1.0, aSignArea.getCenterY() - 1.0 ) );
329 0 : aSign.append( B2DPoint( nRight, aSignArea.getCenterY() - 1.0 ) );
330 0 : aSign.append( B2DPoint( nRight, aSignArea.getCenterY() + 1.0 ) );
331 0 : aSign.append( B2DPoint( aSignArea.getCenterX() + 1.0, aSignArea.getCenterY() + 1.0 ) );
332 0 : aSign.append( B2DPoint( aSignArea.getCenterX() + 1.0, nBottom ) );
333 0 : aSign.append( B2DPoint( aSignArea.getCenterX() - 1.0, nBottom ) );
334 0 : aSign.append( B2DPoint( aSignArea.getCenterX() - 1.0, aSignArea.getCenterY() + 1.0 ) );
335 0 : aSign.append( B2DPoint( nLeft, aSignArea.getCenterY() + 1.0 ) );
336 0 : aSign.setClosed( true );
337 : }
338 : else
339 : {
340 : // Create the v polygon
341 0 : B2DPoint aLeft( aSignArea.getMinX() + TEXT_PADDING, aSignArea.getCenterY() );
342 0 : B2DPoint aRight( aSignArea.getMaxX() - TEXT_PADDING, aSignArea.getCenterY() );
343 0 : B2DPoint aBottom( ( aLeft.getX() + aRight.getX() ) / 2.0, aLeft.getY() + 4.0 );
344 0 : aSign.append( aLeft );
345 0 : aSign.append( aRight );
346 0 : aSign.append( aBottom );
347 0 : aSign.setClosed( true );
348 : }
349 :
350 0 : BColor aSignColor = Color( COL_BLACK ).getBColor( );
351 0 : if ( Application::GetSettings().GetStyleSettings().GetHighContrastMode() )
352 0 : aSignColor = Color( COL_WHITE ).getBColor( );
353 :
354 0 : aSeq.realloc( aSeq.getLength() + 1 );
355 0 : aSeq[ aSeq.getLength() - 1 ] = drawinglayer::primitive2d::Primitive2DReference( new drawinglayer::primitive2d::PolyPolygonColorPrimitive2D(
356 0 : B2DPolyPolygon( aSign ), aSignColor ) );
357 :
358 : // Create the processor and process the primitives
359 0 : const drawinglayer::geometry::ViewInformation2D aNewViewInfos;
360 : drawinglayer::processor2d::BaseProcessor2D * pProcessor =
361 : drawinglayer::processor2d::createBaseProcessor2DFromOutputDevice(
362 0 : *this, aNewViewInfos );
363 :
364 : // TODO Ghost it all if needed
365 0 : drawinglayer::primitive2d::Primitive2DSequence aGhostedSeq( 1 );
366 0 : double nFadeRate = double( m_nFadeRate ) / 100.0;
367 0 : aGhostedSeq[0] = drawinglayer::primitive2d::Primitive2DReference( new drawinglayer::primitive2d::ModifiedColorPrimitive2D(
368 0 : aSeq, BColorModifier( Color( COL_WHITE ).getBColor(), 1.0 - nFadeRate, BCOLORMODIFYMODE_INTERPOLATE ) ) );
369 :
370 0 : pProcessor->process( aGhostedSeq );
371 0 : delete pProcessor;
372 0 : }
373 :
374 0 : bool SwHeaderFooterWin::IsEmptyHeaderFooter( )
375 : {
376 0 : bool bResult = true;
377 :
378 : // Actually check it
379 0 : const SwPageDesc* pDesc = GetPageFrame()->GetPageDesc();
380 :
381 0 : bool const bFirst(GetPageFrame()->OnFirstPage());
382 0 : const SwFrmFmt *const pFmt = (GetPageFrame()->OnRightPage())
383 0 : ? pDesc->GetRightFmt(bFirst)
384 0 : : pDesc->GetLeftFmt(bFirst);
385 :
386 0 : if ( pFmt )
387 : {
388 0 : if ( m_bIsHeader )
389 0 : bResult = !pFmt->GetHeader().IsActive();
390 : else
391 0 : bResult = !pFmt->GetFooter().IsActive();
392 : }
393 :
394 0 : return bResult;
395 : }
396 :
397 0 : void SwHeaderFooterWin::ExecuteCommand( sal_uInt16 nSlot )
398 : {
399 0 : SwView& rView = GetEditWin()->GetView();
400 0 : SwWrtShell& rSh = rView.GetWrtShell();
401 :
402 0 : const String& rStyleName = GetPageFrame()->GetPageDesc()->GetName();
403 0 : switch ( nSlot )
404 : {
405 : case FN_HEADERFOOTER_EDIT:
406 : {
407 0 : sal_uInt16 nPageId = TP_FOOTER_PAGE;
408 0 : if ( m_bIsHeader )
409 0 : nPageId = TP_HEADER_PAGE;
410 :
411 : rView.GetDocShell()->FormatPage(
412 : rStyleName,
413 0 : nPageId, rSh );
414 : }
415 0 : break;
416 : case FN_HEADERFOOTER_BORDERBACK:
417 : {
418 0 : const SwPageDesc* pDesc = GetPageFrame()->GetPageDesc();
419 0 : const SwFrmFmt& rMaster = pDesc->GetMaster();
420 0 : SwFrmFmt* pHFFmt = const_cast< SwFrmFmt* >( rMaster.GetFooter().GetFooterFmt() );
421 0 : if ( m_bIsHeader )
422 0 : pHFFmt = const_cast< SwFrmFmt* >( rMaster.GetHeader().GetHeaderFmt() );
423 :
424 :
425 0 : SfxItemPool* pPool = pHFFmt->GetAttrSet().GetPool();
426 : SfxItemSet aSet( *pPool,
427 : RES_BACKGROUND, RES_BACKGROUND,
428 : RES_BOX, RES_BOX,
429 : SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER,
430 0 : RES_SHADOW, RES_SHADOW, 0 );
431 :
432 0 : aSet.Put( pHFFmt->GetAttrSet() );
433 :
434 : // Create a box info item... needed by the dialog
435 0 : SvxBoxInfoItem aBoxInfo( SID_ATTR_BORDER_INNER );
436 : const SfxPoolItem *pBoxInfo;
437 0 : if ( SFX_ITEM_SET == pHFFmt->GetAttrSet().GetItemState( SID_ATTR_BORDER_INNER,
438 0 : sal_True, &pBoxInfo) )
439 0 : aBoxInfo = *(SvxBoxInfoItem*)pBoxInfo;
440 :
441 0 : aBoxInfo.SetTable( sal_False );
442 0 : aBoxInfo.SetDist( sal_True);
443 0 : aBoxInfo.SetMinDist( sal_False );
444 0 : aBoxInfo.SetDefDist( MIN_BORDER_DIST );
445 0 : aBoxInfo.SetValid( VALID_DISABLE );
446 0 : aSet.Put( aBoxInfo );
447 :
448 0 : if ( svx::ShowBorderBackgroundDlg( this, &aSet, true ) )
449 : {
450 : const SfxPoolItem* pItem;
451 0 : if ( SFX_ITEM_SET == aSet.GetItemState( RES_BACKGROUND, sal_False, &pItem ) ) {
452 0 : pHFFmt->SetFmtAttr( *pItem );
453 0 : rView.GetDocShell()->SetModified(true);
454 : }
455 :
456 0 : if ( SFX_ITEM_SET == aSet.GetItemState( RES_BOX, sal_False, &pItem ) ) {
457 0 : pHFFmt->SetFmtAttr( *pItem );
458 0 : rView.GetDocShell()->SetModified(true);
459 : }
460 :
461 0 : if ( SFX_ITEM_SET == aSet.GetItemState( RES_SHADOW, sal_False, &pItem ) ) {
462 0 : pHFFmt->SetFmtAttr( *pItem );
463 0 : rView.GetDocShell()->SetModified(true);
464 : }
465 0 : }
466 : }
467 0 : break;
468 : case FN_HEADERFOOTER_DELETE:
469 : {
470 0 : rSh.ChangeHeaderOrFooter( rStyleName, m_bIsHeader, false, true );
471 : }
472 0 : break;
473 : default:
474 0 : break;
475 : }
476 0 : }
477 :
478 0 : void SwHeaderFooterWin::SetReadonly( bool bReadonly )
479 : {
480 0 : ShowAll( !bReadonly );
481 0 : }
482 :
483 0 : void SwHeaderFooterWin::MouseButtonDown( const MouseEvent& rMEvt )
484 : {
485 0 : if ( IsEmptyHeaderFooter( ) )
486 : {
487 0 : SwView& rView = GetEditWin()->GetView();
488 0 : SwWrtShell& rSh = rView.GetWrtShell();
489 :
490 0 : const String& rStyleName = GetPageFrame()->GetPageDesc()->GetName();
491 0 : rSh.ChangeHeaderOrFooter( rStyleName, m_bIsHeader, true, false );
492 : }
493 : else
494 0 : MenuButton::MouseButtonDown( rMEvt );
495 0 : }
496 :
497 0 : void SwHeaderFooterWin::Select( )
498 : {
499 0 : ExecuteCommand( GetCurItemId() );
500 0 : }
501 :
502 0 : IMPL_LINK_NOARG(SwHeaderFooterWin, FadeHandler)
503 : {
504 0 : if ( m_bIsAppearing && m_nFadeRate > 0 )
505 0 : m_nFadeRate -= 25;
506 0 : else if ( !m_bIsAppearing && m_nFadeRate < 100 )
507 0 : m_nFadeRate += 25;
508 :
509 0 : if ( m_nFadeRate != 100 && !IsVisible() )
510 : {
511 0 : Show( true );
512 0 : m_pLine->Show( true );
513 : }
514 0 : else if ( m_nFadeRate == 100 && IsVisible( ) )
515 : {
516 0 : Show( false );
517 0 : m_pLine->Show( false );
518 : }
519 : else
520 0 : Invalidate();
521 :
522 0 : if ( IsVisible( ) && m_nFadeRate > 0 && m_nFadeRate < 100 )
523 0 : m_aFadeTimer.Start();
524 :
525 0 : return 0;
526 99 : }
527 :
528 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|