Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / sw / source / uibase / docvw / HeaderFooterWin.cxx
blob64e34e01f6bd747db5d1ef96397cd729d59b5c87
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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 */
10 #include <strings.hrc>
12 #include <doc.hxx>
13 #include <drawdoc.hxx>
14 #include <cmdid.h>
15 #include <DashedLine.hxx>
16 #include <docsh.hxx>
17 #include <edtwin.hxx>
18 #include <fmthdft.hxx>
19 #include <HeaderFooterWin.hxx>
20 #include <pagedesc.hxx>
21 #include <pagefrm.hxx>
22 #include <view.hxx>
23 #include <viewopt.hxx>
24 #include <wrtsh.hxx>
25 #include <IDocumentDrawModelAccess.hxx>
27 #include <basegfx/color/bcolortools.hxx>
28 #include <basegfx/matrix/b2dhommatrixtools.hxx>
29 #include <basegfx/polygon/b2dpolygon.hxx>
30 #include <basegfx/range/b2drectangle.hxx>
31 #include <basegfx/vector/b2dsize.hxx>
32 #include <basegfx/utils/gradienttools.hxx>
33 #include <drawinglayer/attribute/fillgradientattribute.hxx>
34 #include <drawinglayer/attribute/fontattribute.hxx>
35 #include <drawinglayer/primitive2d/fillgradientprimitive2d.hxx>
36 #include <drawinglayer/primitive2d/modifiedcolorprimitive2d.hxx>
37 #include <drawinglayer/primitive2d/PolygonHairlinePrimitive2D.hxx>
38 #include <drawinglayer/primitive2d/PolyPolygonColorPrimitive2D.hxx>
39 #include <drawinglayer/primitive2d/textlayoutdevice.hxx>
40 #include <drawinglayer/primitive2d/textprimitive2d.hxx>
41 #include <editeng/boxitem.hxx>
42 #include <svx/hdft.hxx>
43 #include <sfx2/bindings.hxx>
44 #include <sfx2/viewfrm.hxx>
45 #include <drawinglayer/processor2d/baseprocessor2d.hxx>
46 #include <drawinglayer/processor2d/processor2dtools.hxx>
47 #include <vcl/canvastools.hxx>
48 #include <vcl/metric.hxx>
49 #include <vcl/svapp.hxx>
50 #include <vcl/settings.hxx>
51 #include <vcl/virdev.hxx>
52 #include <memory>
54 #define TEXT_PADDING 5
55 #define BOX_DISTANCE 10
56 #define BUTTON_WIDTH 18
58 using namespace basegfx;
59 using namespace basegfx::utils;
60 using namespace drawinglayer::attribute;
62 namespace
64 basegfx::BColor lcl_GetFillColor(const basegfx::BColor& rLineColor)
66 basegfx::BColor aHslLine = basegfx::utils::rgb2hsl(rLineColor);
67 double nLuminance = aHslLine.getZ() * 2.5;
68 if ( nLuminance == 0 )
69 nLuminance = 0.5;
70 else if ( nLuminance >= 1.0 )
71 nLuminance = aHslLine.getZ() * 0.4;
72 aHslLine.setZ( nLuminance );
73 return basegfx::utils::hsl2rgb( aHslLine );
76 basegfx::BColor lcl_GetLighterGradientColor(const basegfx::BColor& rDarkColor)
78 basegfx::BColor aHslDark = basegfx::utils::rgb2hsl(rDarkColor);
79 double nLuminance = aHslDark.getZ() * 255 + 20;
80 aHslDark.setZ( nLuminance / 255.0 );
81 return basegfx::utils::hsl2rgb( aHslDark );
84 B2DPolygon lcl_GetPolygon( const ::tools::Rectangle& rRect, bool bOnTop )
86 const double nRadius = 3;
87 const double nKappa((M_SQRT2 - 1.0) * 4.0 / 3.0);
89 B2DPolygon aPolygon;
90 aPolygon.append( B2DPoint( rRect.Left(), rRect.Top() ) );
93 B2DPoint aCorner( rRect.Left(), rRect.Bottom() );
94 B2DPoint aStart( rRect.Left(), rRect.Bottom() - nRadius );
95 B2DPoint aEnd( rRect.Left() + nRadius, rRect.Bottom() );
96 aPolygon.append( aStart );
97 aPolygon.appendBezierSegment(
98 interpolate( aStart, aCorner, nKappa ),
99 interpolate( aEnd, aCorner, nKappa ),
100 aEnd );
104 B2DPoint aCorner( rRect.Right(), rRect.Bottom() );
105 B2DPoint aStart( rRect.Right() - nRadius, rRect.Bottom() );
106 B2DPoint aEnd( rRect.Right(), rRect.Bottom() - nRadius );
107 aPolygon.append( aStart );
108 aPolygon.appendBezierSegment(
109 interpolate( aStart, aCorner, nKappa ),
110 interpolate( aEnd, aCorner, nKappa ),
111 aEnd );
114 aPolygon.append( B2DPoint( rRect.Right(), rRect.Top() ) );
116 if ( !bOnTop )
118 B2DRectangle aBRect = vcl::unotools::b2DRectangleFromRectangle(rRect);
119 B2DHomMatrix aRotation = createRotateAroundPoint(
120 aBRect.getCenterX(), aBRect.getCenterY(), M_PI );
121 aPolygon.transform( aRotation );
124 return aPolygon;
128 void SwFrameButtonPainter::PaintButton(drawinglayer::primitive2d::Primitive2DContainer& rSeq,
129 const tools::Rectangle& rRect, bool bOnTop)
131 rSeq.clear();
132 B2DPolygon aPolygon = lcl_GetPolygon(rRect, bOnTop);
134 // Colors
135 basegfx::BColor aLineColor = SwViewOption::GetCurrentViewOptions().GetHeaderFooterMarkColor().getBColor();
136 basegfx::BColor aFillColor = lcl_GetFillColor(aLineColor);
137 basegfx::BColor aLighterColor = lcl_GetLighterGradientColor(aFillColor);
139 const StyleSettings& rSettings = Application::GetSettings().GetStyleSettings();
140 if (rSettings.GetHighContrastMode())
142 aFillColor = rSettings.GetDialogColor().getBColor();
143 aLineColor = rSettings.GetDialogTextColor().getBColor();
145 rSeq.push_back(drawinglayer::primitive2d::Primitive2DReference(
146 new drawinglayer::primitive2d::PolyPolygonColorPrimitive2D(B2DPolyPolygon(aPolygon), aFillColor)));
148 else
150 B2DRectangle aGradientRect = vcl::unotools::b2DRectangleFromRectangle(rRect);
151 double nAngle = M_PI;
152 if (bOnTop)
153 nAngle = 0;
155 FillGradientAttribute aFillAttrs(css::awt::GradientStyle_LINEAR, 0.0, 0.0, 0.0, nAngle,
156 basegfx::BColorStops(aLighterColor, aFillColor));
157 rSeq.push_back(drawinglayer::primitive2d::Primitive2DReference(
158 new drawinglayer::primitive2d::FillGradientPrimitive2D(aGradientRect, std::move(aFillAttrs))));
161 // Create the border lines primitive
162 rSeq.push_back(drawinglayer::primitive2d::Primitive2DReference(
163 new drawinglayer::primitive2d::PolygonHairlinePrimitive2D(std::move(aPolygon), aLineColor)));
166 SwHeaderFooterDashedLine::SwHeaderFooterDashedLine(SwEditWin* pEditWin, const SwFrame *pFrame, bool bHeader)
167 : SwDashedLine(pEditWin, &SwViewOption::GetHeaderFooterMarkColor)
168 , m_pEditWin(pEditWin)
169 , m_pFrame(pFrame)
170 , m_bIsHeader(bHeader)
174 bool SwHeaderFooterDashedLine::IsOnScreen()
176 tools::Rectangle aBounds(GetPosPixel(), GetSizePixel());
177 tools::Rectangle aVisArea = GetEditWin()->LogicToPixel(GetEditWin()->GetView().GetVisArea());
178 return aBounds.Overlaps(aVisArea);
181 void SwHeaderFooterDashedLine::EnsureWin()
183 if (!m_pWin)
185 m_pWin = VclPtr<SwHeaderFooterWin>::Create(m_pEditWin, m_pFrame, m_bIsHeader);
186 m_pWin->SetZOrder(this, ZOrderFlags::Before);
190 void SwHeaderFooterDashedLine::ShowAll(bool bShow)
192 Show(bShow);
193 if (!m_pWin && IsOnScreen())
194 EnsureWin();
195 if (m_pWin)
196 m_pWin->ShowAll(bShow);
199 void SwHeaderFooterDashedLine::SetReadonly(bool bReadonly)
201 ShowAll(!bReadonly);
204 bool SwHeaderFooterDashedLine::Contains(const Point &rDocPt) const
206 if (m_pWin && m_pWin->Contains(rDocPt))
207 return true;
209 ::tools::Rectangle aLineRect(GetPosPixel(), GetSizePixel());
210 return aLineRect.Contains(rDocPt);
213 void SwHeaderFooterDashedLine::SetOffset(Point aOffset, tools::Long nXLineStart, tools::Long nXLineEnd)
215 Point aLinePos(nXLineStart, aOffset.Y());
216 Size aLineSize(nXLineEnd - nXLineStart, 1);
217 SetPosSizePixel(aLinePos, aLineSize);
219 bool bOnScreen = IsOnScreen();
220 if (!m_pWin && bOnScreen)
222 EnsureWin();
223 m_pWin->ShowAll(true);
225 else if (m_pWin && !bOnScreen)
226 m_pWin.disposeAndClear();
228 if (m_pWin)
229 m_pWin->SetOffset(aOffset);
232 SwHeaderFooterWin::SwHeaderFooterWin(SwEditWin* pEditWin, const SwFrame *pFrame, bool bHeader ) :
233 InterimItemWindow(pEditWin, "modules/swriter/ui/hfmenubutton.ui", "HFMenuButton"),
234 m_xMenuButton(m_xBuilder->weld_menu_button("menubutton")),
235 m_xPushButton(m_xBuilder->weld_button("button")),
236 m_pEditWin(pEditWin),
237 m_pFrame(pFrame),
238 m_bIsHeader( bHeader ),
239 m_bIsAppearing( false ),
240 m_nFadeRate( 100 ),
241 m_aFadeTimer("SwHeaderFooterWin m_aFadeTimer")
243 m_xVirDev = m_xMenuButton->create_virtual_device();
244 SwFrameMenuButtonBase::SetVirDevFont(*m_xVirDev);
246 m_xPushButton->connect_clicked(LINK(this, SwHeaderFooterWin, ClickHdl));
247 m_xMenuButton->connect_selected(LINK(this, SwHeaderFooterWin, SelectHdl));
249 // set the PopupMenu
250 // Rewrite the menu entries' text
251 if (m_bIsHeader)
253 m_xMenuButton->set_item_label("edit", SwResId(STR_FORMAT_HEADER));
254 m_xMenuButton->set_item_label("delete", SwResId(STR_DELETE_HEADER));
256 else
258 m_xMenuButton->set_item_label("edit", SwResId(STR_FORMAT_FOOTER));
259 m_xMenuButton->set_item_label("delete", SwResId(STR_DELETE_FOOTER));
262 m_aFadeTimer.SetTimeout(50);
263 m_aFadeTimer.SetInvokeHandler(LINK(this, SwHeaderFooterWin, FadeHandler));
266 SwHeaderFooterWin::~SwHeaderFooterWin( )
268 disposeOnce();
271 void SwHeaderFooterWin::dispose()
273 m_xPushButton.reset();
274 m_xMenuButton.reset();
275 m_pEditWin.clear();
276 m_xVirDev.disposeAndClear();
277 InterimItemWindow::dispose();
280 void SwHeaderFooterWin::SetOffset(Point aOffset)
282 // Compute the text to show
283 const SwPageFrame* pPageFrame = SwFrameMenuButtonBase::GetPageFrame(m_pFrame);
284 const SwPageDesc* pDesc = pPageFrame->GetPageDesc();
285 bool bIsFirst = !pDesc->IsFirstShared() && pPageFrame->OnFirstPage();
286 bool bIsLeft = !pDesc->IsHeaderShared() && !pPageFrame->OnRightPage();
287 bool bIsRight = !pDesc->IsHeaderShared() && pPageFrame->OnRightPage();
288 m_sLabel = SwResId(STR_HEADER_TITLE);
289 if (!m_bIsHeader)
290 m_sLabel = bIsFirst ? SwResId(STR_FIRST_FOOTER_TITLE)
291 : bIsLeft ? SwResId(STR_LEFT_FOOTER_TITLE)
292 : bIsRight ? SwResId(STR_RIGHT_FOOTER_TITLE)
293 : SwResId(STR_FOOTER_TITLE );
294 else
295 m_sLabel = bIsFirst ? SwResId(STR_FIRST_HEADER_TITLE)
296 : bIsLeft ? SwResId(STR_LEFT_HEADER_TITLE)
297 : bIsRight ? SwResId(STR_RIGHT_HEADER_TITLE)
298 : SwResId(STR_HEADER_TITLE);
300 sal_Int32 nPos = m_sLabel.lastIndexOf("%1");
301 m_sLabel = m_sLabel.replaceAt(nPos, 2, pDesc->GetName());
302 m_xMenuButton->set_accessible_name(m_sLabel);
304 // Compute the text size and get the box position & size from it
305 ::tools::Rectangle aTextRect;
306 m_xVirDev->GetTextBoundRect(aTextRect, m_sLabel);
307 ::tools::Rectangle aTextPxRect = m_xVirDev->LogicToPixel(aTextRect);
308 FontMetric aFontMetric = m_xVirDev->GetFontMetric(m_xVirDev->GetFont());
309 Size aBoxSize (aTextPxRect.GetWidth() + BUTTON_WIDTH + TEXT_PADDING * 2,
310 aFontMetric.GetLineHeight() + TEXT_PADDING * 2 );
312 tools::Long nYFooterOff = 0;
313 if (!m_bIsHeader)
314 nYFooterOff = aBoxSize.Height();
316 Point aBoxPos(aOffset.X() - aBoxSize.Width() - BOX_DISTANCE,
317 aOffset.Y() - nYFooterOff);
319 if (AllSettings::GetLayoutRTL())
321 aBoxPos.setX( aOffset.X() + BOX_DISTANCE );
324 // Set the position & Size of the window
325 SetPosSizePixel(aBoxPos, aBoxSize);
327 m_xVirDev->SetOutputSizePixel(aBoxSize);
328 PaintButton();
331 void SwHeaderFooterWin::ShowAll(bool bShow)
333 bool bIsEmptyHeaderFooter = IsEmptyHeaderFooter();
334 m_xMenuButton->set_visible(!bIsEmptyHeaderFooter);
335 m_xPushButton->set_visible(bIsEmptyHeaderFooter);
337 m_bIsAppearing = bShow;
339 if (m_aFadeTimer.IsActive())
340 m_aFadeTimer.Stop();
341 m_aFadeTimer.Start();
344 bool SwHeaderFooterWin::Contains( const Point &rDocPt ) const
346 ::tools::Rectangle aRect(GetPosPixel(), GetSizePixel());
347 return aRect.Contains(rDocPt);
350 void SwHeaderFooterWin::PaintButton()
352 if (!m_xVirDev)
353 return;
355 // Use pixels for the rest of the drawing
356 SetMapMode(MapMode(MapUnit::MapPixel));
357 drawinglayer::primitive2d::Primitive2DContainer aSeq;
358 const ::tools::Rectangle aRect(::tools::Rectangle(Point(0, 0), m_xVirDev->PixelToLogic(GetSizePixel())));
360 SwFrameButtonPainter::PaintButton(aSeq, aRect, m_bIsHeader);
362 // Create the text primitive
363 basegfx::BColor aLineColor = SwViewOption::GetCurrentViewOptions().GetHeaderFooterMarkColor().getBColor();
364 B2DVector aFontSize;
365 FontAttribute aFontAttr = drawinglayer::primitive2d::getFontAttributeFromVclFont(aFontSize, m_xVirDev->GetFont(), false, false);
367 FontMetric aFontMetric = m_xVirDev->GetFontMetric(m_xVirDev->GetFont());
368 double nTextOffsetY = aFontMetric.GetAscent() + TEXT_PADDING;
369 Point aTextPos(TEXT_PADDING, nTextOffsetY);
371 basegfx::B2DHomMatrix aTextMatrix(createScaleTranslateB2DHomMatrix(
372 aFontSize.getX(), aFontSize.getY(),
373 double(aTextPos.X()), double(aTextPos.Y())));
375 aSeq.push_back(drawinglayer::primitive2d::Primitive2DReference(
376 new drawinglayer::primitive2d::TextSimplePortionPrimitive2D(
377 aTextMatrix, m_sLabel, 0, m_sLabel.getLength(),
378 std::vector<double>(), {}, std::move(aFontAttr), css::lang::Locale(), aLineColor)));
380 // Create the 'plus' or 'arrow' primitive
381 B2DRectangle aSignArea(B2DPoint(aRect.Right() - BUTTON_WIDTH, 0.0),
382 B2DVector(aRect.Right(), aRect.getOpenHeight()));
384 B2DPolygon aSign;
385 bool bIsEmptyHeaderFooter = IsEmptyHeaderFooter();
386 if (bIsEmptyHeaderFooter)
388 // Create the + polygon
389 double nLeft = aSignArea.getMinX() + TEXT_PADDING;
390 double nRight = aSignArea.getMaxX() - TEXT_PADDING;
391 double nHalfW = ( nRight - nLeft ) / 2.0;
393 double nTop = aSignArea.getCenterY() - nHalfW;
394 double nBottom = aSignArea.getCenterY() + nHalfW;
396 aSign.append(B2DPoint(nLeft, aSignArea.getCenterY() - 1.0));
397 aSign.append(B2DPoint(aSignArea.getCenterX() - 1.0, aSignArea.getCenterY() - 1.0));
398 aSign.append(B2DPoint(aSignArea.getCenterX() - 1.0, nTop));
399 aSign.append(B2DPoint(aSignArea.getCenterX() + 1.0, nTop));
400 aSign.append(B2DPoint(aSignArea.getCenterX() + 1.0, aSignArea.getCenterY() - 1.0));
401 aSign.append(B2DPoint(nRight, aSignArea.getCenterY() - 1.0));
402 aSign.append(B2DPoint(nRight, aSignArea.getCenterY() + 1.0));
403 aSign.append(B2DPoint(aSignArea.getCenterX() + 1.0, aSignArea.getCenterY() + 1.0));
404 aSign.append(B2DPoint(aSignArea.getCenterX() + 1.0, nBottom));
405 aSign.append(B2DPoint(aSignArea.getCenterX() - 1.0, nBottom));
406 aSign.append(B2DPoint(aSignArea.getCenterX() - 1.0, aSignArea.getCenterY() + 1.0));
407 aSign.append(B2DPoint(nLeft, aSignArea.getCenterY() + 1.0));
408 aSign.setClosed(true);
410 else
412 // Create the v polygon
413 B2DPoint aLeft(aSignArea.getMinX() + TEXT_PADDING, aSignArea.getCenterY());
414 B2DPoint aRight(aSignArea.getMaxX() - TEXT_PADDING, aSignArea.getCenterY());
415 B2DPoint aBottom((aLeft.getX() + aRight.getX()) / 2.0, aLeft.getY() + 4.0);
416 aSign.append(aLeft);
417 aSign.append(aRight);
418 aSign.append(aBottom);
419 aSign.setClosed(true);
422 BColor aSignColor = COL_BLACK.getBColor();
423 if (Application::GetSettings().GetStyleSettings().GetHighContrastMode())
424 aSignColor = COL_WHITE.getBColor();
426 aSeq.push_back( drawinglayer::primitive2d::Primitive2DReference(
427 new drawinglayer::primitive2d::PolyPolygonColorPrimitive2D(
428 B2DPolyPolygon(aSign), aSignColor)) );
430 // Create the processor and process the primitives
431 const drawinglayer::geometry::ViewInformation2D aNewViewInfos;
432 std::unique_ptr<drawinglayer::processor2d::BaseProcessor2D> pProcessor(
433 drawinglayer::processor2d::createProcessor2DFromOutputDevice(*m_xVirDev, aNewViewInfos));
435 // TODO Ghost it all if needed
436 drawinglayer::primitive2d::Primitive2DContainer aGhostedSeq(1);
437 double nFadeRate = double(m_nFadeRate) / 100.0;
439 const basegfx::BColorModifierSharedPtr aBColorModifier =
440 std::make_shared<basegfx::BColorModifier_interpolate>(COL_WHITE.getBColor(),
441 1.0 - nFadeRate);
443 aGhostedSeq[0] = drawinglayer::primitive2d::Primitive2DReference(
444 new drawinglayer::primitive2d::ModifiedColorPrimitive2D(std::move(aSeq), aBColorModifier));
446 pProcessor->process(aGhostedSeq);
448 if (bIsEmptyHeaderFooter)
449 m_xPushButton->set_custom_button(m_xVirDev.get());
450 else
451 m_xMenuButton->set_custom_button(m_xVirDev.get());
454 bool SwHeaderFooterWin::IsEmptyHeaderFooter( ) const
456 bool bResult = true;
458 const SwPageFrame* pPageFrame = SwFrameMenuButtonBase::GetPageFrame(m_pFrame);
459 if (!pPageFrame)
461 return bResult;
464 // Actually check it
465 const SwPageDesc* pDesc = pPageFrame->GetPageDesc();
467 bool const bFirst(pPageFrame->OnFirstPage());
468 const SwFrameFormat *const pFormat = (pPageFrame->OnRightPage())
469 ? pDesc->GetRightFormat(bFirst)
470 : pDesc->GetLeftFormat(bFirst);
472 if ( pFormat )
474 if ( m_bIsHeader )
475 bResult = !pFormat->GetHeader().IsActive();
476 else
477 bResult = !pFormat->GetFooter().IsActive();
480 return bResult;
483 void SwHeaderFooterWin::ExecuteCommand(std::u16string_view rIdent)
485 SwView& rView = m_pEditWin->GetView();
486 SwWrtShell& rSh = rView.GetWrtShell();
488 const SwPageFrame* pPageFrame = SwFrameMenuButtonBase::GetPageFrame(m_pFrame);
489 const OUString& rStyleName = pPageFrame->GetPageDesc()->GetName();
490 if (rIdent == u"edit")
492 OUString sPageId = m_bIsHeader ? OUString("header") : OUString("footer");
493 rView.GetDocShell()->FormatPage(rView.GetFrameWeld(), rStyleName, sPageId, rSh);
495 else if (rIdent == u"borderback")
497 const SwPageDesc* pDesc = pPageFrame->GetPageDesc();
498 const SwFrameFormat& rMaster = pDesc->GetMaster();
499 SwFrameFormat* pHFFormat = const_cast< SwFrameFormat* >( rMaster.GetFooter().GetFooterFormat() );
500 if ( m_bIsHeader )
501 pHFFormat = const_cast< SwFrameFormat* >( rMaster.GetHeader().GetHeaderFormat() );
502 SfxItemSet aSet( pHFFormat->GetAttrSet() );
504 // Items to hand over XPropertyList things like XColorList,
505 // XHatchList, XGradientList, and XBitmapList to the Area TabPage:
506 aSet.MergeRange( SID_COLOR_TABLE, SID_PATTERN_LIST );
507 // create needed items for XPropertyList entries from the DrawModel so that
508 // the Area TabPage can access them
509 rSh.GetDoc()->getIDocumentDrawModelAccess().GetDrawModel()->PutAreaListItems( aSet );
511 aSet.MergeRange(SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER);
512 // Create a box info item... needed by the dialog
513 std::shared_ptr<SvxBoxInfoItem> aBoxInfo(std::make_shared<SvxBoxInfoItem>(SID_ATTR_BORDER_INNER));
514 if (const SvxBoxInfoItem *pBoxInfo = pHFFormat->GetAttrSet().GetItemIfSet(SID_ATTR_BORDER_INNER))
515 aBoxInfo.reset(pBoxInfo->Clone());
517 aBoxInfo->SetTable(false);
518 aBoxInfo->SetDist(true);
519 aBoxInfo->SetMinDist(false);
520 aBoxInfo->SetDefDist(MIN_BORDER_DIST);
521 aBoxInfo->SetValid(SvxBoxInfoItemValidFlags::DISABLE);
522 aSet.Put(*aBoxInfo);
524 if (svx::ShowBorderBackgroundDlg( GetFrameWeld(), &aSet ) )
526 pHFFormat->SetFormatAttr( aSet );
527 rView.GetDocShell()->SetModified();
530 else if (rIdent == u"delete")
532 rSh.ChangeHeaderOrFooter( rStyleName, m_bIsHeader, false, true );
533 // warning: "this" may be disposed now
534 rSh.GetWin()->GrabFocusToDocument();
536 else if (rIdent == u"insert_pagenumber")
538 SfxViewFrame& rVFrame = rSh.GetView().GetViewFrame();
539 rVFrame.GetBindings().Execute(FN_INSERT_FLD_PGNUMBER);
541 else if (rIdent == u"insert_pagecount")
543 SfxViewFrame& rVFrame = rSh.GetView().GetViewFrame();
544 rVFrame.GetBindings().Execute(FN_INSERT_FLD_PGCOUNT);
548 IMPL_LINK_NOARG(SwHeaderFooterWin, ClickHdl, weld::Button&, void)
550 SwView& rView = m_pEditWin->GetView();
551 SwWrtShell& rSh = rView.GetWrtShell();
553 const SwPageFrame* pPageFrame = SwFrameMenuButtonBase::GetPageFrame(m_pFrame);
554 const OUString& rStyleName = pPageFrame->GetPageDesc()->GetName();
556 VclPtr<SwHeaderFooterWin> xThis(this);
557 rSh.ChangeHeaderOrFooter( rStyleName, m_bIsHeader, true, false );
558 //tdf#153059 after ChangeHeaderOrFooter is it possible that "this" is disposed
559 if (xThis->isDisposed())
560 return;
562 m_xPushButton->hide();
563 m_xMenuButton->show();
564 PaintButton();
567 IMPL_LINK(SwHeaderFooterWin, SelectHdl, const OUString&, rIdent, void)
569 ExecuteCommand(rIdent);
572 IMPL_LINK_NOARG(SwHeaderFooterWin, FadeHandler, Timer *, void)
574 if (m_bIsAppearing && m_nFadeRate > 0)
575 m_nFadeRate -= 25;
576 else if (!m_bIsAppearing && m_nFadeRate < 100)
577 m_nFadeRate += 25;
579 if (m_nFadeRate != 100 && !IsVisible())
581 Show();
583 else if (m_nFadeRate == 100 && IsVisible())
585 Show(false);
587 else
588 PaintButton();
590 if (IsVisible() && m_nFadeRate > 0 && m_nFadeRate < 100)
591 m_aFadeTimer.Start();
594 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */