LibreOffice Module svx (master) 1
fmpage.cxx
Go to the documentation of this file.
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 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20#include <svx/fmpage.hxx>
21#include <com/sun/star/beans/XPropertySet.hpp>
22
23#include <svx/fmmodel.hxx>
24
25#include <fmobj.hxx>
26
27#include <fmpgeimp.hxx>
28
29#include <svx/svdview.hxx>
30#include <tools/urlobj.hxx>
31#include <vcl/help.hxx>
32#include <vcl/window.hxx>
33#include <osl/diagnose.h>
34
35
36#include <fmprop.hxx>
37#include <fmundo.hxx>
38using namespace ::svxform;
40#include <comphelper/types.hxx>
41
43using com::sun::star::uno::UNO_QUERY;
44
45
46FmFormPage::FmFormPage(FmFormModel& rModel, bool bMasterPage)
47: SdrPage(rModel, bMasterPage)
48 ,m_pImpl( new FmFormPageImpl( *this ) )
49{
50}
51
53{
54 // call parent
55 SdrPage::lateInit( rPage );
56
57 // copy local variables (former stuff from copy constructor)
58 m_pImpl->initFrom( rPage.GetImpl() );
60}
61
62
64{
65}
66
68{
69 FmFormModel& rFmFormModel(static_cast< FmFormModel& >(rTargetModel));
70 rtl::Reference<FmFormPage> pClonedFmFormPage =
71 new FmFormPage(
72 rFmFormModel,
73 IsMasterPage());
74 pClonedFmFormPage->lateInit(*this);
75 return pClonedFmFormPage;
76}
77
78
79void FmFormPage::InsertObject(SdrObject* pObj, size_t nPos)
80{
82 static_cast< FmFormModel& >(getSdrModelFromSdrPage()).GetUndoEnv().Inserted(pObj);
83}
84
85
86const Reference< css::form::XForms > & FmFormPage::GetForms( bool _bForceCreate ) const
87{
88 const SdrPage& rMasterPage( *this );
89 const FmFormPage* pFormPage = dynamic_cast< const FmFormPage* >( &rMasterPage );
90 OSL_ENSURE( pFormPage, "FmFormPage::GetForms: referenced page is no FmFormPage - is this allowed?!" );
91 if ( !pFormPage )
92 pFormPage = this;
93
94 return pFormPage->m_pImpl->getForms( _bForceCreate );
95}
96
97
98bool FmFormPage::RequestHelp( vcl::Window* pWindow, SdrView const * pView,
99 const HelpEvent& rEvt )
100{
101 if( pView->IsAction() )
102 return false;
103
104 Point aPos = rEvt.GetMousePosPixel();
105 aPos = pWindow->ScreenToOutputPixel( aPos );
106 aPos = pWindow->PixelToLogic( aPos );
107
108 SdrPageView* pPV = nullptr;
109 SdrObject* pObj = pView->PickObj(aPos, 0, pPV, SdrSearchOptions::DEEP);
110 if (!pObj)
111 return false;
112
113 FmFormObj* pFormObject = FmFormObj::GetFormObject( pObj );
114 if ( !pFormObject )
115 return false;
116
117 OUString aHelpText;
118 css::uno::Reference< css::beans::XPropertySet > xSet( pFormObject->GetUnoControlModel(), css::uno::UNO_QUERY );
119 if (xSet.is())
120 {
121 if (::comphelper::hasProperty(FM_PROP_HELPTEXT, xSet))
122 aHelpText = ::comphelper::getString(xSet->getPropertyValue(FM_PROP_HELPTEXT));
123
124 if (aHelpText.isEmpty() && ::comphelper::hasProperty(FM_PROP_TARGET_URL, xSet))
125 {
126 OUString aText = ::comphelper::getString(xSet->getPropertyValue(FM_PROP_TARGET_URL));
127 INetURLObject aUrl(aText);
128
129 // test if it is a protocol type that I want to display
130 INetProtocol aProtocol = aUrl.GetProtocol();
131 static const INetProtocol s_aQuickHelpSupported[] =
132 { INetProtocol::Ftp, INetProtocol::Http, INetProtocol::File, INetProtocol::Mailto,
133 INetProtocol::Https, INetProtocol::Javascript,
134 INetProtocol::Ldap
135 };
136 for (const INetProtocol& i : s_aQuickHelpSupported)
137 if (i == aProtocol)
138 {
140 break;
141 }
142 }
143 }
144 if ( !aHelpText.isEmpty() )
145 {
146 // display the help
147 tools::Rectangle aItemRect = pObj->GetCurrentBoundRect();
148 aItemRect = pWindow->LogicToPixel( aItemRect );
149 Point aPt = pWindow->OutputToScreenPixel( aItemRect.TopLeft() );
150 aItemRect.SetLeft( aPt.X() );
151 aItemRect.SetTop( aPt.Y() );
152 aPt = pWindow->OutputToScreenPixel( aItemRect.BottomRight() );
153 aItemRect.SetRight( aPt.X() );
154 aItemRect.SetBottom( aPt.Y() );
155 if( rEvt.GetMode() == HelpEventMode::BALLOON )
156 Help::ShowBalloon( pWindow, aItemRect.Center(), aItemRect, aHelpText);
157 else
158 Help::ShowQuickHelp( pWindow, aItemRect, aHelpText );
159 }
160 return true;
161}
162
163
165{
167 if (pObj)
168 static_cast< FmFormModel& >(getSdrModelFromSdrPage()).GetUndoEnv().Removed(pObj.get());
169 return pObj;
170}
171
172/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
::std::unique_ptr< XmlIdRegistry_Impl > m_pImpl
void lateInit(const FmFormPage &rPage)
Definition: fmpage.cxx:52
friend class FmFormObj
Definition: fmpage.hxx:44
const css::uno::Reference< css::form::XForms > & GetForms(bool _bForceCreate=true) const
Definition: fmpage.cxx:86
FmFormPage(const FmFormPage &)=delete
std::unique_ptr< FmFormPageImpl > m_pImpl
Definition: fmpage.hxx:45
static bool RequestHelp(vcl::Window *pWin, SdrView const *pView, const HelpEvent &rEvt)
Definition: fmpage.cxx:98
virtual ~FmFormPage() override
Definition: fmpage.cxx:63
OUString m_sPageName
Definition: fmpage.hxx:46
virtual void InsertObject(SdrObject *pObj, size_t nPos=SAL_MAX_SIZE) override
Definition: fmpage.cxx:79
FmFormPageImpl & GetImpl() const
Definition: fmpage.hxx:62
virtual rtl::Reference< SdrObject > RemoveObject(size_t nObjNum) override
Definition: fmpage.cxx:164
virtual rtl::Reference< SdrPage > CloneSdrPage(SdrModel &rTargetModel) const override
Definition: fmpage.cxx:67
HelpEventMode GetMode() const
const Point & GetMousePosPixel() const
static void ShowQuickHelp(vcl::Window *pParent, const tools::Rectangle &rScreenRect, const OUString &rHelpText, QuickHelpFlags nStyle=QuickHelpFlags::NONE)
static void ShowBalloon(vcl::Window *pParent, const Point &rScreenPos, const tools::Rectangle &, const OUString &rHelpText)
INetProtocol GetProtocol() const
OUString GetURLNoPass(DecodeMechanism eMechanism=DecodeMechanism::ToIUri, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
constexpr tools::Long Y() const
constexpr tools::Long X() const
virtual bool IsAction() const override
Definition: svdcrtv.cxx:201
SdrObject * PickObj(const Point &rPnt, short nTol, SdrPageView *&rpPV, SdrSearchOptions nOptions, SdrObject **ppRootObj, bool *pbHitPassDirect=nullptr) const
Definition: svdmrkv.cxx:2426
virtual void InsertObject(SdrObject *pObj, size_t nPos=SAL_MAX_SIZE)
Definition: svdpage.cxx:295
virtual rtl::Reference< SdrObject > RemoveObject(size_t nObjNum)
Definition: svdpage.cxx:373
Abstract DrawObject.
Definition: svdobj.hxx:260
virtual const tools::Rectangle & GetCurrentBoundRect() const
Definition: svdobj.cxx:962
A SdrPage contains exactly one SdrObjList and a description of the physical page dimensions (size / m...
Definition: svdpage.hxx:379
bool IsMasterPage() const
Definition: svdpage.hxx:464
void lateInit(const SdrPage &rSrcPage)
Definition: svdpage.cxx:1372
SdrModel & getSdrModelFromSdrPage() const
Definition: svdpage.hxx:403
constexpr Point Center() const
constexpr void SetLeft(tools::Long v)
constexpr void SetTop(tools::Long v)
constexpr Point TopLeft() const
constexpr void SetRight(tools::Long v)
constexpr void SetBottom(tools::Long v)
constexpr Point BottomRight() const
Point OutputToScreenPixel(const Point &rPos) const
Point LogicToPixel(const Point &rLogicPt) const
Point PixelToLogic(const Point &rDevicePt) const
Point ScreenToOutputPixel(const Point &rPos) const
constexpr OUStringLiteral FM_PROP_HELPTEXT
Definition: fmprop.hxx:100
constexpr OUStringLiteral FM_PROP_TARGET_URL
Definition: fmprop.hxx:54
sal_uInt16 nPos
int i
class FmSearchEngine - Impl class for FmSearchDialog
INetProtocol