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