diff options
Diffstat (limited to '')
57 files changed, 10232 insertions, 0 deletions
diff --git a/svx/source/inc/AccessibleFrameSelector.hxx b/svx/source/inc/AccessibleFrameSelector.hxx new file mode 100644 index 000000000..26f30aa67 --- /dev/null +++ b/svx/source/inc/AccessibleFrameSelector.hxx @@ -0,0 +1,137 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_SVX_SOURCE_INC_ACCESSIBLEFRAMESELECTOR_HXX +#define INCLUDED_SVX_SOURCE_INC_ACCESSIBLEFRAMESELECTOR_HXX + +#include <com/sun/star/accessibility/XAccessible.hpp> +#include <com/sun/star/accessibility/XAccessibleContext.hpp> +#include <cppuhelper/implbase1.hxx> +#include<comphelper/accessiblecomponenthelper.hxx> +#include <svx/framebordertype.hxx> + +namespace svx { + +class FrameSelector; + +namespace a11y { + +typedef ::cppu::ImplHelper1<css::accessibility::XAccessible> OAccessibleHelper_Base; + +class AccFrameSelector final : public ::comphelper::OAccessibleComponentHelper, + public OAccessibleHelper_Base +{ +public: + explicit AccFrameSelector(FrameSelector& rFrameSel); + virtual ~AccFrameSelector() override; + + DECLARE_XINTERFACE( ) + DECLARE_XTYPEPROVIDER( ) + + //XAccessibleComponent + virtual void SAL_CALL grabFocus( ) override; + virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleAtPoint( const css::awt::Point& aPoint ) override; + + //XAccessibleContext + virtual sal_Int32 SAL_CALL getAccessibleChildCount( ) override; + virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleChild( sal_Int32 i ) override; + virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleParent( ) override; + virtual sal_Int16 SAL_CALL getAccessibleRole( ) override; + virtual OUString SAL_CALL getAccessibleDescription( ) override; + virtual OUString SAL_CALL getAccessibleName( ) override; + virtual css::uno::Reference< css::accessibility::XAccessibleRelationSet > SAL_CALL getAccessibleRelationSet( ) override; + virtual css::uno::Reference< css::accessibility::XAccessibleStateSet > SAL_CALL getAccessibleStateSet( ) override; + + //XAccessible + virtual css::uno::Reference< css::accessibility::XAccessibleContext > SAL_CALL getAccessibleContext( ) override; + + virtual sal_Int32 SAL_CALL getForeground( ) override; + virtual sal_Int32 SAL_CALL getBackground( ) override; + + void Invalidate(); + +private: + // OCommonAccessibleComponent + /// implements the calculation of the bounding rectangle + virtual css::awt::Rectangle implGetBounds( ) override; + + /// @throws css::uno::RuntimeException + void IsValid(); + + FrameSelector* mpFrameSel; +}; + +class AccFrameSelectorChild final : public ::comphelper::OAccessibleComponentHelper, + public OAccessibleHelper_Base +{ +public: + explicit AccFrameSelectorChild( FrameSelector& rFrameSel, FrameBorderType eBorder ); + + virtual ~AccFrameSelectorChild() override; + + DECLARE_XINTERFACE( ) + DECLARE_XTYPEPROVIDER( ) + + //XAccessibleComponent + virtual void SAL_CALL grabFocus( ) override; + virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleAtPoint( const css::awt::Point& aPoint ) override; + + //XAccessibleContext + virtual sal_Int32 SAL_CALL getAccessibleChildCount( ) override; + virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleChild( sal_Int32 i ) override; + virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleParent( ) override; + virtual sal_Int16 SAL_CALL getAccessibleRole( ) override; + virtual OUString SAL_CALL getAccessibleDescription( ) override; + virtual OUString SAL_CALL getAccessibleName( ) override; + virtual css::uno::Reference< css::accessibility::XAccessibleRelationSet > SAL_CALL getAccessibleRelationSet( ) override; + virtual css::uno::Reference< css::accessibility::XAccessibleStateSet > SAL_CALL getAccessibleStateSet( ) override; + + //XAccessible + virtual css::uno::Reference< css::accessibility::XAccessibleContext > SAL_CALL getAccessibleContext( ) override; + + virtual sal_Int32 SAL_CALL getForeground( ) override; + virtual sal_Int32 SAL_CALL getBackground( ) override; + + void NotifyAccessibleEvent(const sal_Int16 _nEventId, const css::uno::Any& _rOldValue, const css::uno::Any& _rNewValue) + { + ::comphelper::OAccessibleComponentHelper::NotifyAccessibleEvent(_nEventId, _rOldValue, _rNewValue); + } + + void Invalidate(); + +private: + // OCommonAccessibleComponent + /// implements the calculation of the bounding rectangle + virtual css::awt::Rectangle implGetBounds( ) override; + + /// @throws css::uno::RuntimeException + void IsValid(); + + FrameSelector* mpFrameSel; + + FrameBorderType meBorder; +}; + + +} +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/inc/DefaultShapesPanel.hxx b/svx/source/inc/DefaultShapesPanel.hxx new file mode 100644 index 000000000..6067c05b5 --- /dev/null +++ b/svx/source/inc/DefaultShapesPanel.hxx @@ -0,0 +1,83 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_SVX_SOURCE_INC_DEFAULTSHAPESPANEL_HXX +#define INCLUDED_SVX_SOURCE_INC_DEFAULTSHAPESPANEL_HXX + +#include <com/sun/star/frame/XFrame.hpp> +#include <sfx2/sidebar/PanelLayout.hxx> +#include <svtools/valueset.hxx> +#include <map> +#include "ShapesUtil.hxx" + +using namespace css; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::frame; + +namespace svx::sidebar { + +/** This panel provides buttons for inserting shapes into a document. +*/ +class DefaultShapesPanel + : public PanelLayout, public SvxShapeCommandsMap +{ +public: + DefaultShapesPanel ( + vcl::Window* pParent, + const css::uno::Reference<css::frame::XFrame>& rxFrame); + static VclPtr<vcl::Window> Create( + vcl::Window* pParent, + const css::uno::Reference<css::frame::XFrame>& rxFrame); + virtual ~DefaultShapesPanel() override; + virtual void dispose() override; + +private: + std::unique_ptr<ValueSet> mxLineArrowSet; + std::unique_ptr<weld::CustomWeld> mxLineArrowSetWin; + std::unique_ptr<ValueSet> mxCurveSet; + std::unique_ptr<weld::CustomWeld> mxCurveSetWin; + std::unique_ptr<ValueSet> mxConnectorSet; + std::unique_ptr<weld::CustomWeld> mxConnectorSetWin; + std::unique_ptr<ValueSet> mxBasicShapeSet; + std::unique_ptr<weld::CustomWeld> mxBasicShapeSetWin; + std::unique_ptr<ValueSet> mxSymbolShapeSet; + std::unique_ptr<weld::CustomWeld> mxSymbolShapeSetWin; + std::unique_ptr<ValueSet> mxBlockArrowSet; + std::unique_ptr<weld::CustomWeld> mxBlockArrowSetWin; + std::unique_ptr<ValueSet> mxFlowchartSet; + std::unique_ptr<weld::CustomWeld> mxFlowchartSetWin; + std::unique_ptr<ValueSet> mxCalloutSet; + std::unique_ptr<weld::CustomWeld> mxCalloutSetWin; + std::unique_ptr<ValueSet> mxStarSet; + std::unique_ptr<weld::CustomWeld> mxStarSetWin; + std::unique_ptr<ValueSet> mx3DObjectSet; + std::unique_ptr<weld::CustomWeld> mx3DObjectSetWin; + + Reference< XFrame > mxFrame; + std::map<ValueSet*, std::map<sal_uInt16, OUString>> mpShapesSetMap; + + void populateShapes(); + void Initialize(); + DECL_LINK( ShapeSelectHdl, ValueSet*, void ); +}; + +} // end of namespace sd::sidebar + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/inc/GraphCtlAccessibleContext.hxx b/svx/source/inc/GraphCtlAccessibleContext.hxx new file mode 100644 index 000000000..f476f5e14 --- /dev/null +++ b/svx/source/inc/GraphCtlAccessibleContext.hxx @@ -0,0 +1,190 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + + +#ifndef INCLUDED_SVX_SOURCE_INC_GRAPHCTLACCESSIBLECONTEXT_HXX +#define INCLUDED_SVX_SOURCE_INC_GRAPHCTLACCESSIBLECONTEXT_HXX + +#include <cppuhelper/compbase7.hxx> +#include <com/sun/star/uno/Reference.hxx> +#include <com/sun/star/accessibility/XAccessible.hpp> +#include <com/sun/star/accessibility/XAccessibleComponent.hpp> +#include <com/sun/star/accessibility/XAccessibleContext.hpp> +#include <com/sun/star/accessibility/XAccessibleEventBroadcaster.hpp> +#include <com/sun/star/accessibility/XAccessibleSelection.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/lang/XServiceName.hpp> +#include <cppuhelper/basemutex.hxx> +#include <svl/lstner.hxx> + +#include <map> + +#include <svx/AccessibleShapeTreeInfo.hxx> +#include <svx/IAccessibleViewForwarder.hxx> +#include <svx/AccessibleShape.hxx> + +namespace com::sun::star::awt { + struct Point; + struct Rectangle; + struct Size; + class XFocusListener; +} +namespace tools { class Rectangle; } +class GraphCtrl; +class SdrObject; +class SdrModel; +class SdrPage; +class SdrView; + +/** @descr + This base class provides an implementation of the + <code>AccessibleContext</code> service. +*/ + +typedef ::cppu::WeakAggComponentImplHelper7< + css::accessibility::XAccessible, + css::accessibility::XAccessibleComponent, + css::accessibility::XAccessibleContext, + css::accessibility::XAccessibleEventBroadcaster, + css::accessibility::XAccessibleSelection, + css::lang::XServiceInfo, + css::lang::XServiceName > + SvxGraphCtrlAccessibleContext_Base; + +class SvxGraphCtrlAccessibleContext final : + private cppu::BaseMutex, public SvxGraphCtrlAccessibleContext_Base, + public SfxListener, public ::accessibility::IAccessibleViewForwarder +{ +public: + friend class GraphCtrl; + + // internal + SvxGraphCtrlAccessibleContext(GraphCtrl& rRepresentation); + + void Notify( SfxBroadcaster& aBC, const SfxHint& aHint ) override; + + // XAccessible + /// Return the XAccessibleContext. + virtual css::uno::Reference< css::accessibility::XAccessibleContext> SAL_CALL + getAccessibleContext() override; + + // XAccessibleComponent + virtual sal_Bool SAL_CALL containsPoint( const css::awt::Point& rPoint ) override; + virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleAtPoint( const css::awt::Point& rPoint ) override; + virtual css::awt::Rectangle SAL_CALL getBounds() override; + virtual css::awt::Point SAL_CALL getLocation() override; + virtual css::awt::Point SAL_CALL getLocationOnScreen() override; + virtual css::awt::Size SAL_CALL getSize() override; + virtual void SAL_CALL grabFocus() override; + + virtual sal_Int32 SAL_CALL getForeground() override; + + virtual sal_Int32 SAL_CALL getBackground() override; + + // XAccessibleContext + virtual sal_Int32 SAL_CALL getAccessibleChildCount() override; + virtual css::uno::Reference< css::accessibility::XAccessible> SAL_CALL getAccessibleChild (sal_Int32 nIndex) override; + virtual css::uno::Reference< css::accessibility::XAccessible> SAL_CALL getAccessibleParent() override; + virtual sal_Int32 SAL_CALL getAccessibleIndexInParent() override; + virtual sal_Int16 SAL_CALL getAccessibleRole() override; + virtual OUString SAL_CALL getAccessibleDescription() override; + virtual OUString SAL_CALL getAccessibleName() override; + virtual css::uno::Reference< css::accessibility::XAccessibleRelationSet> SAL_CALL getAccessibleRelationSet() override; + virtual css::uno::Reference< css::accessibility::XAccessibleStateSet> SAL_CALL getAccessibleStateSet() override; + virtual css::lang::Locale SAL_CALL getLocale() override; + + // XAccessibleEventBroadcaster + virtual void SAL_CALL addAccessibleEventListener( const css::uno::Reference< css::accessibility::XAccessibleEventListener>& xListener) override; + virtual void SAL_CALL removeAccessibleEventListener( const css::uno::Reference< css::accessibility::XAccessibleEventListener>& xListener) override; + + // XServiceInfo + virtual OUString SAL_CALL getImplementationName() override; + virtual sal_Bool SAL_CALL supportsService (const OUString& sServiceName) override; + virtual css::uno::Sequence< OUString> SAL_CALL getSupportedServiceNames() override; + + // XTypeProvider + virtual css::uno::Sequence<sal_Int8> SAL_CALL getImplementationId() override; + + // XServiceName + virtual OUString SAL_CALL getServiceName() override; + + // XAccessibleSelection + virtual void SAL_CALL selectAccessibleChild( sal_Int32 nChildIndex ) override; + virtual sal_Bool SAL_CALL isAccessibleChildSelected( sal_Int32 nChildIndex ) override; + virtual void SAL_CALL clearAccessibleSelection() override; + virtual void SAL_CALL selectAllAccessibleChildren() override; + virtual sal_Int32 SAL_CALL getSelectedAccessibleChildCount() override; + virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex ) override; + virtual void SAL_CALL deselectAccessibleChild( sal_Int32 nSelectedChildIndex ) override; + + // IAccessibleViewforwarder + virtual tools::Rectangle GetVisibleArea() const override; + virtual Point LogicToPixel (const Point& rPoint) const override; + virtual Size LogicToPixel (const Size& rSize) const override; + + /** This method is used by the graph control to tell the + accessibility object about a new model and view. + */ + void setModelAndView (SdrModel* pModel, SdrView* pView); + +private: + virtual ~SvxGraphCtrlAccessibleContext() override; + /// @throws css::lang::IndexOutOfBoundsException + void checkChildIndexOnSelection( long nIndexOfChild ); + + virtual void SAL_CALL disposing() final override; + + /// @throws css::uno::RuntimeException + /// @throws css::lang::IndexOutOfBoundsException + SdrObject* getSdrObject( sal_Int32 nIndex ); + + void CommitChange (sal_Int16 aEventId, const css::uno::Any& rNewValue, const css::uno::Any& rOldValue); + + css::uno::Reference< css::accessibility::XAccessible > getAccessible( const SdrObject* pObj ); + + ::accessibility::AccessibleShapeTreeInfo maTreeInfo; + + /** Description of this object. This is not a constant because it can + be set from the outside. + */ + OUString msDescription; + + /** Name of this object. + */ + OUString msName; + + /// map of accessible shapes + typedef ::std::map< const SdrObject*, rtl::Reference<::accessibility::AccessibleShape> > ShapesMapType; + ShapesMapType mxShapes; + + GraphCtrl* mpControl; + + SdrModel* mpModel; + SdrPage* mpPage; + SdrView* mpView; + + /// client id in the AccessibleEventNotifier queue + sal_uInt32 mnClientId; + + bool mbDisposed; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/inc/ShapesUtil.hxx b/svx/source/inc/ShapesUtil.hxx new file mode 100644 index 000000000..72d6e63dc --- /dev/null +++ b/svx/source/inc/ShapesUtil.hxx @@ -0,0 +1,39 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_SVX_SOURCE_INC_SHAPESUTIL_HXX +#define INCLUDED_SVX_SOURCE_INC_SHAPESUTIL_HXX +#include <map> +#include <rtl/ustring.hxx> + +namespace svx::sidebar { + +class SvxShapeCommandsMap +{ +public: + SvxShapeCommandsMap(); + std::map<sal_uInt16, OUString> mpLineShapes, mpCurveShapes, + mpConnectorShapes, mpBasicShapes, mpSymbolShapes, + mpBlockArrowShapes, mpFlowchartShapes, + mpCalloutShapes, mpStarShapes, mp3DShapes; +}; + +} + +#endif +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
\ No newline at end of file diff --git a/svx/source/inc/cell.hxx b/svx/source/inc/cell.hxx new file mode 100644 index 000000000..0d68864f2 --- /dev/null +++ b/svx/source/inc/cell.hxx @@ -0,0 +1,221 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_SVX_SOURCE_INC_CELL_HXX +#define INCLUDED_SVX_SOURCE_INC_CELL_HXX + +#include <config_options.h> +#include <com/sun/star/table/XMergeableCell.hpp> +#include <com/sun/star/awt/XLayoutConstrains.hpp> +#include <com/sun/star/lang/XEventListener.hpp> + +#include <rtl/ref.hxx> +#include <svl/style.hxx> +#include <svx/sdtaitm.hxx> +#include "tablemodel.hxx" +#include <editeng/unotext.hxx> +#include <svx/svdtext.hxx> + + +class SfxItemSet; +class OutlinerParaObject; +class SdrObject; +namespace sdr::properties { class TextProperties; } + + +namespace sdr::table { + + +class UNLESS_MERGELIBS(SVXCORE_DLLPUBLIC) Cell : public SdrText, + public SvxUnoTextBase, + public css::table::XMergeableCell, + public css::awt::XLayoutConstrains, + public css::lang::XEventListener, + public ::cppu::OWeakObject +{ + friend class CellUndo; + +public: + SVX_DLLPRIVATE static rtl::Reference< Cell > create( SdrTableObj& rTableObj ); + + // private + SVX_DLLPRIVATE void dispose(); + + // SdrTextShape proxy + bool IsActiveCell() const; + bool IsTextEditActive() const; + SVX_DLLPRIVATE bool hasText() const; + + SVX_DLLPRIVATE void cloneFrom( const CellRef& rCell ); + + SVX_DLLPRIVATE void setCellRect( ::tools::Rectangle const & rCellRect ) { maCellRect = rCellRect; } + SVX_DLLPRIVATE const ::tools::Rectangle& getCellRect() const { return maCellRect; } + SVX_DLLPRIVATE ::tools::Rectangle& getCellRect() { return maCellRect; } + + bool CanCreateEditOutlinerParaObject() const; + std::unique_ptr<OutlinerParaObject> CreateEditOutlinerParaObject() const; + SVX_DLLPRIVATE void SetStyleSheet( SfxStyleSheet* pStyleSheet, bool bDontRemoveHardAttr ); + SVX_DLLPRIVATE virtual SfxStyleSheet* GetStyleSheet() const override; + SVX_DLLPRIVATE void TakeTextAnchorRect(tools::Rectangle& rAnchorRect) const; + + SVX_DLLPRIVATE void SetMergedItemSetAndBroadcast(const SfxItemSet& rSet, bool bClearAllItems); + void SetMergedItem(const SfxPoolItem& rItem); + + SVX_DLLPRIVATE sal_Int32 calcPreferredWidth( const Size aSize ); + SVX_DLLPRIVATE sal_Int32 getMinimumWidth() const; + SVX_DLLPRIVATE sal_Int32 getMinimumHeight(); + + SVX_DLLPRIVATE long GetTextLeftDistance() const; + SVX_DLLPRIVATE long GetTextRightDistance() const; + SVX_DLLPRIVATE long GetTextUpperDistance() const; + SVX_DLLPRIVATE long GetTextLowerDistance() const; + + SVX_DLLPRIVATE SdrTextVertAdjust GetTextVerticalAdjust() const; + SdrTextHorzAdjust GetTextHorizontalAdjust() const; + + SVX_DLLPRIVATE void merge( sal_Int32 nColumnSpan, sal_Int32 nRowSpan ); + SVX_DLLPRIVATE void mergeContent( const CellRef& xSourceCell ); + SVX_DLLPRIVATE void replaceContentAndFormating( const CellRef& xSourceCell ); + + SVX_DLLPRIVATE void setMerged(); + + SVX_DLLPRIVATE void copyFormatFrom( const CellRef& xSourceCell ); + + // XInterface + SVX_DLLPRIVATE virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type& Type ) override; + SVX_DLLPRIVATE virtual void SAL_CALL acquire() throw () override; + SVX_DLLPRIVATE virtual void SAL_CALL release() throw () override; + + // XTypeProvider + SVX_DLLPRIVATE virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes( ) override; + SVX_DLLPRIVATE virtual css::uno::Sequence< ::sal_Int8 > SAL_CALL getImplementationId( ) override; + + // XLayoutConstrains + SVX_DLLPRIVATE virtual css::awt::Size SAL_CALL getMinimumSize() override; + SVX_DLLPRIVATE virtual css::awt::Size SAL_CALL getPreferredSize() override; + SVX_DLLPRIVATE virtual css::awt::Size SAL_CALL calcAdjustedSize( const css::awt::Size& aNewSize ) override; + + // XMergeableCell + SVX_DLLPRIVATE virtual ::sal_Int32 SAL_CALL getRowSpan() override; + SVX_DLLPRIVATE virtual ::sal_Int32 SAL_CALL getColumnSpan() override; + SVX_DLLPRIVATE virtual sal_Bool SAL_CALL isMerged() override; + + // XCell + SVX_DLLPRIVATE virtual OUString SAL_CALL getFormula() override; + SVX_DLLPRIVATE virtual void SAL_CALL setFormula( const OUString& aFormula ) override; + SVX_DLLPRIVATE virtual double SAL_CALL getValue() override; + SVX_DLLPRIVATE virtual void SAL_CALL setValue( double nValue ) override; + SVX_DLLPRIVATE virtual css::table::CellContentType SAL_CALL getType() override; + SVX_DLLPRIVATE virtual sal_Int32 SAL_CALL getError() override; + + // css::beans::XPropertySet + SVX_DLLPRIVATE virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override; + SVX_DLLPRIVATE virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName, const css::uno::Any& aValue ) override; + SVX_DLLPRIVATE virtual css::uno::Any SAL_CALL getPropertyValue( const OUString& PropertyName ) override; + SVX_DLLPRIVATE virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener ) override; + SVX_DLLPRIVATE virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener >& aListener ) override; + SVX_DLLPRIVATE virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override; + SVX_DLLPRIVATE virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override; + + // XMultiPropertySet + SVX_DLLPRIVATE virtual void SAL_CALL setPropertyValues( const css::uno::Sequence< OUString >& aPropertyNames, const css::uno::Sequence< css::uno::Any >& aValues ) override; + SVX_DLLPRIVATE virtual css::uno::Sequence< css::uno::Any > SAL_CALL getPropertyValues( const css::uno::Sequence< OUString >& aPropertyNames ) override; + SVX_DLLPRIVATE virtual void SAL_CALL addPropertiesChangeListener( const css::uno::Sequence< OUString >& aPropertyNames, const css::uno::Reference< css::beans::XPropertiesChangeListener >& xListener ) override; + SVX_DLLPRIVATE virtual void SAL_CALL removePropertiesChangeListener( const css::uno::Reference< css::beans::XPropertiesChangeListener >& xListener ) override; + SVX_DLLPRIVATE virtual void SAL_CALL firePropertiesChangeEvent( const css::uno::Sequence< OUString >& aPropertyNames, const css::uno::Reference< css::beans::XPropertiesChangeListener >& xListener ) override; + + // css::beans::XPropertyState + SVX_DLLPRIVATE virtual css::beans::PropertyState SAL_CALL getPropertyState( const OUString& PropertyName ) override; + SVX_DLLPRIVATE virtual css::uno::Sequence< css::beans::PropertyState > SAL_CALL getPropertyStates( const css::uno::Sequence< OUString >& aPropertyName ) override; + SVX_DLLPRIVATE virtual void SAL_CALL setPropertyToDefault( const OUString& PropertyName ) override; + SVX_DLLPRIVATE virtual css::uno::Any SAL_CALL getPropertyDefault( const OUString& aPropertyName ) override; + + // XMultiPropertyStates + SVX_DLLPRIVATE virtual void SAL_CALL setAllPropertiesToDefault() override; + SVX_DLLPRIVATE virtual void SAL_CALL setPropertiesToDefault( const css::uno::Sequence< OUString >& aPropertyNames ) override; + SVX_DLLPRIVATE virtual css::uno::Sequence< css::uno::Any > SAL_CALL getPropertyDefaults( const css::uno::Sequence< OUString >& aPropertyNames ) override; + + // XText + SVX_DLLPRIVATE virtual void SAL_CALL insertTextContent( const css::uno::Reference< css::text::XTextRange >& xRange, const css::uno::Reference< css::text::XTextContent >& xContent, sal_Bool bAbsorb ) override; + SVX_DLLPRIVATE virtual void SAL_CALL removeTextContent( const css::uno::Reference< css::text::XTextContent >& xContent ) override; + + // XSimpleText + SVX_DLLPRIVATE virtual void SAL_CALL insertString( const css::uno::Reference< css::text::XTextRange >& xRange, const OUString& aString, sal_Bool bAbsorb ) override; + SVX_DLLPRIVATE virtual void SAL_CALL insertControlCharacter( const css::uno::Reference< css::text::XTextRange >& xRange, ::sal_Int16 nControlCharacter, sal_Bool bAbsorb ) override; + + // XTextRange + SVX_DLLPRIVATE virtual OUString SAL_CALL getString( ) override; + SVX_DLLPRIVATE virtual void SAL_CALL setString( const OUString& aString ) override; + + // XEventListener + SVX_DLLPRIVATE virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override; + + SVX_DLLPRIVATE virtual void SetOutlinerParaObject( std::unique_ptr<OutlinerParaObject> pTextObject ) override; + + SVX_DLLPRIVATE void AddUndo(); + + using SvxUnoTextRangeBase::setPropertyValue; + using SvxUnoTextRangeBase::getPropertyValue; + + SVX_DLLPRIVATE sdr::properties::TextProperties* CloneProperties( SdrObject& rNewObj, Cell& rNewCell ); + + SVX_DLLPRIVATE static sdr::properties::TextProperties* CloneProperties( sdr::properties::TextProperties const * pProperties, SdrObject& rNewObj, Cell& rNewCell ); + + SVX_DLLPRIVATE void notifyModified(); + + void dumpAsXml(xmlTextWriterPtr pWriter, sal_Int32 nRow, sal_Int32 nCol) const; + +protected: + SVX_DLLPRIVATE virtual const SfxItemSet& GetObjectItemSet() override; + SVX_DLLPRIVATE void SetObjectItem(const SfxPoolItem& rItem); + + SVX_DLLPRIVATE static css::uno::Any GetAnyForItem( SfxItemSet const & aSet, const SfxItemPropertySimpleEntry* pMap ); + +private: + /// @throws css::uno::RuntimeException + SVX_DLLPRIVATE Cell( SdrTableObj& rTableObj ); + SVX_DLLPRIVATE virtual ~Cell() throw() override; + + Cell(Cell const &) = delete; + void operator =(Cell const &) = delete; + + const SvxItemPropertySet* mpPropSet; + + std::unique_ptr<sdr::properties::TextProperties> mpProperties; + + css::table::CellContentType mnCellContentType; + + OUString msFormula; + double mfValue; + ::sal_Int32 mnError; + bool mbMerged; + ::sal_Int32 mnRowSpan; + ::sal_Int32 mnColSpan; + + tools::Rectangle maCellRect; + + css::uno::Reference< css::table::XTable > mxTable; +}; + + +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/inc/celltypes.hxx b/svx/source/inc/celltypes.hxx new file mode 100644 index 000000000..7f8a9d87f --- /dev/null +++ b/svx/source/inc/celltypes.hxx @@ -0,0 +1,97 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_SVX_SOURCE_INC_CELLTYPES_HXX +#define INCLUDED_SVX_SOURCE_INC_CELLTYPES_HXX + +#include <rtl/ref.hxx> +#include <vector> + +namespace sdr::table { + +class Cell; +class TableModel; +class TableRow; +class TableColumn; +class TableRows; +class TableColumns; +typedef rtl::Reference< Cell > CellRef; +typedef rtl::Reference< TableModel > TableModelRef; +typedef rtl::Reference< TableRow > TableRowRef; +typedef rtl::Reference< TableColumn > TableColumnRef; +typedef std::vector< CellRef > CellVector; +typedef std::vector< TableRowRef > RowVector; +typedef std::vector< TableColumnRef > ColumnVector; + +class TableDesignUser +{ +public: + virtual bool isInUse() = 0; + +protected: + ~TableDesignUser() {} +}; + +template< typename T > +class RangeIterator +{ +public: + /** creates an iterator from rStart (including) to rEnd (excluding) if + bForward is true or from nEnd (excluding to nStart (including). + rStart must be <= rEnd. + */ + RangeIterator( const T& rStart, const T& rEnd, bool bForward ) + { + if( bForward ) + { + maIter = rStart; + maEnd = rEnd; + } + else + { + maIter = rEnd-1; + maEnd = rStart-1; + } + } + + /* iterates in the configured direction and returns true if rValue + now contains a valid position in the range of this iterator */ + bool next( T& rValue ) + { + if( maIter == maEnd ) + return false; + + rValue = maIter; + if( maIter < maEnd ) + ++maIter; + else + --maIter; + return true; + } + +private: + T maEnd; + T maIter; +}; + +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/inc/charmapacc.hxx b/svx/source/inc/charmapacc.hxx new file mode 100644 index 000000000..71bcc63a4 --- /dev/null +++ b/svx/source/inc/charmapacc.hxx @@ -0,0 +1,223 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_SVX_SOURCE_INC_CHARMAPACC_HXX +#define INCLUDED_SVX_SOURCE_INC_CHARMAPACC_HXX + +#include <comphelper/accessibleselectionhelper.hxx> +#include <com/sun/star/accessibility/XAccessibleAction.hpp> +#include <com/sun/star/accessibility/XAccessibleTable.hpp> +#include <tools/gen.hxx> +#include <rtl/ref.hxx> + +#include <vector> +class SvxShowCharSet; + +namespace svx +{ + typedef ::cppu::ImplHelper1 < css::accessibility::XAccessible + > OAccessibleHelper_Base_2; + + class SvxShowCharSetAcc; + + class SvxShowCharSetItemAcc; + + // - SvxShowCharSetItem - + + /** Simple struct to hold some information about the single items of the table. + */ + struct SvxShowCharSetItem + { + SvxShowCharSet& mrParent; + sal_uInt16 mnId; + OUString maText; + tools::Rectangle maRect; + rtl::Reference<SvxShowCharSetItemAcc> m_xItem; + SvxShowCharSetAcc* m_pParent; + + SvxShowCharSetItem( SvxShowCharSet& rParent, SvxShowCharSetAcc* _pParent, sal_uInt16 _nPos ); + ~SvxShowCharSetItem(); + + css::uno::Reference< css::accessibility::XAccessible > GetAccessible(); + }; + + + typedef ::cppu::ImplHelper2 < css::accessibility::XAccessible, + css::accessibility::XAccessibleTable + > OAccessibleHelper_Base; + + // - SvxShowCharSetAcc - + + /** The table implementation of the vcl control. + */ + + class SvxShowCharSetAcc : public ::comphelper::OAccessibleSelectionHelper, + public OAccessibleHelper_Base + { + ::std::vector< css::uno::Reference< css::accessibility::XAccessible > > m_aChildren; + SvxShowCharSet* m_pParent; // the vcl control + protected: + virtual void SAL_CALL disposing() override; + public: + SvxShowCharSetAcc(SvxShowCharSet* pParent); + + DECLARE_XINTERFACE( ) + DECLARE_XTYPEPROVIDER( ) + + // XAccessibleComponent + virtual void SAL_CALL grabFocus( ) override; + virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleAtPoint( const css::awt::Point& aPoint ) override; + + //OAccessibleContextHelper + // XAccessibleContext - still waiting to be overwritten + virtual sal_Int32 SAL_CALL getAccessibleChildCount() override; + virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleChild( sal_Int32 i ) override; + virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleParent( ) override; + virtual sal_Int16 SAL_CALL getAccessibleRole( ) override; + virtual OUString SAL_CALL getAccessibleDescription( ) override; + virtual OUString SAL_CALL getAccessibleName( ) override; + virtual css::uno::Reference< css::accessibility::XAccessibleRelationSet > SAL_CALL getAccessibleRelationSet( ) override; + virtual css::uno::Reference< css::accessibility::XAccessibleStateSet > SAL_CALL getAccessibleStateSet( ) override; + + virtual css::uno::Reference< css::accessibility::XAccessibleContext > SAL_CALL getAccessibleContext( ) override { return this; } + virtual sal_Int32 SAL_CALL getForeground( ) override; + virtual sal_Int32 SAL_CALL getBackground( ) override; + + // XAccessibleTable + virtual sal_Int32 SAL_CALL getAccessibleRowCount( ) override; + virtual sal_Int32 SAL_CALL getAccessibleColumnCount( ) override; + virtual OUString SAL_CALL getAccessibleRowDescription( sal_Int32 nRow ) override; + virtual OUString SAL_CALL getAccessibleColumnDescription( sal_Int32 nColumn ) override; + virtual sal_Int32 SAL_CALL getAccessibleRowExtentAt( sal_Int32 nRow, sal_Int32 nColumn ) override; + virtual sal_Int32 SAL_CALL getAccessibleColumnExtentAt( sal_Int32 nRow, sal_Int32 nColumn ) override; + virtual css::uno::Reference< css::accessibility::XAccessibleTable > SAL_CALL getAccessibleRowHeaders( ) override; + virtual css::uno::Reference< css::accessibility::XAccessibleTable > SAL_CALL getAccessibleColumnHeaders( ) override; + virtual css::uno::Sequence< sal_Int32 > SAL_CALL getSelectedAccessibleRows( ) override; + virtual css::uno::Sequence< sal_Int32 > SAL_CALL getSelectedAccessibleColumns( ) override; + virtual sal_Bool SAL_CALL isAccessibleRowSelected( sal_Int32 nRow ) override; + virtual sal_Bool SAL_CALL isAccessibleColumnSelected( sal_Int32 nColumn ) override; + virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleCellAt( sal_Int32 nRow, sal_Int32 nColumn ) override; + virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleCaption( ) override; + virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleSummary( ) override; + virtual sal_Bool SAL_CALL isAccessibleSelected( sal_Int32 nRow, sal_Int32 nColumn ) override; + virtual sal_Int32 SAL_CALL getAccessibleIndex( sal_Int32 nRow, sal_Int32 nColumn ) override; + virtual sal_Int32 SAL_CALL getAccessibleRow( sal_Int32 nChildIndex ) override; + virtual sal_Int32 SAL_CALL getAccessibleColumn( sal_Int32 nChildIndex ) override; + + + void fireEvent( + const sal_Int16 _nEventId, + const css::uno::Any& _rOldValue, + const css::uno::Any& _rNewValue + ) + { + NotifyAccessibleEvent(_nEventId,_rOldValue,_rNewValue); + } + + void clearCharSetControl() { m_pParent = nullptr; } + protected: + + virtual ~SvxShowCharSetAcc() override; + + // OCommonAccessibleSelection + // return if the specified child is visible => watch for special ChildIndexes (ACCESSIBLE_SELECTION_CHILD_xxx) + virtual bool + implIsSelected( sal_Int32 nAccessibleChildIndex ) override; + + // select the specified child => watch for special ChildIndexes (ACCESSIBLE_SELECTION_CHILD_xxx) + virtual void + implSelect( sal_Int32 nAccessibleChildIndex, bool bSelect ) override; + + // OCommonAccessibleComponent + /// implements the calculation of the bounding rectangle - still waiting to be overwritten + virtual css::awt::Rectangle implGetBounds( ) override; + }; + + + // - SvxShowCharSetItemAcc - + + typedef ::cppu::ImplHelper2 < css::accessibility::XAccessible, + css::accessibility::XAccessibleAction + > OAccessibleHelper_Base_3; + + /** The child implementation of the table. + */ + class SvxShowCharSetItemAcc : public ::comphelper::OAccessibleComponentHelper, + public OAccessibleHelper_Base_3 + { + private: + SvxShowCharSetItem* mpParent; + protected: + virtual ~SvxShowCharSetItemAcc() override; + + // OCommonAccessibleComponent + /// implements the calculation of the bounding rectangle - still waiting to be overwritten + virtual css::awt::Rectangle implGetBounds( ) override; + public: + + // XInterface + DECLARE_XINTERFACE( ) + DECLARE_XTYPEPROVIDER( ) + + SvxShowCharSetItemAcc( SvxShowCharSetItem* pParent ); + + void ParentDestroyed(); + + // XAccessibleComponent + virtual void SAL_CALL grabFocus( ) override; + virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleAtPoint( const css::awt::Point& aPoint ) override; + + //OAccessibleContextHelper + // XAccessibleContext - still waiting to be overwritten + virtual sal_Int32 SAL_CALL getAccessibleChildCount( ) override; + virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleChild( sal_Int32 i ) override; + virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleParent( ) override; + virtual sal_Int16 SAL_CALL getAccessibleRole( ) override; + virtual OUString SAL_CALL getAccessibleDescription( ) override; + virtual OUString SAL_CALL getAccessibleName( ) override; + virtual css::uno::Reference< css::accessibility::XAccessibleRelationSet > SAL_CALL getAccessibleRelationSet( ) override; + virtual css::uno::Reference< css::accessibility::XAccessibleStateSet > SAL_CALL getAccessibleStateSet( ) override; + + virtual css::uno::Reference< css::accessibility::XAccessibleContext > SAL_CALL getAccessibleContext( ) override { return this; } + + virtual sal_Int32 SAL_CALL getForeground( ) override { return mpParent->m_pParent->getForeground(); } + virtual sal_Int32 SAL_CALL getBackground( ) override { return mpParent->m_pParent->getBackground(); } + + // XAccessibleAction + virtual sal_Int32 SAL_CALL getAccessibleActionCount( ) override; + virtual sal_Bool SAL_CALL doAccessibleAction ( sal_Int32 nIndex ) override; + virtual OUString SAL_CALL getAccessibleActionDescription ( sal_Int32 nIndex ) override; + virtual css::uno::Reference< css::accessibility::XAccessibleKeyBinding > SAL_CALL getAccessibleActionKeyBinding( sal_Int32 nIndex ) override; + + + void fireEvent( + const sal_Int16 _nEventId, + const css::uno::Any& _rOldValue, + const css::uno::Any& _rNewValue + ) + { + NotifyAccessibleEvent(_nEventId,_rOldValue,_rNewValue); + } + }; +} + + +#endif // INCLUDED_SVX_SOURCE_INC_CHARMAPACC_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/inc/clonelist.hxx b/svx/source/inc/clonelist.hxx new file mode 100644 index 000000000..5ed3e4d8c --- /dev/null +++ b/svx/source/inc/clonelist.hxx @@ -0,0 +1,47 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_SVX_SOURCE_INC_CLONELIST_HXX +#define INCLUDED_SVX_SOURCE_INC_CLONELIST_HXX + +#include <vector> + +#include <sal/types.h> + +class SdrObject; + +// #i13033# +// New mechanism to hold a list of all original and cloned objects for later +// re-creating the connections for contained connectors +class CloneList +{ + std::vector<const SdrObject*> maOriginalList; + std::vector<SdrObject*> maCloneList; + +public: + void AddPair(const SdrObject* pOriginal, SdrObject* pClone); + + const SdrObject* GetOriginal(sal_uInt32 nIndex) const; + SdrObject* GetClone(sal_uInt32 nIndex) const; + + void CopyConnections() const; +}; + +#endif // INCLUDED_SVX_SOURCE_INC_CLONELIST_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/inc/datalistener.hxx b/svx/source/inc/datalistener.hxx new file mode 100644 index 000000000..2749c4e52 --- /dev/null +++ b/svx/source/inc/datalistener.hxx @@ -0,0 +1,73 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_SVX_SOURCE_INC_DATALISTENER_HXX +#define INCLUDED_SVX_SOURCE_INC_DATALISTENER_HXX + +#include <cppuhelper/implbase.hxx> +#include <com/sun/star/container/XContainerListener.hpp> +#include <com/sun/star/frame/XFrameActionListener.hpp> +#include <com/sun/star/xml/dom/events/XEventListener.hpp> +#include <vcl/vclptr.hxx> + + +namespace svxform +{ + + + class DataNavigatorWindow; + + typedef cppu::WeakImplHelper< + css::container::XContainerListener, + css::frame::XFrameActionListener, + css::xml::dom::events::XEventListener > DataListener_t; + + class DataListener : public DataListener_t + { + private: + VclPtr<DataNavigatorWindow> m_pNaviWin; + + public: + DataListener( DataNavigatorWindow* pNaviWin ); + + protected: + virtual ~DataListener() override; + + public: + // XContainerListener + virtual void SAL_CALL elementInserted( const css::container::ContainerEvent& Event ) override; + virtual void SAL_CALL elementRemoved( const css::container::ContainerEvent& Event ) override; + virtual void SAL_CALL elementReplaced( const css::container::ContainerEvent& Event ) override; + + // XFrameActionListener + virtual void SAL_CALL frameAction( const css::frame::FrameActionEvent& Action ) override; + + // xml::dom::events::XEventListener + virtual void SAL_CALL handleEvent( const css::uno::Reference< css::xml::dom::events::XEvent >& evt ) override; + + // lang::XEventListener + virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override; + }; + + +} + + +#endif // INCLUDED_SVX_SOURCE_INC_DATALISTENER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/inc/datanavi.hxx b/svx/source/inc/datanavi.hxx new file mode 100644 index 000000000..45158ce9f --- /dev/null +++ b/svx/source/inc/datanavi.hxx @@ -0,0 +1,616 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_SVX_SOURCE_INC_DATANAVI_HXX +#define INCLUDED_SVX_SOURCE_INC_DATANAVI_HXX + +#include <config_options.h> +#include <vcl/builder.hxx> +#include <vcl/lstbox.hxx> +#include <vcl/menubtn.hxx> +#include <vcl/tabctrl.hxx> +#include <vcl/tabpage.hxx> +#include <vcl/toolbox.hxx> +#include <vcl/idle.hxx> +#include <vcl/weld.hxx> +#include <svtools/inettbc.hxx> +#include <vcl/treelistbox.hxx> +#include <sfx2/dockwin.hxx> +#include <sfx2/childwin.hxx> +#include <sfx2/ctrlitem.hxx> +#include <svx/dialmgr.hxx> +#include <svx/strings.hrc> +#include <svx/svxdllapi.h> +#include <rtl/ref.hxx> +#include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/container/XContainer.hpp> +#include <com/sun/star/container/XNameContainer.hpp> +#include <com/sun/star/frame/XFrame.hpp> +#include <com/sun/star/xforms/XFormsUIHelper1.hpp> +#include <com/sun/star/xforms/XModel.hpp> +#include <com/sun/star/xforms/XSubmission.hpp> +#include <com/sun/star/xml/dom/XNode.hpp> +#include <com/sun/star/xml/dom/events/XEventTarget.hpp> + +#include "datalistener.hxx" + +#include <memory> +#include <vector> + +class FmFormShell; + + +namespace svxform +{ + + + enum DataGroupType + { + DGTUnknown = 0, + DGTInstance, + DGTSubmission, + DGTBinding + }; + + enum DataItemType + { + DITNone = 0, + DITText, + DITAttribute, + DITElement, + DITBinding + }; + + struct ItemNode; + class XFormsPage; + class DataNavigatorWindow; + class AddInstanceDialog; + + class DataTreeListBox : public SvTreeListBox + { + private: + std::unique_ptr<VclBuilder> m_xBuilder; + VclPtr<PopupMenu> m_xMenu; + VclPtr<XFormsPage> m_pXFormsPage; + DataGroupType m_eGroup; + sal_uInt16 m_nAddId; + sal_uInt16 m_nAddElementId; + sal_uInt16 m_nAddAttributeId; + sal_uInt16 m_nEditId; + sal_uInt16 m_nRemoveId; + + protected: + using SvTreeListBox::ExecuteDrop; + + public: + DataTreeListBox( vcl::Window* pParent, WinBits nBits ); + virtual ~DataTreeListBox() override; + virtual void dispose() override; + + virtual VclPtr<PopupMenu> CreateContextMenu() override; + virtual void ExecuteContextMenuAction( sal_uInt16 _nSelectedPopupEntry ) override; + virtual sal_Int8 AcceptDrop( const AcceptDropEvent& rEvt ) override; + virtual sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt ) override; + virtual void StartDrag( sal_Int8 nAction, const Point& rPosPixel ) override; + + void SetGroup(DataGroupType _eGroup); + void SetXFormsPage(XFormsPage* _pPage); + void SetToolBoxItemIds(sal_uInt16 _nAddId, + sal_uInt16 _nAddElementId, + sal_uInt16 _nAddAttributeId, + sal_uInt16 _nEditId, + sal_uInt16 _nRemoveId); + void DeleteAndClear(); + void RemoveEntry( SvTreeListEntry const * _pEntry ); + }; + + class ReplaceString + { + OUString m_sDoc_UI; + OUString m_sInstance_UI; + OUString m_sNone_UI; + + static constexpr OUStringLiteral const m_sDoc_API = "all"; + static constexpr OUStringLiteral const m_sInstance_API = "instance"; + static constexpr OUStringLiteral const m_sNone_API = "none"; + + ReplaceString( const ReplaceString& ) = delete; + + public: + ReplaceString() + { + m_sDoc_UI = SvxResId(RID_STR_REPLACE_DOC); + m_sInstance_UI = SvxResId(RID_STR_REPLACE_INST); + m_sNone_UI = SvxResId(RID_STR_REPLACE_NONE); + } + + /** convert submission replace string from API value to UI value. + Use 'none' as default. */ + OUString const & toUI( const OUString& rStr ) const + { + if( rStr == m_sDoc_API ) + return m_sDoc_UI; + else if( rStr == m_sInstance_API ) + return m_sInstance_UI; + else + return m_sNone_UI; + } + + /** convert submission replace string from UI to API. + Use 'none' as default. */ + OUString toAPI( const OUString& rStr ) const + { + if( rStr == m_sDoc_UI ) + return m_sDoc_API; + else if( rStr == m_sInstance_UI ) + return m_sInstance_API; + else + return m_sNone_API; + } + }; + + class MethodString + { + OUString m_sPost_UI; + OUString m_sPut_UI; + OUString m_sGet_UI; + + static constexpr OUStringLiteral m_sPost_API = "post"; + static constexpr OUStringLiteral m_sPut_API = "put"; + static constexpr OUStringLiteral m_sGet_API = "get"; + + MethodString( const MethodString& ) = delete; + + public: + + MethodString() + { + m_sPost_UI = SvxResId(RID_STR_METHOD_POST); + m_sPut_UI = SvxResId(RID_STR_METHOD_PUT); + m_sGet_UI = SvxResId(RID_STR_METHOD_GET); + } + + /** convert from API to UI; put is default. */ + OUString const & toUI( const OUString& rStr ) const + { + if( rStr == m_sGet_API ) + return m_sGet_UI; + else if( rStr == m_sPost_API ) + return m_sPost_UI; + else + return m_sPut_UI; + } + + /** convert from UI to API; put is default */ + OUString toAPI( const OUString& rStr ) const + { + if( rStr == m_sGet_UI ) + return m_sGet_API; + else if( rStr == m_sPost_UI ) + return m_sPost_API; + else + return m_sPut_API; + } + }; + + class XFormsPage : public TabPage + { + private: + MethodString m_aMethodString; + ReplaceString m_aReplaceString; + + VclPtr<ToolBox> m_pToolBox; + VclPtr<DataTreeListBox> m_pItemList; + sal_uInt16 m_nAddId; + sal_uInt16 m_nAddElementId; + sal_uInt16 m_nAddAttributeId; + sal_uInt16 m_nEditId; + sal_uInt16 m_nRemoveId; + + css::uno::Reference< css::xforms::XFormsUIHelper1 > + m_xUIHelper; + + VclPtr<DataNavigatorWindow> m_pNaviWin; + bool m_bHasModel; + DataGroupType m_eGroup; + // these strings are not valid on the Submission and Binding Page + // mb: furthermore these are properties of an instance, thus + // it would be much better to get/set them through the UIHelper + // interface. + OUString m_sInstanceName; + OUString m_sInstanceURL; + bool m_bLinkOnce; + + DECL_LINK(TbxSelectHdl, ToolBox *, void); + DECL_LINK(ItemSelectHdl, SvTreeListBox*, void); + + void AddChildren(SvTreeListEntry* _pParent, + const css::uno::Reference< css::xml::dom::XNode >& _xNode); + bool DoToolBoxAction( sal_uInt16 _nToolBoxID ); + SvTreeListEntry* AddEntry( std::unique_ptr<ItemNode> _pNewNode, bool _bIsElement ); + SvTreeListEntry* AddEntry( const css::uno::Reference< css::beans::XPropertySet >& _rPropSet ); + void EditEntry( const css::uno::Reference< css::beans::XPropertySet >& _rPropSet ); + bool RemoveEntry(); + + protected: + virtual bool EventNotify( NotifyEvent& rNEvt ) override; + + public: + XFormsPage( vcl::Window* pParent, DataNavigatorWindow* _pNaviWin, DataGroupType _eGroup ); + virtual ~XFormsPage() override; + virtual void dispose() override; + + virtual void Resize() override; + + bool HasModel() const { return m_bHasModel; } + OUString SetModel( const css::uno::Reference< css::xforms::XModel > & _xModel, sal_uInt16 _nPagePos ); + void ClearModel(); + OUString LoadInstance(const css::uno::Sequence< css::beans::PropertyValue >& _xPropSeq); + + bool DoMenuAction( sal_uInt16 _nMenuID ); + void EnableMenuItems( Menu* _pMenu ); + + const OUString& GetInstanceName() const { return m_sInstanceName; } + const OUString& GetInstanceURL() const { return m_sInstanceURL; } + bool GetLinkOnce() const { return m_bLinkOnce; } + void SetInstanceName( const OUString &name ) { m_sInstanceName=name; } + void SetInstanceURL( const OUString &url ) { m_sInstanceURL=url; } + void SetLinkOnce( bool bLinkOnce ) { m_bLinkOnce=bLinkOnce; } + + css::uno::Reference<css::beans::XPropertySet> + GetBindingForNode( const css::uno::Reference<css::xml::dom::XNode> &xNode ) { return m_xUIHelper->getBindingForNode(xNode,true); } + OUString GetServiceNameForNode( const css::uno::Reference<css::xml::dom::XNode> &xNode ) { return m_xUIHelper->getDefaultServiceNameForNode(xNode); } + const css::uno::Reference< css::xforms::XFormsUIHelper1 >& + GetXFormsHelper() const { return m_xUIHelper; } + }; + + class DataNavigatorWindow : public vcl::Window, public VclBuilderContainer + { + private: + VclPtr<ListBox> m_pModelsBox; + VclPtr<MenuButton> m_pModelBtn; + VclPtr<TabControl> m_pTabCtrl; + VclPtr<MenuButton> m_pInstanceBtn; + + VclPtr<XFormsPage> m_pInstPage; + VclPtr<XFormsPage> m_pSubmissionPage; + VclPtr<XFormsPage> m_pBindingPage; + + sal_Int32 m_nLastSelectedPos; + bool m_bShowDetails; + bool m_bIsNotifyDisabled; + std::vector< VclPtr<XFormsPage> > + m_aPageList; + std::vector< css::uno::Reference< css::container::XContainer > > + m_aContainerList; + std::vector< css::uno::Reference< css::xml::dom::events::XEventTarget > > + m_aEventTargetList; + Timer m_aUpdateTimer; + + ::rtl::Reference < DataListener > + m_xDataListener; + css::uno::Reference< css::container::XNameContainer > + m_xDataContainer; + css::uno::Reference< css::frame::XFrame > + m_xFrame; + css::uno::Reference< css::frame::XModel > + m_xFrameModel; + + DECL_LINK( ModelSelectListBoxHdl, ListBox&, void ); + DECL_LINK( MenuSelectHdl, MenuButton *, void ); + DECL_LINK( MenuActivateHdl, MenuButton *, void ); + DECL_LINK( ActivatePageHdl, TabControl*, void); + DECL_LINK( UpdateHdl, Timer *, void); + void ModelSelectHdl(ListBox const *); + XFormsPage* GetCurrentPage( sal_uInt16& rCurId ); + void LoadModels(); + void SetPageModel(); + void ClearAllPageModels( bool bClearPages ); + void InitPages(); + void CreateInstancePage( const css::uno::Sequence< css::beans::PropertyValue >& _xPropSeq ); + bool HasFirstInstancePage() const; + sal_uInt16 GetNewPageId() const; + + bool IsAdditionalPage(sal_uInt16 nPageId) const; + + protected: + virtual void Resize() override; + virtual Size GetOptimalSize() const override; + + public: + DataNavigatorWindow( vcl::Window* pParent, SfxBindings const * pBindings ); + virtual ~DataNavigatorWindow() override; + virtual void dispose() override; + + static void SetDocModified(); + void NotifyChanges( bool _bLoadAll = false ); + void AddContainerBroadcaster( const css::uno::Reference< css::container::XContainer > & xContainer ); + void AddEventBroadcaster( const css::uno::Reference< css::xml::dom::events::XEventTarget >& xTarget ); + void RemoveBroadcaster(); + + bool IsShowDetails() const { return m_bShowDetails; } + void DisableNotify( bool _bDisable ) { m_bIsNotifyDisabled = _bDisable; } + }; + + class DataNavigator : public SfxDockingWindow, public SfxControllerItem + { + private: + VclPtr<DataNavigatorWindow> m_aDataWin; + + protected: + virtual void Resize() override; + virtual Size CalcDockingSize( SfxChildAlignment ) override; + virtual SfxChildAlignment CheckAlignment( SfxChildAlignment, SfxChildAlignment ) override; + + public: + DataNavigator( SfxBindings* pBindings, SfxChildWindow* pMgr, vcl::Window* pParent ); + virtual ~DataNavigator() override; + virtual void dispose() override; + + using SfxDockingWindow::StateChanged; + + void StateChanged( sal_uInt16 nSID, SfxItemState eState, + const SfxPoolItem* pState ) override; + }; + + class UNLESS_MERGELIBS(SVXCORE_DLLPUBLIC) DataNavigatorManager : public SfxChildWindow + { + public: + SVX_DLLPRIVATE DataNavigatorManager( vcl::Window* pParent, sal_uInt16 nId, + SfxBindings* pBindings, SfxChildWinInfo* pInfo ); + SFX_DECL_CHILDWINDOW( DataNavigatorManager ); + }; + + class AddDataItemDialog : public weld::GenericDialogController + { + private: + css::uno::Reference< css::xforms::XFormsUIHelper1 > + m_xUIHelper; + css::uno::Reference< css::beans::XPropertySet > + m_xBinding; + css::uno::Reference< css::beans::XPropertySet > + m_xTempBinding; + + ItemNode* m_pItemNode; + DataItemType m_eItemType; + OUString m_sFL_Element; + OUString m_sFL_Attribute; + OUString m_sFL_Binding; + OUString m_sFT_BindingExp; + + std::unique_ptr<weld::Frame> m_xItemFrame; + std::unique_ptr<weld::Label> m_xNameFT; + std::unique_ptr<weld::Entry> m_xNameED; + std::unique_ptr<weld::Label> m_xDefaultFT; + std::unique_ptr<weld::Entry> m_xDefaultED; + std::unique_ptr<weld::Button> m_xDefaultBtn; + std::unique_ptr<weld::Widget> m_xSettingsFrame; + std::unique_ptr<weld::Label> m_xDataTypeFT; + std::unique_ptr<weld::ComboBox> m_xDataTypeLB; + std::unique_ptr<weld::CheckButton> m_xRequiredCB; + std::unique_ptr<weld::Button> m_xRequiredBtn; + std::unique_ptr<weld::CheckButton> m_xRelevantCB; + std::unique_ptr<weld::Button> m_xRelevantBtn; + std::unique_ptr<weld::CheckButton> m_xConstraintCB; + std::unique_ptr<weld::Button> m_xConstraintBtn; + std::unique_ptr<weld::CheckButton> m_xReadonlyCB; + std::unique_ptr<weld::Button> m_xReadonlyBtn; + std::unique_ptr<weld::CheckButton> m_xCalculateCB; + std::unique_ptr<weld::Button> m_xCalculateBtn; + std::unique_ptr<weld::Button> m_xOKBtn; + + void Check(const weld::ToggleButton* pBox); + DECL_LINK(CheckHdl, weld::ToggleButton&, void); + DECL_LINK(ConditionHdl, weld::Button&, void); + DECL_LINK(OKHdl, weld::Button&, void); + + void InitDialog(); + void InitFromNode(); + void InitDataTypeBox(); + + public: + AddDataItemDialog( + weld::Window* pParent, ItemNode* _pNode, + const css::uno::Reference< css::xforms::XFormsUIHelper1 >& _rUIHelper ); + virtual ~AddDataItemDialog() override; + + void InitText( DataItemType _eType ); + }; + + class AddConditionDialog : public weld::GenericDialogController + { + private: + Idle m_aResultIdle; + OUString m_sPropertyName; + + css::uno::Reference< css::xforms::XFormsUIHelper1 > + m_xUIHelper; + css::uno::Reference< css::beans::XPropertySet > + m_xBinding; + + std::unique_ptr<weld::TextView> m_xConditionED; + std::unique_ptr<weld::TextView> m_xResultWin; + std::unique_ptr<weld::Button> m_xEditNamespacesBtn; + std::unique_ptr<weld::Button> m_xOKBtn; + + DECL_LINK(ModifyHdl, weld::TextView&, void); + DECL_LINK(ResultHdl, Timer *, void); + DECL_LINK(EditHdl, weld::Button&, void); + DECL_LINK(OKHdl, weld::Button&, void); + + public: + AddConditionDialog(weld::Window* pParent, + const OUString& _rPropertyName, const css::uno::Reference< css::beans::XPropertySet >& _rBinding); + virtual ~AddConditionDialog() override; + + const css::uno::Reference< css::xforms::XFormsUIHelper1 >& GetUIHelper() const { return m_xUIHelper; } + OUString GetCondition() const { return m_xConditionED->get_text(); } + void SetCondition(const OUString& _rCondition) + { + m_xConditionED->set_text(_rCondition); + m_aResultIdle.Start(); + } + }; + + class NamespaceItemDialog : public weld::GenericDialogController + { + private: + AddConditionDialog* m_pConditionDlg; + std::vector< OUString > m_aRemovedList; + + css::uno::Reference< css::container::XNameContainer >& + m_rNamespaces; + + std::unique_ptr<weld::TreeView> m_xNamespacesList; + std::unique_ptr<weld::Button> m_xAddNamespaceBtn; + std::unique_ptr<weld::Button> m_xEditNamespaceBtn; + std::unique_ptr<weld::Button> m_xDeleteNamespaceBtn; + std::unique_ptr<weld::Button> m_xOKBtn; + + DECL_LINK(SelectHdl, weld::TreeView&, void); + DECL_LINK(ClickHdl, weld::Button&, void); + DECL_LINK(OKHdl, weld::Button&, void); + + void LoadNamespaces(); + + public: + NamespaceItemDialog(AddConditionDialog* pParent, css::uno::Reference< css::container::XNameContainer >& _rContainer); + virtual ~NamespaceItemDialog() override; + }; + + class ManageNamespaceDialog : public weld::GenericDialogController + { + private: + AddConditionDialog* m_pConditionDlg; + + std::unique_ptr<weld::Entry> m_xPrefixED; + std::unique_ptr<weld::Entry> m_xUrlED; + std::unique_ptr<weld::Button> m_xOKBtn; + std::unique_ptr<weld::Label> m_xAltTitle; + + DECL_LINK(OKHdl, weld::Button&, void); + + public: + ManageNamespaceDialog(weld::Window* pParent, AddConditionDialog* _pCondDlg, bool bIsEdit); + virtual ~ManageNamespaceDialog() override; + + void SetNamespace(const OUString& _rPrefix, const OUString& _rURL) + { + m_xPrefixED->set_text(_rPrefix); + m_xUrlED->set_text(_rURL); + } + OUString GetPrefix() const { return m_xPrefixED->get_text(); } + OUString GetURL() const { return m_xUrlED->get_text(); } + }; + + class AddSubmissionDialog : public weld::GenericDialogController + { + private: + MethodString m_aMethodString; + ReplaceString m_aReplaceString; + + ItemNode* m_pItemNode; + + css::uno::Reference< css::xforms::XFormsUIHelper1 > + m_xUIHelper; + css::uno::Reference< css::xforms::XSubmission > + m_xNewSubmission; + css::uno::Reference< css::beans::XPropertySet > + m_xSubmission; + css::uno::Reference< css::beans::XPropertySet > + m_xTempBinding; + css::uno::Reference< css::beans::XPropertySet > + m_xCreatedBinding; + + std::unique_ptr<weld::Entry> m_xNameED; + std::unique_ptr<weld::Entry> m_xActionED; + std::unique_ptr<weld::ComboBox> m_xMethodLB; + std::unique_ptr<weld::Entry> m_xRefED; + std::unique_ptr<weld::Button> m_xRefBtn; + std::unique_ptr<weld::ComboBox> m_xBindLB; + std::unique_ptr<weld::ComboBox> m_xReplaceLB; + std::unique_ptr<weld::Button> m_xOKBtn; + + DECL_LINK(RefHdl, weld::Button&, void); + DECL_LINK(OKHdl, weld::Button&, void); + + void FillAllBoxes(); + + public: + AddSubmissionDialog(weld::Window* pParent, ItemNode* pNode, + const css::uno::Reference< css::xforms::XFormsUIHelper1 >& rUIHelper); + virtual ~AddSubmissionDialog() override; + + const css::uno::Reference< css::xforms::XSubmission >& GetNewSubmission() const { return m_xNewSubmission; } + }; + + class AddModelDialog : public weld::GenericDialogController + { + private: + std::unique_ptr<weld::Entry> m_xNameED; + std::unique_ptr<weld::CheckButton> m_xModifyCB; + std::unique_ptr<weld::Label> m_xAltTitle; + + public: + AddModelDialog(weld::Window* pParent, bool _bEdit); + virtual ~AddModelDialog() override; + + OUString GetName() const { return m_xNameED->get_text(); } + void SetName( const OUString& _rName ) { m_xNameED->set_text( _rName );} + + bool GetModifyDoc() const { return m_xModifyCB->get_active(); } + void SetModifyDoc( const bool bModify ) { m_xModifyCB->set_active(bModify); } + }; + + class AddInstanceDialog : public weld::GenericDialogController + { + private: + OUString m_sAllFilterName; + + std::unique_ptr<weld::Entry> m_xNameED; + std::unique_ptr<weld::Label> m_xURLFT; + std::unique_ptr<SvtURLBox> m_xURLED; + std::unique_ptr<weld::Button> m_xFilePickerBtn; + std::unique_ptr<weld::CheckButton> m_xLinkInstanceCB; + std::unique_ptr<weld::Label> m_xAltTitle; + + DECL_LINK(FilePickerHdl, weld::Button&, void); + + public: + AddInstanceDialog(weld::Window* pParent, bool _bEdit); + virtual ~AddInstanceDialog() override; + + OUString GetName() const { return m_xNameED->get_text(); } + void SetName( const OUString& rName ) { m_xNameED->set_text( rName );} + OUString GetURL() const { return m_xURLED->get_active_text(); } + void SetURL( const OUString& rURL ) { m_xURLED->set_entry_text( rURL );} + bool IsLinkInstance() const { return m_xLinkInstanceCB->get_active(); } + void SetLinkInstance( bool bLink ) { m_xLinkInstanceCB->set_active(bLink); } + }; + + class LinkedInstanceWarningBox : public weld::MessageDialogController + { + public: + LinkedInstanceWarningBox(weld::Widget* pParent); + }; +} + + +#endif // INCLUDED_SVX_SOURCE_INC_DATANAVI_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/inc/delayedevent.hxx b/svx/source/inc/delayedevent.hxx new file mode 100644 index 000000000..4f7925c94 --- /dev/null +++ b/svx/source/inc/delayedevent.hxx @@ -0,0 +1,81 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_SVX_SOURCE_INC_DELAYEDEVENT_HXX +#define INCLUDED_SVX_SOURCE_INC_DELAYEDEVENT_HXX + +#include <tools/link.hxx> + +struct ImplSVEvent; + +namespace svxform +{ + + + //= DelayedEvent + + /** small class which encapsulates posting a Link instance as ApplicationUserEvent + + No thread safety at all here, just a little saving of code to type multiple times + */ + class DelayedEvent + { + public: + DelayedEvent( const Link<void*,void>& _rHandler ) + :m_aHandler( _rHandler ) + ,m_nEventId( nullptr ) + { + } + + ~DelayedEvent() + { + CancelPendingCall(); + } + + /** calls the handler asynchronously + + If there's already a call pending, this previous call is cancelled. + */ + void Call(); + + /** cancels a call which is currently pending + + If no call is currently pending, then this is ignored. + */ + void CancelPendingCall(); + + private: + Link<void*,void> m_aHandler; + ImplSVEvent * m_nEventId; + + private: + DECL_LINK( OnCall, void*, void ); + + private: + DelayedEvent( const DelayedEvent& ) = delete; + DelayedEvent& operator=( const DelayedEvent& ) = delete; + }; + + +} + + +#endif // INCLUDED_SVX_SOURCE_INC_DELAYEDEVENT_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/inc/docrecovery.hxx b/svx/source/inc/docrecovery.hxx new file mode 100644 index 000000000..4a954f57b --- /dev/null +++ b/svx/source/inc/docrecovery.hxx @@ -0,0 +1,503 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_SVX_SOURCE_INC_DOCRECOVERY_HXX +#define INCLUDED_SVX_SOURCE_INC_DOCRECOVERY_HXX + +#include <vcl/weld.hxx> +#include <o3tl/typed_flags_set.hxx> + +#include <cppuhelper/implbase.hxx> +#include <com/sun/star/task/XStatusIndicator.hpp> +#include <com/sun/star/frame/XStatusListener.hpp> +#include <com/sun/star/frame/XDispatch.hpp> +#include <com/sun/star/lang/XComponent.hpp> +#include <com/sun/star/uno/XComponentContext.hpp> + + +#define RECOVERY_CMDPART_PROTOCOL "vnd.sun.star.autorecovery:" + +#define RECOVERY_CMDPART_DO_EMERGENCY_SAVE "/doEmergencySave" +#define RECOVERY_CMDPART_DO_RECOVERY "/doAutoRecovery" +#define RECOVERY_CMDPART_DO_BRINGTOFRONT "/doBringToFront" + +#define RECOVERY_CMD_DO_PREPARE_EMERGENCY_SAVE "vnd.sun.star.autorecovery:/doPrepareEmergencySave" +#define RECOVERY_CMD_DO_EMERGENCY_SAVE "vnd.sun.star.autorecovery:/doEmergencySave" +#define RECOVERY_CMD_DO_RECOVERY "vnd.sun.star.autorecovery:/doAutoRecovery" +#define RECOVERY_CMD_DO_ENTRY_BACKUP "vnd.sun.star.autorecovery:/doEntryBackup" +#define RECOVERY_CMD_DO_ENTRY_CLEANUP "vnd.sun.star.autorecovery:/doEntryCleanUp" + +#define PROP_STATUSINDICATOR "StatusIndicator" +#define PROP_DISPATCHASYNCHRON "DispatchAsynchron" +#define PROP_SAVEPATH "SavePath" +#define PROP_ENTRYID "EntryID" + +#define STATEPROP_ID "ID" +#define STATEPROP_STATE "DocumentState" +#define STATEPROP_ORGURL "OriginalURL" +#define STATEPROP_TEMPURL "TempURL" +#define STATEPROP_FACTORYURL "FactoryURL" +#define STATEPROP_TEMPLATEURL "TemplateURL" +#define STATEPROP_TITLE "Title" +#define STATEPROP_MODULE "Module" + +#define RECOVERY_OPERATIONSTATE_START "start" +#define RECOVERY_OPERATIONSTATE_STOP "stop" +#define RECOVERY_OPERATIONSTATE_UPDATE "update" + +#define DLG_RET_UNKNOWN -1 +#define DLG_RET_OK RET_OK +#define DLG_RET_CANCEL RET_CANCEL +#define DLG_RET_OK_AUTOLUNCH 101 + + +enum class EDocStates +{ + /* TEMP STATES */ + + /// default state, if a document was new created or loaded + Unknown = 0x000, + /** an action was started (saving/loading) ... Can be interesting later if the process may be was interrupted by an exception. */ + TryLoadBackup = 0x010, + TryLoadOriginal = 0x020, + + /* FINAL STATES */ + + /// the Auto/Emergency saved document isn't usable any longer + Damaged = 0x040, + /// the Auto/Emergency saved document is not really up-to-date (some changes can be missing) + Incomplete = 0x080, + /// the Auto/Emergency saved document was processed successfully + Succeeded = 0x200 +}; +namespace o3tl { + template<> struct typed_flags<EDocStates> : is_typed_flags<EDocStates, 0x2f0> {}; +} + + +namespace svx{ + namespace DocRecovery{ + + +enum ERecoveryState +{ + E_SUCCESSFULLY_RECOVERED, + E_ORIGINAL_DOCUMENT_RECOVERED, + E_RECOVERY_FAILED, + E_RECOVERY_IS_IN_PROGRESS, + E_NOT_RECOVERED_YET +}; + + +struct TURLInfo +{ + public: + + /// unique ID, which is specified by the underlying autorecovery core! + sal_Int32 ID; + + /// the full qualified document URL + OUString OrgURL; + + /// the full qualified URL of the temp. file (if it's exists) + OUString TempURL; + + /// a may be existing factory URL (e.g. for untitled documents) + OUString FactoryURL; + + /// may be the document base on a template file !? + OUString TemplateURL; + + /// the pure file name, without path, disc etcpp. + OUString DisplayName; + + /// the application module, where this document was loaded + OUString Module; + + /// state info as e.g. VALID, CORRUPTED, NON EXISTING ... + EDocStates DocState; + + /// ui representation for DocState! + ERecoveryState RecoveryState; + + /// standard icon + OUString StandardImageId; + + public: + + TURLInfo() + : ID (-1 ) + , DocState (EDocStates::Unknown) + , RecoveryState(E_NOT_RECOVERED_YET) + {} +}; + + +typedef ::std::vector< TURLInfo > TURLList; + + +class IRecoveryUpdateListener +{ + public: + + // inform listener about changed items, which should be refreshed + virtual void updateItems() = 0; + + // inform listener about ending of the asynchronous recovery operation + virtual void end() = 0; + + // TODO + virtual void stepNext(TURLInfo* pItem) = 0; + + protected: + ~IRecoveryUpdateListener() {} +}; + + +class RecoveryCore : public ::cppu::WeakImplHelper< css::frame::XStatusListener > +{ + + // types, const + public: + + + // member + private: + + /// TODO + css::uno::Reference< css::uno::XComponentContext > m_xContext; + + /// TODO + css::uno::Reference< css::frame::XDispatch > m_xRealCore; + + /// TODO + css::uno::Reference< css::task::XStatusIndicator > m_xProgress; + + /// TODO + TURLList m_lURLs; + + /// TODO + IRecoveryUpdateListener* m_pListener; + + /** @short knows the reason, why we listen on our internal m_xRealCore + member. + + @descr Because we listen for different operations + on the core dispatch implementation, we must know, + which URL we have to use for deregistration! + */ + bool m_bListenForSaving; + + + // native interface + public: + + + /** @short TODO */ + RecoveryCore(const css::uno::Reference< css::uno::XComponentContext >& rxContext, + bool bUsedForSaving); + + + /** @short TODO */ + virtual ~RecoveryCore() override; + + + /** @short TODO */ + const css::uno::Reference< css::uno::XComponentContext >& getComponentContext() const; + + + /** @short TODO */ + TURLList& getURLListAccess(); + + + /** @short TODO */ + static bool isBrokenTempEntry(const TURLInfo& rInfo); + void saveBrokenTempEntries(const OUString& sSaveDir); + void saveAllTempEntries(const OUString& sSaveDir); + void forgetBrokenTempEntries(); + void forgetAllRecoveryEntries(); + void forgetBrokenRecoveryEntries(); + + + /** @short TODO */ + void setProgressHandler(const css::uno::Reference< css::task::XStatusIndicator >& xProgress); + + + /** @short TODO */ + void setUpdateListener(IRecoveryUpdateListener* pListener); + + + /** @short TODO */ + void doEmergencySavePrepare(); + void doEmergencySave(); + void doRecovery(); + + + /** @short TODO */ + static ERecoveryState mapDocState2RecoverState(EDocStates eDocState); + + + // uno interface + public: + + // css.frame.XStatusListener + virtual void SAL_CALL statusChanged(const css::frame::FeatureStateEvent& aEvent) override; + + // css.lang.XEventListener + virtual void SAL_CALL disposing(const css::lang::EventObject& aEvent) override; + + + // helper + private: + + + /** @short starts listening on the internal EmergencySave/AutoRecovery core. + */ + void impl_startListening(); + + + /** @short stop listening on the internal EmergencySave/AutoRecovery core. + */ + void impl_stopListening(); + + + /** @short TODO */ + css::util::URL impl_getParsedURL(const OUString& sURL); +}; + +class PluginProgress : public ::cppu::WeakImplHelper<css::task::XStatusIndicator, css::lang::XComponent> +{ +// member +private: + weld::ProgressBar* m_pProgressBar; + int m_nRange; + +// native interface +public: + PluginProgress(weld::ProgressBar* pProgressBar); + virtual ~PluginProgress() override; + +// uno interface +public: + // XStatusIndicator + virtual void SAL_CALL start(const OUString& sText, sal_Int32 nRange) override; + virtual void SAL_CALL end() override; + virtual void SAL_CALL setText(const OUString& sText) override; + virtual void SAL_CALL setValue(sal_Int32 nValue) override; + virtual void SAL_CALL reset() override; + + // XComponent + virtual void SAL_CALL dispose() override; + virtual void SAL_CALL addEventListener(const css::uno::Reference< css::lang::XEventListener >& xListener) override; + virtual void SAL_CALL removeEventListener( const css::uno::Reference< css::lang::XEventListener >& xListener) override; +}; + +class SaveDialog : public weld::GenericDialogController +{ +// member +private: + RecoveryCore* m_pCore; + std::unique_ptr<weld::TreeView> m_xFileListLB; + std::unique_ptr<weld::Button> m_xOkBtn; + +// interface +public: + /** @short create all child controls of this dialog. + + @descr The dialog isn't shown nor it starts any + action by itself! + + @param pParent + can point to a parent window. + If it's set to 0, the defmodal-dialog-parent + is used automatically. + + @param pCore + provides access to the recovery core service + and the current list of open documents, + which should be shown inside this dialog. + */ + SaveDialog(weld::Window* pParent, RecoveryCore* pCore); + virtual ~SaveDialog() override; + + DECL_LINK(OKButtonHdl, weld::Button&, void); +}; + +class SaveProgressDialog : public weld::GenericDialogController + , public IRecoveryUpdateListener +{ + // member + private: + // @short TODO + RecoveryCore* m_pCore; + + std::unique_ptr<weld::ProgressBar> m_xProgressBar; + + // @short TODO + css::uno::Reference< css::task::XStatusIndicator > m_xProgress; + // interface + public: + /** @short create all child controls of this dialog. + + @descr The dialog isn't shown nor it starts any + action by itself! + + @param pParent + can point to a parent window. + If it's set to 0, the defmodal-dialog-parent + is used automatically. + + @param pCore + used to start emergency save. + */ + SaveProgressDialog(weld::Window* pParent, + RecoveryCore* pCore); + virtual ~SaveProgressDialog() override; + + /** @short start the emergency save operation. */ + virtual short run() override; + + // IRecoveryUpdateListener + virtual void updateItems() override; + virtual void stepNext(TURLInfo* pItem) override; + virtual void end() override; +}; + +class RecoveryDialog : public weld::GenericDialogController + , public IRecoveryUpdateListener +{ + // member + private: + OUString m_aTitleRecoveryInProgress; + OUString m_aRecoveryOnlyFinish; + OUString m_aRecoveryOnlyFinishDescr; + + RecoveryCore* m_pCore; + css::uno::Reference< css::task::XStatusIndicator > m_xProgress; + enum EInternalRecoveryState + { + E_RECOVERY_PREPARED, // dialog started... recovery prepared + E_RECOVERY_IN_PROGRESS, // recovery core still in progress + E_RECOVERY_CORE_DONE, // recovery core finished it's task + E_RECOVERY_DONE, // user clicked "next" button + E_RECOVERY_CANCELED, // user clicked "cancel" button + E_RECOVERY_CANCELED_BEFORE, // user clicked "cancel" button before recovery was started + E_RECOVERY_CANCELED_AFTERWARDS, // user clicked "cancel" button after recovery was finished + E_RECOVERY_HANDLED // the recovery wizard page was shown already... and will be shown now again... + }; + sal_Int32 m_eRecoveryState; + bool m_bWaitForCore; + bool m_bWasRecoveryStarted; + + OUString m_aSuccessRecovStr; + OUString m_aOrigDocRecovStr; + OUString m_aRecovFailedStr; + OUString m_aRecovInProgrStr; + OUString m_aNotRecovYetStr; + + std::unique_ptr<weld::Label> m_xDescrFT; + std::unique_ptr<weld::ProgressBar> m_xProgressBar; + std::unique_ptr<weld::TreeView> m_xFileListLB; + std::unique_ptr<weld::Button> m_xNextBtn; + std::unique_ptr<weld::Button> m_xCancelBtn; + + // member + public: + /** @short TODO */ + RecoveryDialog(weld::Window* pParent, + RecoveryCore* pCore); + + virtual ~RecoveryDialog() override; + + // IRecoveryUpdateListener + virtual void updateItems() override; + virtual void stepNext(TURLInfo* pItem) override; + virtual void end() override; + + short execute(); + + // helper + private: + DECL_LINK(NextButtonHdl, weld::Button&, void); + DECL_LINK(CancelButtonHdl, weld::Button&, void); + + OUString impl_getStatusString( const TURLInfo& rInfo ) const; + static OUString impl_getStatusImage( const TURLInfo& rInfo ); +}; + + +class BrokenRecoveryDialog : public weld::GenericDialogController +{ +// member +private: + OUString m_sSavePath; + RecoveryCore* m_pCore; + bool const m_bBeforeRecovery; + bool m_bExecutionNeeded; + + std::unique_ptr<weld::TreeView> m_xFileListLB; + std::unique_ptr<weld::Entry> m_xSaveDirED; + std::unique_ptr<weld::Button> m_xSaveDirBtn; + std::unique_ptr<weld::Button> m_xOkBtn; + std::unique_ptr<weld::Button> m_xCancelBtn; + +// interface +public: + + /** @short TODO */ + BrokenRecoveryDialog(weld::Window* pParent, + RecoveryCore* pCore, + bool bBeforeRecovery); + virtual ~BrokenRecoveryDialog() override; + + /** @short TODO */ + bool isExecutionNeeded() const; + + + /** @short TODO */ + const OUString& getSaveDirURL() const; + + +// helper +private: + /** @short TODO */ + void impl_refresh(); + + + /** @short TODO */ + DECL_LINK(SaveButtonHdl, weld::Button&, void); + + + /** @short TODO */ + DECL_LINK(OkButtonHdl, weld::Button&, void); + + + /** @short TODO */ + DECL_LINK(CancelButtonHdl, weld::Button&, void); + + + /** @short TODO */ + void impl_askForSavePath(); +}; + } +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/inc/filtnav.hxx b/svx/source/inc/filtnav.hxx new file mode 100644 index 000000000..f0cda9a44 --- /dev/null +++ b/svx/source/inc/filtnav.hxx @@ -0,0 +1,339 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_SVX_SOURCE_INC_FILTNAV_HXX +#define INCLUDED_SVX_SOURCE_INC_FILTNAV_HXX + +#include <com/sun/star/form/XForm.hpp> +#include <com/sun/star/form/runtime/XFormController.hpp> +#include <com/sun/star/form/runtime/XFilterController.hpp> +#include <svl/lstner.hxx> +#include <svl/SfxBroadcaster.hxx> + +#include <vcl/window.hxx> +#include <sfx2/childwin.hxx> +#include <svl/poolitem.hxx> +#include <sfx2/bindings.hxx> +#include <sfx2/dockwin.hxx> +#include <sfx2/ctrlitem.hxx> +#include <vcl/image.hxx> +#include <vcl/treelistbox.hxx> + +#include "fmexch.hxx" +#include "sqlparserclient.hxx" + +class FmFormShell; + + +namespace svxform +{ + + +class FmFilterItem; +class FmFilterItems; +class FmParentData; +class FmFilterAdapter; + + +// data structure for the filter model + +class FmFilterData +{ + FmParentData* m_pParent; + OUString m_aText; + +public: + FmFilterData(FmParentData* pParent, const OUString& rText) + :m_pParent( pParent ) + ,m_aText( rText ) + {} + virtual ~FmFilterData(){} + + void SetText( const OUString& rText ){ m_aText = rText; } + const OUString& GetText() const { return m_aText; } + FmParentData* GetParent() const {return m_pParent;} + + virtual Image GetImage() const; +}; + + +class FmParentData : public FmFilterData +{ +protected: + ::std::vector< std::unique_ptr<FmFilterData> > m_aChildren; + +public: + FmParentData(FmParentData* pParent, const OUString& rText) + : FmFilterData(pParent, rText) + {} + virtual ~FmParentData() override; + + ::std::vector< std::unique_ptr<FmFilterData> >& GetChildren() { return m_aChildren; } +}; + + +// Item representing the forms and subforms +class FmFormItem : public FmParentData +{ + css::uno::Reference< css::form::runtime::XFormController > m_xController; + css::uno::Reference< css::form::runtime::XFilterController > m_xFilterController; + +public: + + FmFormItem( FmParentData* _pParent, + const css::uno::Reference< css::form::runtime::XFormController > & _xController, + const OUString& _rText) + :FmParentData( _pParent, _rText ) + ,m_xController( _xController ) + ,m_xFilterController( _xController, css::uno::UNO_QUERY_THROW ) + { + } + + const css::uno::Reference< css::form::runtime::XFormController >& + GetController() const { return m_xController; } + + const css::uno::Reference< css::form::runtime::XFilterController >& + GetFilterController() const { return m_xFilterController; } + + virtual Image GetImage() const override; +}; + + +class FmFilterItems : public FmParentData +{ +public: + FmFilterItems(FmFormItem* pParent, const OUString& rText ) : FmParentData(pParent, rText) {} + + FmFilterItem* Find( const ::sal_Int32 _nFilterComponentIndex ) const; + virtual Image GetImage() const override; +}; + + +class FmFilterItem : public FmFilterData +{ + OUString m_aFieldName; + sal_Int32 m_nComponentIndex; + +public: + FmFilterItem( + FmFilterItems* pParent, + const OUString& aFieldName, + const OUString& aCondition, + const sal_Int32 _nComponentIndex + ); + + const OUString& GetFieldName() const {return m_aFieldName;} + sal_Int32 GetComponentIndex() const { return m_nComponentIndex; } + + virtual Image GetImage() const override; +}; + + +class FmFilterModel final : public FmParentData + ,public SfxBroadcaster + ,public ::svxform::OSQLParserClient +{ + friend class FmFilterAdapter; + + css::uno::Reference< css::container::XIndexAccess > m_xControllers; + css::uno::Reference< css::form::runtime::XFormController > m_xController; + rtl::Reference<FmFilterAdapter> m_pAdapter; + FmFilterItems* m_pCurrentItems; + +public: + FmFilterModel(); + virtual ~FmFilterModel() override; + + void Update(const css::uno::Reference< css::container::XIndexAccess > & xControllers, const css::uno::Reference< css::form::runtime::XFormController > & xCurrent); + void Clear(); + bool ValidateText(FmFilterItem const * pItem, OUString& rText, OUString& rErrorMsg) const; + void Append(FmFilterItems* pItems, std::unique_ptr<FmFilterItem> pFilterItem); + void SetTextForItem(FmFilterItem* pItem, const OUString& rText); + + FmFormItem* GetCurrentForm() const {return m_pCurrentItems ? static_cast<FmFormItem*>(m_pCurrentItems->GetParent()) : nullptr;} + FmFilterItems* GetCurrentItems() const {return m_pCurrentItems;} + void SetCurrentItems(FmFilterItems* pCurrent); + + const css::uno::Reference< css::form::runtime::XFormController > & GetCurrentController() const {return m_xController;} + void SetCurrentController(const css::uno::Reference< css::form::runtime::XFormController > & xController); + + void Remove(FmFilterData* pFilterItem); + static void AppendFilterItems( FmFormItem& _rItem ); + void EnsureEmptyFilterRows( FmParentData& _rItem ); + +private: + void Insert(const ::std::vector<std::unique_ptr<FmFilterData>>::iterator& rPos, std::unique_ptr<FmFilterData> pFilterItem); + void Remove( const ::std::vector<std::unique_ptr<FmFilterData>>::iterator& rPos ); + FmFormItem* Find(const ::std::vector<std::unique_ptr<FmFilterData>>& rItems, const css::uno::Reference< css::form::runtime::XFormController > & xController) const; + FmFormItem* Find(const ::std::vector<std::unique_ptr<FmFilterData>>& rItems, const css::uno::Reference< css::form::XForm >& xForm) const; + void Update(const css::uno::Reference< css::container::XIndexAccess > & xControllers, FmParentData* pParent); +}; + + +class OFilterItemExchange : public OLocalExchange +{ + ::std::vector<FmFilterItem*> m_aDraggedEntries; + FmFormItem* m_pFormItem; // ensure that we drop on the same form + +public: + OFilterItemExchange(); + + static SotClipboardFormatId getFormatId( ); + inline static bool hasFormat( const DataFlavorExVector& _rFormats ); + + const ::std::vector<FmFilterItem*>& getDraggedEntries() const { return m_aDraggedEntries; } + void setDraggedEntries(const ::std::vector<FmFilterItem*>& _rList) { m_aDraggedEntries = _rList; } + FmFormItem* getFormItem() const { return m_pFormItem; } + + void setFormItem( FmFormItem* _pItem ) { m_pFormItem = _pItem; } + +protected: + virtual void AddSupportedFormats() override; +}; + +inline bool OFilterItemExchange::hasFormat( const DataFlavorExVector& _rFormats ) +{ + return OLocalExchange::hasFormat( _rFormats, getFormatId() ); +} + +class OFilterExchangeHelper : public OLocalExchangeHelper +{ +public: + OFilterExchangeHelper(vcl::Window* _pDragSource) : OLocalExchangeHelper(_pDragSource) { } + + OFilterItemExchange* operator->() const { return static_cast<OFilterItemExchange*>(m_xTransferable.get()); } + +protected: + virtual OLocalExchange* createExchange() const override; +}; + + +class FmFilterNavigator final : public SvTreeListBox, public SfxListener +{ + enum DROP_ACTION{ DA_SCROLLUP, DA_SCROLLDOWN, DA_EXPANDNODE }; + + std::unique_ptr<FmFilterModel> m_pModel; + SvTreeListEntry* m_pEditingCurrently; + OFilterExchangeHelper m_aControlExchange; + + + AutoTimer m_aDropActionTimer; + unsigned short m_aTimerCounter; + Point m_aTimerTriggered; // position, where DropTimer was started + DROP_ACTION m_aDropActionType; + +public: + FmFilterNavigator( vcl::Window* pParent ); + virtual ~FmFilterNavigator() override; + virtual void dispose() override; + + void UpdateContent( + const css::uno::Reference< css::container::XIndexAccess > & xControllers, + const css::uno::Reference< css::form::runtime::XFormController > & xCurrent + ); + +private: + + virtual void KeyInput( const KeyEvent& rKEvt ) override; + virtual void Command( const CommandEvent& rEvt ) override; + virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override; + virtual void InitEntry(SvTreeListEntry* pEntry, const OUString& rStr, const Image& rImg1, const Image& rImg2) override; + virtual bool Select( SvTreeListEntry* pEntry, bool bSelect=true ) override; + virtual bool EditingEntry( SvTreeListEntry* pEntry, Selection& rSelection ) override; + virtual bool EditedEntry( SvTreeListEntry* pEntry, const OUString& rNewText ) override; + + virtual sal_Int8 AcceptDrop( const AcceptDropEvent& rEvt ) override; + virtual sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt ) override; + virtual void StartDrag( sal_Int8 nAction, const Point& rPosPixel ) override; + + void DeleteSelection(); + SvTreeListEntry* FindEntry(const FmFilterData* pItem) const; + void Insert(FmFilterData* pItem, sal_uLong nPos); + void Remove(FmFilterData const * pItem); + + DECL_LINK(OnRemove, void*, void); + DECL_LINK(OnDropActionTimer, Timer*, void); + + /** returns the first form item and the selected FilterItems in the vector + @param _rItemList + Is filled inside. <OUT/> + @return + The first form item. + */ + FmFormItem* getSelectedFilterItems(::std::vector<FmFilterItem*>& _rItemList); + /** + * inserts the filter items into the tree model and creates new FilterItems if needed. + * @param _rFilterList + * The items which should be inserted. + * @param _pTargetItems + * The target where to insert the items. + * @param _bCopy + * If <TRUE/> the items will not be removed from the model, otherwise they will. + */ + void insertFilterItem(const ::std::vector<FmFilterItem*>& _rFilterList,FmFilterItems* _pTargetItems, bool _bCopy); + SvTreeListEntry* getPrevEntry(SvTreeListEntry* _pStartWith); + SvTreeListEntry* getNextEntry(SvTreeListEntry* _pStartWith); + + using SvTreeListBox::Select; + using SvTreeListBox::ExecuteDrop; + using SvTreeListBox::Insert; +}; + + +class FmFilterNavigatorWin : public SfxDockingWindow, public SfxControllerItem +{ +private: + VclPtr<FmFilterNavigator> m_pNavigator; + +protected: + virtual void Resize() override; + virtual bool Close() override; + virtual Size CalcDockingSize( SfxChildAlignment ) override; + virtual SfxChildAlignment CheckAlignment( SfxChildAlignment, SfxChildAlignment ) override; + +public: + FmFilterNavigatorWin( SfxBindings *pBindings, SfxChildWindow *pMgr, + vcl::Window* pParent ); + virtual ~FmFilterNavigatorWin() override; + virtual void dispose() override; + + void UpdateContent( FmFormShell const * pFormShell ); + void StateChanged( sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState ) override; + void FillInfo( SfxChildWinInfo& rInfo ) const override; + + using SfxDockingWindow::StateChanged; + + virtual void GetFocus() override; +}; + + +class FmFilterNavigatorWinMgr : public SfxChildWindow +{ +public: + FmFilterNavigatorWinMgr( vcl::Window *pParent, sal_uInt16 nId, SfxBindings *pBindings, + SfxChildWinInfo *pInfo ); + SFX_DECL_CHILDWINDOW( FmFilterNavigatorWinMgr ); +}; + + +} + + +#endif // INCLUDED_SVX_SOURCE_INC_FILTNAV_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/inc/findtextfield.hxx b/svx/source/inc/findtextfield.hxx new file mode 100644 index 000000000..3e5de483c --- /dev/null +++ b/svx/source/inc/findtextfield.hxx @@ -0,0 +1,70 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include <vcl/InterimItemWindow.hxx> + +namespace svt +{ +class AcceleratorExecute; +} + +class FindTextFieldControl final : public InterimItemWindow +{ +public: + FindTextFieldControl(vcl::Window* pParent, + css::uno::Reference<css::frame::XFrame> const& xFrame, + const css::uno::Reference<css::uno::XComponentContext>& xContext); + + virtual void dispose() override; + + virtual ~FindTextFieldControl() override; + + virtual void GetFocus() override; + + void Remember_Impl(const OUString& rStr); + void SetTextToSelected_Impl(); + + void connect_changed(const Link<weld::ComboBox&, void>& rLink); + + int get_count() const; + OUString get_text(int nIndex) const; + OUString get_active_text() const; + void append_text(const OUString& rText); + void set_entry_message_type(weld::EntryMessageType eType); + +private: + ImplSVEvent* m_nAsyncGetFocusId; + std::unique_ptr<weld::ComboBox> m_xWidget; + css::uno::Reference<css::frame::XFrame> m_xFrame; + css::uno::Reference<css::uno::XComponentContext> m_xContext; + std::unique_ptr<svt::AcceleratorExecute> m_pAcc; + Link<weld::ComboBox&, void> m_aChangeHdl; + + DECL_LINK(FocusInHdl, weld::Widget&, void); + DECL_LINK(KeyInputHdl, const KeyEvent&, bool); + DECL_LINK(ActivateHdl, weld::ComboBox&, bool); + DECL_LINK(OnAsyncGetFocus, void*, void); + + void FocusIn(); + void ActivateFind(bool bShift); +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/inc/fmPropBrw.hxx b/svx/source/inc/fmPropBrw.hxx new file mode 100644 index 000000000..4fb36fc59 --- /dev/null +++ b/svx/source/inc/fmPropBrw.hxx @@ -0,0 +1,104 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_SVX_SOURCE_INC_FMPROPBRW_HXX +#define INCLUDED_SVX_SOURCE_INC_FMPROPBRW_HXX + +#include <com/sun/star/frame/XFrame2.hpp> +#include <com/sun/star/inspection/XObjectInspectorModel.hpp> +#include <com/sun/star/uno/XComponentContext.hpp> + +#include <sfx2/basedlgs.hxx> +#include <sfx2/ctrlitem.hxx> +#include <sfx2/childwin.hxx> +#include <svx/fmtools.hxx> + + +class FmPropBrwMgr : public SfxChildWindow +{ +public: + FmPropBrwMgr(vcl::Window *pParent, sal_uInt16 nId, SfxBindings *pBindings, SfxChildWinInfo *pInfo); + SFX_DECL_CHILDWINDOW(FmPropBrwMgr); +}; + +class SfxBindings; +class FmFormShell; + +class FmPropBrw final : public SfxModelessDialogController, public SfxControllerItem +{ + bool m_bInitialStateChange; + weld::Window* m_pParent; + ImplSVEvent* m_nAsyncGetFocusId; + OUString m_sLastActivePage; + std::unique_ptr<weld::Container> m_xContainer; + css::uno::Reference< css::uno::XComponentContext > + m_xInspectorContext; + css::uno::Reference< css::uno::XComponentContext > + m_xORB; + css::uno::Reference< css::frame::XFrame2 > + m_xMeAsFrame; + css::uno::Reference< css::uno::XInterface > + m_xLastKnownDocument; + css::uno::Reference< css::inspection::XObjectInspectorModel > + m_xInspectorModel; + css::uno::Reference< css::frame::XController > + m_xBrowserController; + + virtual void StateChanged(sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState) override; + virtual void FillInfo( SfxChildWinInfo& rInfo ) const override; + virtual void Close() override; + + DECL_LINK( OnAsyncGetFocus, void*, void ); + + void implSetNewSelection( const InterfaceBag& _rSelection ); + void implDetachController(); + bool implIsReadOnlyModel() const; + OUString getCurrentPage() const; + +public: + FmPropBrw( + const css::uno::Reference< css::uno::XComponentContext >& _xORB, + SfxBindings* pBindings, + SfxChildWindow* pMgr, + weld::Window* pParent, + const SfxChildWinInfo* _pInfo + ); + virtual ~FmPropBrw() override; + +private: + + /** creates the PropertyBrowser (aka ObjectInspector) and plugs it into our frame + + This method ensures that a new component is created every time the XModel which + we're working for changed. This is necessary since this model is part of the + ComponentContext we use to create the ObjectInspector. + */ + void impl_ensurePropertyBrowser_nothrow( FmFormShell* _pFormShell ); + + /** creates a property browser + + After this method returns, m_xBrowserController is not <NULL/>. + + @precond + we don't have an ObjectInspector, yet, i.e. m_xBrowserController is <NULL/>. + */ + void impl_createPropertyBrowser_throw( FmFormShell* _pFormShell ); +}; +#endif // INCLUDED_SVX_SOURCE_INC_FMPROPBRW_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/inc/fmcontrolbordermanager.hxx b/svx/source/inc/fmcontrolbordermanager.hxx new file mode 100644 index 000000000..8c281112d --- /dev/null +++ b/svx/source/inc/fmcontrolbordermanager.hxx @@ -0,0 +1,230 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_SVX_SOURCE_INC_FMCONTROLBORDERMANAGER_HXX +#define INCLUDED_SVX_SOURCE_INC_FMCONTROLBORDERMANAGER_HXX + +#include <com/sun/star/awt/VisualEffect.hpp> +#include <com/sun/star/awt/FontUnderline.hpp> +#include <com/sun/star/awt/XControl.hpp> +#include <com/sun/star/awt/XVclWindowPeer.hpp> +#include <o3tl/typed_flags_set.hxx> +#include <tools/color.hxx> + +#include <set> + +namespace com::sun::star::form::validation { class XValidatableFormComponent; } + +enum class ControlStatus { + NONE = 0x00, + Focused = 0x01, + MouseHover = 0x02, + Invalid = 0x04 +}; +namespace o3tl { + template<> struct typed_flags<ControlStatus> : is_typed_flags<ControlStatus, 0x07> {}; +} + + +namespace svxform +{ + + + struct BorderDescriptor + { + sal_Int16 nBorderType; + Color nBorderColor; + + BorderDescriptor() + :nBorderType( css::awt::VisualEffect::FLAT ) + { + } + }; + + struct UnderlineDescriptor + { + sal_Int16 nUnderlineType; + Color nUnderlineColor; + + UnderlineDescriptor() + :nUnderlineType( css::awt::FontUnderline::NONE ) + { + } + + UnderlineDescriptor( sal_Int16 _nUnderlineType, Color _nUnderlineColor ) + :nUnderlineType( _nUnderlineType ) + ,nUnderlineColor( _nUnderlineColor ) + { + } + }; + + struct ControlData : public BorderDescriptor, UnderlineDescriptor + { + css::uno::Reference< css::awt::XControl > xControl; + OUString sOriginalHelpText; + + ControlData() : BorderDescriptor() { } + ControlData( const css::uno::Reference< css::awt::XControl >& _rxControl ) + :xControl( _rxControl ) + { + } + }; + + + //= ControlBorderManager + + /** manages the dynamic border color for form controls + + Used by the <type>FormController</type>, this class manages the dynamic changes in the + border color of form controls. For this a set of events have to be forwarded to the manager + instance, which then will switch the border color depending on the mouse and focus status + of the controls. + */ + class ControlBorderManager + { + private: + struct ControlDataCompare + { + bool operator()( const ControlData& _rLHS, const ControlData& _rRHS ) const + { + return _rLHS.xControl.get() < _rRHS.xControl.get(); + } + }; + + typedef ::std::set< ControlData, ControlDataCompare > ControlBag; + typedef ::std::set< css::uno::Reference< css::awt::XVclWindowPeer > > PeerBag; + + PeerBag m_aColorableControls; + PeerBag m_aNonColorableControls; + + ControlData m_aFocusControl; + ControlData m_aMouseHoverControl; + ControlBag m_aInvalidControls; + + + // attributes + Color m_nFocusColor; + Color m_nMouseHoveColor; + Color m_nInvalidColor; + bool m_bDynamicBorderColors; + + public: + ControlBorderManager(); + ~ControlBorderManager(); + + public: + void focusGained( const css::uno::Reference< css::uno::XInterface >& _rxControl ); + void focusLost( const css::uno::Reference< css::uno::XInterface >& _rxControl ); + void mouseEntered( const css::uno::Reference< css::uno::XInterface >& _rxControl ); + void mouseExited( const css::uno::Reference< css::uno::XInterface >& _rxControl ); + + void validityChanged( + const css::uno::Reference< css::awt::XControl >& _rxControl, + const css::uno::Reference< css::form::validation::XValidatableFormComponent >& _rxValidatable + ); + + /// enables dynamic border color for the controls + void enableDynamicBorderColor( ); + /// disables dynamic border color for the controls + void disableDynamicBorderColor( ); + + /** sets a color to be used for a given status + @param _nStatus + the status which the color should be applied for. Must not be ControlStatus::NONE + @param _nColor + the color to apply for the given status + */ + void setStatusColor( ControlStatus _nStatus, Color _nColor ); + + /** restores all colors of all controls where we possibly changed them + */ + void restoreAll(); + + private: + /** called when a control got one of the two possible statuses (focused, and hovered with the mouse) + @param _rxControl + the control which gained the status + @param _rControlData + the control's status data, as a reference to our respective member + */ + void controlStatusGained( + const css::uno::Reference< css::uno::XInterface >& _rxControl, + ControlData& _rControlData + ); + + /** called when a control lost one of the two possible statuses (focused, and hovered with the mouse) + @param _rxControl + the control which lost the status + @param _rControlData + the control's status data, as a reference to our respective member + */ + void controlStatusLost( const css::uno::Reference< css::uno::XInterface >& _rxControl, ControlData& _rControlData ); + + /** determines whether the border of a given peer can be colored + @param _rxPeer + the peer to examine. Must not be <NULL/> + */ + bool canColorBorder( const css::uno::Reference< css::awt::XVclWindowPeer >& _rxPeer ); + + /** determines the status of the given control + */ + ControlStatus getControlStatus( const css::uno::Reference< css::awt::XControl >& _rxControl ); + + /** retrieves the color associated with a given ControlStatus + @param _eStatus + the status of the control. Must not be <member>ControlStatus::none</member> + */ + Color getControlColorByStatus( ControlStatus _eStatus ); + + /** sets the border color for a given control, depending on its status + @param _rxControl + the control to set the border color for. Must not be <NULL/> + @param _rxPeer + the peer of the control, to be passed herein for optimization the caller usually needs it, anyway). + Must not be <NULL/> + @param _rFallback + the color/type to use when the control has the status ControlStatus::NONE + */ + void updateBorderStyle( + const css::uno::Reference< css::awt::XControl >& _rxControl, + const css::uno::Reference< css::awt::XVclWindowPeer >& _rxPeer, + const BorderDescriptor& _rFallback + ); + + /** determines the to-be-remembered original border color and type for a control + + The method also takes into account that the control may currently have an overwritten + border style + + @param _rxControl + the control to examine. Must not be <NULL/>, and have a non-<NULL/> peer + */ + void determineOriginalBorderStyle( + const css::uno::Reference< css::awt::XControl >& _rxControl, + BorderDescriptor& _rData + ) const; + }; + + +} + + +#endif // INCLUDED_SVX_SOURCE_INC_FMCONTROLBORDERMANAGER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/inc/fmcontrollayout.hxx b/svx/source/inc/fmcontrollayout.hxx new file mode 100644 index 000000000..8a8062cfe --- /dev/null +++ b/svx/source/inc/fmcontrollayout.hxx @@ -0,0 +1,67 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_SVX_SOURCE_INC_FMCONTROLLAYOUT_HXX +#define INCLUDED_SVX_SOURCE_INC_FMCONTROLLAYOUT_HXX + +#include <com/sun/star/beans/XPropertySet.hpp> + +#include "fmdocumentclassification.hxx" + + +namespace svxform +{ + + namespace ControlLayouter + { + /** initializes the layout of a newly created form control (model) + */ + void initializeControlLayout( + const css::uno::Reference< css::beans::XPropertySet >& _rxControlModel, + DocumentType _eDocType + ); + + /** determines whether for the given document type, dynamic control border coloring is enabled + */ + bool useDynamicBorderColor( DocumentType _eDocType ); + + /** determines whether for the given document type, form controls should use the document's reference device + for text rendering + */ + bool useDocumentReferenceDevice( DocumentType _eDocType ); + + /** gets the "default" style in a document which can be used if some default text format is needed + + It depends on the type document type which concrete kind of style is returned, but it is expected to support + the css.style.CharacterProperties service. + + @param _rxModel + a form component. + */ + css::uno::Reference< css::beans::XPropertySet > + getDefaultDocumentTextStyle( const css::uno::Reference< css::beans::XPropertySet >& _rxModel ); + } + + +} + + +#endif // INCLUDED_SVX_SOURCE_INC_FMCONTROLLAYOUT_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/inc/fmdocumentclassification.hxx b/svx/source/inc/fmdocumentclassification.hxx new file mode 100644 index 000000000..05a2a76e4 --- /dev/null +++ b/svx/source/inc/fmdocumentclassification.hxx @@ -0,0 +1,71 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_SVX_SOURCE_INC_FMDOCUMENTCLASSIFICATION_HXX +#define INCLUDED_SVX_SOURCE_INC_FMDOCUMENTCLASSIFICATION_HXX + +#include <com/sun/star/frame/XModel.hpp> + + +namespace svxform +{ + + enum DocumentType + { + eTextDocument, + eWebDocument, + eSpreadsheetDocument, + eDrawingDocument, + ePresentationDocument, + eEnhancedForm, + eDatabaseForm, + eDatabaseReport, + + eUnknownDocumentType + }; + + class DocumentClassification + { + public: + /** classifies a document model + */ + static DocumentType classifyDocument( + const css::uno::Reference< css::frame::XModel >& _rxDocumentModel + ); + + static DocumentType classifyHostDocument( + const css::uno::Reference< css::uno::XInterface >& _rxFormComponent + ); + + static DocumentType getDocumentTypeForModuleIdentifier( + const OUString& _rModuleIdentifier + ); + + static OUString getModuleIdentifierForDocumentType( + DocumentType _eType + ); + }; + + +} + + +#endif // INCLUDED_SVX_SOURCE_INC_FMDOCUMENTCLASSIFICATION_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/inc/fmexch.hxx b/svx/source/inc/fmexch.hxx new file mode 100644 index 000000000..4bffa6c18 --- /dev/null +++ b/svx/source/inc/fmexch.hxx @@ -0,0 +1,252 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_SVX_SOURCE_INC_FMEXCH_HXX +#define INCLUDED_SVX_SOURCE_INC_FMEXCH_HXX + +#include <config_options.h> +#include <sal/config.h> + +#include <set> + +#include <sot/exchange.hxx> +#include <vcl/transfer.hxx> +#include <com/sun/star/uno/Sequence.hxx> +#include <com/sun/star/form/XForms.hpp> +#include <rtl/ref.hxx> +#include <tools/link.hxx> +#include <vcl/window.hxx> +#include <svx/svxdllapi.h> + +class SvTreeListEntry; +class SvTreeListBox; + +namespace svxform +{ + + + typedef ::std::set< SvTreeListEntry* > ListBoxEntrySet; + + + //= OLocalExchange + + class UNLESS_MERGELIBS(SVXCORE_DLLPUBLIC) OLocalExchange : public TransferableHelper + { + private: + Link<OLocalExchange&,void> m_aClipboardListener; + bool m_bDragging : 1; + bool m_bClipboardOwner : 1; + + public: + class GrantAccess + { + friend class OLocalExchangeHelper; + }; + + public: + OLocalExchange( ); + + bool isDragging() const { return m_bDragging; } + bool isClipboardOwner() const { return m_bClipboardOwner; } + + void startDrag( vcl::Window* pWindow, sal_Int8 nDragSourceActions, const GrantAccess& ); + void copyToClipboard( vcl::Window* _pWindow, const GrantAccess& ); + + void setClipboardListener( const Link<OLocalExchange&,void>& _rListener ) { m_aClipboardListener = _rListener; } + + void clear(); + + static bool hasFormat( const DataFlavorExVector& _rFormats, SotClipboardFormatId _nFormatId ); + + protected: + // XClipboardOwner + virtual void SAL_CALL lostOwnership( const css::uno::Reference< css::datatransfer::clipboard::XClipboard >& _rxClipboard, const css::uno::Reference< css::datatransfer::XTransferable >& _rxTrans ) override; + + // TransferableHelper + virtual void DragFinished( sal_Int8 nDropAction ) override; + virtual bool GetData( const css::datatransfer::DataFlavor& rFlavor, const OUString& rDestDoc ) override; + + private: + // don't allow this base class method to be called from outside + using TransferableHelper::StartDrag; + }; + + + //= OLocalExchangeHelper + + /// a helper for navigator windows (SvTreeListBox'es) which allow DnD within themself + class UNLESS_MERGELIBS(SVXCORE_DLLPUBLIC) OLocalExchangeHelper + { + protected: + VclPtr<vcl::Window> m_pDragSource; + rtl::Reference<OLocalExchange> m_xTransferable; + + public: + OLocalExchangeHelper( vcl::Window* _pDragSource ); + virtual ~OLocalExchangeHelper(); + + void prepareDrag( ); + + void startDrag( sal_Int8 nDragSourceActions ); + void copyToClipboard( ) const; + + bool isDragSource() const { return m_xTransferable.is() && m_xTransferable->isDragging(); } + bool isClipboardOwner() const { return m_xTransferable.is() && m_xTransferable->isClipboardOwner(); } + bool isDataExchangeActive( ) const { return isDragSource() || isClipboardOwner(); } + void clear() { if ( isDataExchangeActive() ) m_xTransferable->clear(); } + + SVX_DLLPRIVATE void setClipboardListener( const Link<OLocalExchange&,void>& _rListener ) { if ( m_xTransferable.is() ) m_xTransferable->setClipboardListener( _rListener ); } + + protected: + SVX_DLLPRIVATE virtual OLocalExchange* createExchange() const = 0; + + protected: + SVX_DLLPRIVATE void implReset(); + }; + + class OControlTransferData + { + private: + DataFlavorExVector m_aCurrentFormats; + + protected: + ListBoxEntrySet m_aSelectedEntries; + css::uno::Sequence< css::uno::Sequence< sal_uInt32 > > + m_aControlPaths; + css::uno::Sequence< css::uno::Reference< css::uno::XInterface > > + m_aHiddenControlModels; + + css::uno::Reference< css::form::XForms > + m_xFormsRoot; // the root of the forms collection where the entries we represent reside + // this uniquely identifies the page and the document + + SvTreeListEntry* m_pFocusEntry; + + protected: + // updates m_aCurrentFormats with all formats we currently could supply + void updateFormats( ); + + public: + OControlTransferData( ); + + // ctor to construct the data from an arbitrary Transferable (usually clipboard data) + OControlTransferData( + const css::uno::Reference< css::datatransfer::XTransferable >& _rxTransferable + ); + + inline const DataFlavorExVector& GetDataFlavorExVector() const; + + void addSelectedEntry( SvTreeListEntry* _pEntry ); + void setFocusEntry( SvTreeListEntry* _pFocusEntry ); + + /** notifies the data transfer object that a certain entry has been removed from the owning tree + + In case the removed entry is part of the transfer object's selection, the entry is removed from + the selection. + + @param _pEntry + @return the number of entries remaining in the selection. + */ + size_t onEntryRemoved( SvTreeListEntry* _pEntry ); + + void setFormsRoot( + const css::uno::Reference< css::form::XForms >& _rxFormsRoot + ) { m_xFormsRoot = _rxFormsRoot; } + + void buildPathFormat(SvTreeListBox const * pTreeBox, SvTreeListEntry const * pRoot); + // assembles m_aControlPaths from m_aSelectedEntries + // (it is assumed that the entries are sorted in m_aSelectedEntries with respect to the neighbor relationship) + + + void buildListFromPath(SvTreeListBox const * pTreeBox, SvTreeListEntry* pRoot); + // The reverse way: throws everything out of m_aSelectedEntries and rebuilds it using m_aControlPaths + + void addHiddenControlsFormat(const css::uno::Sequence< css::uno::Reference< css::uno::XInterface > >& seqInterfaces); + // adds an SVX_FML_HIDDEN_CONTROLS format and remembers the passed interfaces for it + // (it is NOT checked whether actually only hidden controls are denominated + // by this - the caller must ensure that) + + const ListBoxEntrySet& selected() const { return m_aSelectedEntries; } + const css::uno::Sequence< css::uno::Reference< css::uno::XInterface > >& + hiddenControls() const { return m_aHiddenControlModels; } + + const css::uno::Reference< css::form::XForms >& + getFormsRoot() const { return m_xFormsRoot; } + }; + + + inline const DataFlavorExVector& OControlTransferData::GetDataFlavorExVector() const + { + const_cast< OControlTransferData* >( this )->updateFormats( ); + return m_aCurrentFormats; + } + + class OControlExchange : public OLocalExchange, public OControlTransferData + { + public: + OControlExchange( ); + + public: + static SotClipboardFormatId getFieldExchangeFormatId( ); + static SotClipboardFormatId getControlPathFormatId( ); + static SotClipboardFormatId getHiddenControlModelsFormatId( ); + + inline static bool hasFieldExchangeFormat( const DataFlavorExVector& _rFormats ); + inline static bool hasControlPathFormat( const DataFlavorExVector& _rFormats ); + inline static bool hasHiddenControlModelsFormat( const DataFlavorExVector& _rFormats ); + + protected: + virtual bool GetData( const css::datatransfer::DataFlavor& rFlavor, const OUString& rDestDoc ) override; + virtual void AddSupportedFormats() override; + }; + + class OControlExchangeHelper : public OLocalExchangeHelper + { + public: + OControlExchangeHelper(vcl::Window* _pDragSource) : OLocalExchangeHelper(_pDragSource) { } + + OControlExchange* operator->() const { return static_cast< OControlExchange* >( m_xTransferable.get() ); } + OControlExchange& operator*() const { return *static_cast< OControlExchange* >( m_xTransferable.get() ); } + + protected: + virtual OLocalExchange* createExchange() const override; + }; + + + inline bool OControlExchange::hasFieldExchangeFormat( const DataFlavorExVector& _rFormats ) + { + return hasFormat( _rFormats, getFieldExchangeFormatId() ); + } + + inline bool OControlExchange::hasControlPathFormat( const DataFlavorExVector& _rFormats ) + { + return hasFormat( _rFormats, getControlPathFormatId() ); + } + + inline bool OControlExchange::hasHiddenControlModelsFormat( const DataFlavorExVector& _rFormats ) + { + return hasFormat( _rFormats, getHiddenControlModelsFormatId() ); + } + + +} + + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/inc/fmexpl.hxx b/svx/source/inc/fmexpl.hxx new file mode 100644 index 000000000..4d18c2783 --- /dev/null +++ b/svx/source/inc/fmexpl.hxx @@ -0,0 +1,550 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_SVX_SOURCE_INC_FMEXPL_HXX +#define INCLUDED_SVX_SOURCE_INC_FMEXPL_HXX + +#include <config_options.h> +#include <svl/lstner.hxx> +#include <svl/SfxBroadcaster.hxx> +#include <vcl/window.hxx> +#include <sfx2/childwin.hxx> +#include <svl/poolitem.hxx> +#include <sfx2/bindings.hxx> +#include <sfx2/dockwin.hxx> +#include <sfx2/ctrlitem.hxx> +#include <vcl/image.hxx> + +#include <com/sun/star/form/XForm.hpp> +#include <com/sun/star/form/XFormComponent.hpp> +#include <com/sun/star/beans/PropertyChangeEvent.hpp> +#include <com/sun/star/container/XContainerListener.hpp> +#include <com/sun/star/beans/XPropertyChangeListener.hpp> +#include <com/sun/star/container/XIndexContainer.hpp> + +#include <vcl/treelistbox.hxx> + +#include <svx/fmview.hxx> + +#include "fmexch.hxx" +#include <vector> +#include <set> +#include <cppuhelper/implbase.hxx> + +class SdrObjListIter; +class FmFormShell; +class SdrObject; +class FmFormModel; +class FmFormView; +class SdrMarkList; + + +class FmEntryData; +class FmNavInsertedHint : public SfxHint +{ + FmEntryData* pEntryData; + sal_uInt32 nPos; + +public: + FmNavInsertedHint( FmEntryData* pInsertedEntryData, sal_uInt32 nRelPos ); + virtual ~FmNavInsertedHint() override; + + FmEntryData* GetEntryData() const { return pEntryData; } + sal_uInt32 GetRelPos() const { return nPos; } +}; + + +class FmNavModelReplacedHint : public SfxHint +{ + FmEntryData* pEntryData; // the data of the entry that has got a new model + +public: + FmNavModelReplacedHint( FmEntryData* pAffectedEntryData ); + virtual ~FmNavModelReplacedHint() override; + + FmEntryData* GetEntryData() const { return pEntryData; } +}; + + +class FmNavRemovedHint : public SfxHint +{ + FmEntryData* pEntryData; + +public: + FmNavRemovedHint( FmEntryData* pInsertedEntryData ); + virtual ~FmNavRemovedHint() override; + + FmEntryData* GetEntryData() const { return pEntryData; } +}; + + +class FmNavNameChangedHint : public SfxHint +{ + FmEntryData* pEntryData; + OUString aNewName; + +public: + FmNavNameChangedHint( FmEntryData* pData, const OUString& rNewName ); + virtual ~FmNavNameChangedHint() override; + + FmEntryData* GetEntryData() const { return pEntryData; } + const OUString& GetNewName() const { return aNewName; } +}; + + +class FmNavClearedHint : public SfxHint +{ +public: + FmNavClearedHint(); + virtual ~FmNavClearedHint() override; +}; + + +class FmNavViewMarksChanged : public SfxHint +{ + FmFormView* pView; +public: + FmNavViewMarksChanged(FmFormView* pWhichView) { pView = pWhichView; } + + const FmFormView* GetAffectedView() const { return pView; } +}; + + +class FmEntryDataList; +class FmEntryData +{ +private: + css::uno::Reference< css::uno::XInterface > m_xNormalizedIFace; + css::uno::Reference< css::beans::XPropertySet > m_xProperties; + css::uno::Reference< css::container::XChild > m_xChild; + +protected: + Image m_aNormalImage; + OUString aText; + + std::unique_ptr<FmEntryDataList> + pChildList; + FmEntryData* pParent; + +protected: + void newObject( const css::uno::Reference< css::uno::XInterface >& _rxIFace ); + +public: + + FmEntryData( FmEntryData* pParentData, const css::uno::Reference< css::uno::XInterface >& _rIFace ); + FmEntryData( const FmEntryData& rEntryData ); + virtual ~FmEntryData(); + + void SetText( const OUString& rText ){ aText = rText; } + void SetParent( FmEntryData* pParentData ){ pParent = pParentData; } + + const Image& GetNormalImage() const { return m_aNormalImage; } + + const OUString& GetText() const { return aText; } + FmEntryData* GetParent() const { return pParent; } + FmEntryDataList* GetChildList() const { return pChildList.get(); } + + virtual bool IsEqualWithoutChildren( FmEntryData* pEntryData ); + virtual std::unique_ptr<FmEntryData> Clone() = 0; + + // note that the interface returned is normalized, i.e. querying the given XInterface of the object + // for XInterface must return the interface itself. + const css::uno::Reference< css::uno::XInterface >& GetElement() const + { + return m_xNormalizedIFace; + } + + const css::uno::Reference< css::beans::XPropertySet >& GetPropertySet() const + { + return m_xProperties; + } + + const css::uno::Reference< css::container::XChild >& GetChildIFace() const + { + return m_xChild; + } +}; + + +class FmEntryDataList final +{ +private: + std::vector< std::unique_ptr<FmEntryData> > maEntryDataList; + +public: + FmEntryDataList(); + ~FmEntryDataList(); + + FmEntryData* at( size_t Index ) + { return maEntryDataList.at(Index).get(); } + + size_t size() const { return maEntryDataList.size(); } + void removeNoDelete( FmEntryData* pItem ); + void insert( std::unique_ptr<FmEntryData> pItem, size_t Index ); + void clear(); +}; + + +// FmNavRequestSelectHint - someone tells the NavigatorTree to select certain entries + +typedef std::set<FmEntryData*> FmEntryDataArray; + +class FmNavRequestSelectHint : public SfxHint +{ + FmEntryDataArray m_arredToSelect; + bool m_bMixedSelection; +public: + FmNavRequestSelectHint() + : m_bMixedSelection(false) + { + } + + void SetMixedSelection(bool bMixedSelection) { m_bMixedSelection = bMixedSelection; } + bool IsMixedSelection() const { return m_bMixedSelection; } + void AddItem(FmEntryData* pEntry) { m_arredToSelect.insert(pEntry); } + void ClearItems() { m_arredToSelect.clear(); } + FmEntryDataArray& GetItems() { return m_arredToSelect; } +}; + + +class FmFormData : public FmEntryData +{ + css::uno::Reference< css::form::XForm > m_xForm; + +public: + FmFormData(const css::uno::Reference< css::form::XForm >& _rxForm, FmFormData* _pParent); + FmFormData( const FmFormData& rFormData ); + virtual ~FmFormData() override; + + const css::uno::Reference< css::form::XForm >& GetFormIface() const { return m_xForm; } + + virtual bool IsEqualWithoutChildren( FmEntryData* pEntryData ) override; + virtual std::unique_ptr<FmEntryData> Clone() override; +}; + + +class FmControlData : public FmEntryData +{ + css::uno::Reference< css::form::XFormComponent > m_xFormComponent; + + Image GetImage() const; + +public: + + FmControlData( + const css::uno::Reference< css::form::XFormComponent >& _rxComponent, + FmFormData* _pParent + ); + FmControlData( const FmControlData& rControlData ); + virtual ~FmControlData() override; + + const css::uno::Reference< css::form::XFormComponent >& GetFormComponent() const { return m_xFormComponent; } + virtual bool IsEqualWithoutChildren( FmEntryData* pEntryData ) override; + virtual std::unique_ptr<FmEntryData> Clone() override; + + void ModelReplaced(const css::uno::Reference< css::form::XFormComponent >& _rxNew); +}; + + +namespace svxform +{ + + + class NavigatorTreeModel; + + class OFormComponentObserver final + :public ::cppu::WeakImplHelper < css::beans::XPropertyChangeListener + , css::container::XContainerListener + > + { + ::svxform::NavigatorTreeModel* m_pNavModel; + sal_uInt32 m_nLocks; + bool m_bCanUndo; + + public: + OFormComponentObserver( ::svxform::NavigatorTreeModel* pModel ); + + // XEventListenerListener + virtual void SAL_CALL disposing(const css::lang::EventObject& Source) override; + + // css::beans::XPropertyChangeListener + virtual void SAL_CALL propertyChange(const css::beans::PropertyChangeEvent& evt) override; + + // css::container::XContainerListener + + virtual void SAL_CALL elementInserted(const css::container::ContainerEvent& rEvent) override; + virtual void SAL_CALL elementReplaced(const css::container::ContainerEvent& rEvent) override; + virtual void SAL_CALL elementRemoved(const css::container::ContainerEvent& rEvent) override; + + void Lock() { m_nLocks++; } + void UnLock() { m_nLocks--; } + bool IsLocked() const { return m_nLocks != 0; } + bool CanUndo() const { return m_bCanUndo; } + void ReleaseModel() { m_pNavModel = nullptr; } + private: + void Insert(const css::uno::Reference< css::uno::XInterface >& xIface, sal_Int32 nIndex); + void Remove( const css::uno::Reference< css::uno::XInterface >& _rxElement ); + }; + + class NavigatorTreeModel : public SfxBroadcaster + ,public SfxListener + { + friend class NavigatorTree; + friend class OFormComponentObserver; + + std::unique_ptr<FmEntryDataList> + m_pRootList; + FmFormShell* m_pFormShell; + FmFormPage* m_pFormPage; + FmFormModel* m_pFormModel; + rtl::Reference<OFormComponentObserver> m_pPropChangeList; + + void UpdateContent( const css::uno::Reference< css::form::XForms >& xForms ); + + void InsertForm(const css::uno::Reference< css::form::XForm >& xForm, sal_uInt32 nRelPos); + void RemoveForm(FmFormData const * pFormData); + + void InsertFormComponent(const css::uno::Reference< css::form::XFormComponent >& xComp, sal_uInt32 nRelPos); + void RemoveFormComponent(FmControlData const * pControlData); + void InsertSdrObj(const SdrObject* pSdrObj); + void RemoveSdrObj(const SdrObject* pSdrObj); + + void ReplaceFormComponent(const css::uno::Reference< css::form::XFormComponent >& xOld, const css::uno::Reference< css::form::XFormComponent >& xNew); + + void BroadcastMarkedObjects(const SdrMarkList& mlMarked); + // send a RequestSelectHint with the currently selected objects + bool InsertFormComponent(FmNavRequestSelectHint& rHint, SdrObject* pObject); + // is a helper for previous, manages the ... in SdrObjGroups; + // returns sal_True if the object is a FormComponent (or recursively consists only of such) + + public: + NavigatorTreeModel(); + virtual ~NavigatorTreeModel() override; + + void FillBranch( FmFormData* pParentData ); + void UpdateContent( FmFormShell* pNewShell ); + + void Insert(FmEntryData* pEntryData, sal_uInt32 nRelPos = SAL_MAX_UINT32, + bool bAlterModel = false); + void Remove(FmEntryData* pEntryData, bool bAlterModel = false); + + static bool Rename( FmEntryData* pEntryData, const OUString& rNewText ); + + void Clear(); + void SetModified(); + + css::uno::Reference< css::form::XForms > GetForms() const; + FmFormShell* GetFormShell() const { return m_pFormShell; } + FmFormPage* GetFormPage() const { return m_pFormPage; } + FmEntryData* FindData( const css::uno::Reference< css::uno::XInterface >& xElement, FmEntryDataList* pDataList, bool bRecurs=true ); + FmEntryData* FindData( const OUString& rText, FmFormData const * pParentData, bool bRecurs ); + FmEntryDataList* GetRootList() const { return m_pRootList.get(); } + static css::uno::Reference< css::container::XIndexContainer > GetFormComponents( FmFormData const * pParentFormData ); + + virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override; + }; + + + typedef std::set<SvTreeListEntry*> SvLBoxEntrySortedArray; + + class NavigatorTree : public SvTreeListBox, public SfxListener + { + enum DROP_ACTION { DA_SCROLLUP, DA_SCROLLDOWN, DA_EXPANDNODE }; + enum SELDATA_ITEMS { SDI_DIRTY, SDI_ALL, SDI_NORMALIZED, SDI_NORMALIZED_FORMARK }; + + // when dropping I want to be able to scroll and to expand folders, for this: + AutoTimer m_aDropActionTimer; + Timer m_aSynchronizeTimer; + // the meta-data about my current selection + SvLBoxEntrySortedArray m_arrCurrentSelection; + // the entries which, in the view, are currently marked as "cut" (painted semi-transparent) + ListBoxEntrySet m_aCutEntries; + + ::svxform::OControlExchangeHelper m_aControlExchange; + + std::unique_ptr<NavigatorTreeModel> m_pNavModel; + SvTreeListEntry* m_pRootEntry; + SvTreeListEntry* m_pEditEntry; + + ImplSVEvent * nEditEvent; + + SELDATA_ITEMS m_sdiState; + Point m_aTimerTriggered; // the position at which the DropTimer was switched on + DROP_ACTION m_aDropActionType; + + sal_uInt16 m_nSelectLock; + sal_uInt16 m_nFormsSelected; + sal_uInt16 m_nControlsSelected; + sal_uInt16 m_nHiddenControls; // (the number is included in m_nControlsSelected) + + unsigned short m_aTimerCounter; + + bool m_bDragDataDirty : 1; // ditto + bool m_bPrevSelectionMixed : 1; + bool m_bRootSelected : 1; + bool m_bInitialUpdate : 1; // am I the first time in the UpdateContent? + bool m_bKeyboardCut : 1; + + FmControlData* NewControl( const OUString& rServiceName, SvTreeListEntry const * pParentEntry, bool bEditName ); + void NewForm( SvTreeListEntry const * pParentEntry ); + SvTreeListEntry* Insert( FmEntryData* pEntryData, sal_uLong nRelPos ); + void Remove( FmEntryData* pEntryData ); + + + void CollectSelectionData(SELDATA_ITEMS sdiHow); + // Collects the currently selected entries in m_arrCurrentSelection, normalizes the list if requested. + // - SDI_NORMALIZED simply means that all entries that already have a selected ancestor are not collected. + // - SDI_NORMALIZED_FORMARK means that the procedure is the same as for SDI_NORMALIZED, + // but entries whose direct parent is not selected are collected (independent of the + // status of further ancestors). The same applies for forms that are selected, + // regardless of the status of any ancestors. + // For both normalized modes, the m_nFormsSelected, ... contain the correct number, + // even if not all of these entries end up in m_arrCurrentSelection. + // SDI_DIRTY is of course not allowed as a parameter. + + // a single interface for all selected entries + void ShowSelectionProperties(bool bForce = false); + // delete all selected elements + void DeleteSelection(); + + void SynchronizeSelection(FmEntryDataArray& arredToSelect); + // after calling this method, exactly the entries marked in the array are selected + void SynchronizeSelection(); + // makes the same, takes the MarkList of the View + void SynchronizeMarkList(); + // reverse direction of SynchronizeMarkList: selects in the view all controls corresponding to the current selection + + void CollectObjects(FmFormData const * pFormData, bool bDeep, ::std::set< css::uno::Reference< css::form::XFormComponent > >& _rObjects); + + // in the Select I usually update the Marklist of the corresponding view, + // with the following functions I can control the locking of this behavior + void LockSelectionHandling() { ++m_nSelectLock; } + void UnlockSelectionHandling() { --m_nSelectLock; } + bool IsSelectionHandlingLocked() const { return m_nSelectLock>0; } + + static bool IsHiddenControl(FmEntryData const * pEntryData); + + DECL_LINK( OnEdit, void*, void ); + DECL_LINK( OnDropActionTimer, Timer*, void ); + + DECL_LINK( OnEntrySelDesel, SvTreeListBox*, void ); + DECL_LINK( OnSynchronizeTimer, Timer*, void ); + + DECL_LINK( OnClipboardAction, OLocalExchange&, void ); + + protected: + virtual void Command( const CommandEvent& rEvt ) override; + + virtual sal_Int8 AcceptDrop( const AcceptDropEvent& rEvt ) override; + virtual sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt ) override; + virtual void StartDrag( sal_Int8 nAction, const Point& rPosPixel ) override; + + public: + NavigatorTree(vcl::Window* pParent ); + virtual ~NavigatorTree() override; + virtual void dispose() override; + + void Clear(); + void UpdateContent( FmFormShell* pFormShell ); + void MarkViewObj( FmFormData const * pFormData, bool bDeep ); + void MarkViewObj( FmControlData const * pControlData ); + void UnmarkAllViewObj(); + + static bool IsFormEntry( SvTreeListEntry const * pEntry ); + static bool IsFormComponentEntry( SvTreeListEntry const * pEntry ); + + OUString GenerateName( FmEntryData const * pEntryData ); + + NavigatorTreeModel* GetNavModel() const { return m_pNavModel.get(); } + SvTreeListEntry* FindEntry( FmEntryData* pEntryData ); + + virtual bool EditedEntry( SvTreeListEntry* pEntry, const OUString& rNewText ) override; + virtual bool Select( SvTreeListEntry* pEntry, bool bSelect=true ) override; + virtual bool EditingEntry( SvTreeListEntry* pEntry, Selection& ) override; + virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override; + virtual void KeyInput( const KeyEvent& rKEvt ) override; + + virtual void ModelHasRemoved( SvTreeListEntry* _pEntry ) override; + + using SvTreeListBox::Insert; + using SvTreeListBox::ExecuteDrop; + using SvTreeListBox::Select; + + private: + sal_Int8 implAcceptDataTransfer( const DataFlavorExVector& _rFlavors, sal_Int8 _nAction, SvTreeListEntry* _pTargetEntry, bool _bDnD ); + + sal_Int8 implExecuteDataTransfer( const OControlTransferData& _rData, sal_Int8 _nAction, const Point& _rDropPos, bool _bDnD ); + sal_Int8 implExecuteDataTransfer( const OControlTransferData& _rData, sal_Int8 _nAction, SvTreeListEntry* _pTargetEntry, bool _bDnD ); + + // check if a cut, copy, or drag operation can be started in the current situation + bool implAllowExchange( sal_Int8 _nAction, bool* _pHasNonHidden = nullptr ); + // check if a paste with the current clipboard content can be accepted + bool implAcceptPaste( ); + + // fills m_aControlExchange in preparation of a DnD or clipboard operation + bool implPrepareExchange( sal_Int8 _nAction ); + + void doPaste(); + void doCopy(); + void doCut(); + + bool doingKeyboardCut( ) const { return m_bKeyboardCut; } + }; + + + class NavigatorFrame : public SfxDockingWindow, public SfxControllerItem + { + private: + VclPtr< ::svxform::NavigatorTree> m_pNavigatorTree; + + protected: + virtual void Resize() override; + virtual bool Close() override; + virtual void GetFocus() override; + virtual Size CalcDockingSize( SfxChildAlignment ) override; + virtual SfxChildAlignment CheckAlignment( SfxChildAlignment, SfxChildAlignment ) override; + + using SfxDockingWindow::StateChanged; + + public: + NavigatorFrame( SfxBindings *pBindings, SfxChildWindow *pMgr, + vcl::Window* pParent ); + virtual ~NavigatorFrame() override; + virtual void dispose() override; + + void UpdateContent( FmFormShell* pFormShell ); + void StateChanged( sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState ) override; + void FillInfo( SfxChildWinInfo& rInfo ) const override; + }; + + + class UNLESS_MERGELIBS(SVXCORE_DLLPUBLIC) NavigatorFrameManager : public SfxChildWindow + { + public: + SVX_DLLPRIVATE NavigatorFrameManager( vcl::Window *pParent, sal_uInt16 nId, SfxBindings *pBindings, + SfxChildWinInfo *pInfo ); + SFX_DECL_CHILDWINDOW( NavigatorFrameManager ); + }; + + +} + + +#endif // INCLUDED_SVX_SOURCE_INC_FMEXPL_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/inc/fmobj.hxx b/svx/source/inc/fmobj.hxx new file mode 100644 index 000000000..4f7467f49 --- /dev/null +++ b/svx/source/inc/fmobj.hxx @@ -0,0 +1,119 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_SVX_SOURCE_INC_FMOBJ_HXX +#define INCLUDED_SVX_SOURCE_INC_FMOBJ_HXX + +#include <config_options.h> +#include <svx/svdouno.hxx> +#include <com/sun/star/container/XIndexContainer.hpp> +#include <com/sun/star/form/XForms.hpp> +#include <com/sun/star/script/ScriptEventDescriptor.hpp> + + +// FmFormObj + +class UNLESS_MERGELIBS(SVXCORE_DLLPUBLIC) FmFormObj : public SdrUnoObj +{ + FmFormObj( const FmFormObj& ) = delete; + + css::uno::Sequence< css::script::ScriptEventDescriptor > aEvts; // events of the object + css::uno::Sequence< css::script::ScriptEventDescriptor> m_aEventsHistory; + // valid if and only if m_pEnvironmentHistory != NULL, this are the events which we're set when + // m_pEnvironmentHistory was created + + // information for the control environment is only maintained if an object is not in an + // object list + css::uno::Reference< css::container::XIndexContainer> m_xParent; + css::uno::Reference< css::form::XForms > m_xEnvironmentHistory; + sal_Int32 m_nPos; + + VclPtr<OutputDevice> m_pLastKnownRefDevice; + // the last ref device we know, as set at the model + // only to be used for comparison with the current ref device! + +protected: + // protected destructor + SAL_DLLPRIVATE virtual ~FmFormObj() override; + +public: + FmFormObj( + SdrModel& rSdrModel, + const OUString& rModelName); + FmFormObj(SdrModel& rSdrModel); + + SAL_DLLPRIVATE const css::uno::Reference< css::container::XIndexContainer>& + GetOriginalParent() const { return m_xParent; } + SAL_DLLPRIVATE const css::uno::Sequence< css::script::ScriptEventDescriptor >& + GetOriginalEvents() const { return aEvts; } + SAL_DLLPRIVATE sal_Int32 + GetOriginalIndex() const { return m_nPos; } + + SAL_DLLPRIVATE void SetObjEnv( + const css::uno::Reference< css::container::XIndexContainer>& xForm, + const sal_Int32 nIdx, + const css::uno::Sequence< css::script::ScriptEventDescriptor >& rEvts ); + SAL_DLLPRIVATE void ClearObjEnv(); + +public: + // react on page change + virtual void handlePageChange(SdrPage* pOldPage, SdrPage* pNewPage) override; + + SAL_DLLPRIVATE virtual SdrInventor GetObjInventor() const override; + SAL_DLLPRIVATE virtual sal_uInt16 GetObjIdentifier() const override; + SAL_DLLPRIVATE virtual void NbcReformatText() override; + + SAL_DLLPRIVATE virtual FmFormObj* CloneSdrObject(SdrModel& rTargetModel) const override; + SAL_DLLPRIVATE FmFormObj& operator= (const FmFormObj& rObj); + + SAL_DLLPRIVATE void clonedFrom(const FmFormObj* _pSource); + + SAL_DLLPRIVATE static css::uno::Reference< css::uno::XInterface> ensureModelEnv( + const css::uno::Reference< css::uno::XInterface>& _rSourceContainer, + const css::uno::Reference< css::form::XForms>& _rTopLevelDestContainer); + + /** returns the FmFormObj behind the given SdrObject + + In case the SdrObject *is* a FmFormObject, this is a simple cast. In case the SdrObject + is a virtual object whose referenced object is a FmFormObj, then this referenced + object is returned. In all other cases, NULL is returned. + */ + SAL_DLLPRIVATE static FmFormObj* GetFormObject( SdrObject* _pSdrObject ); + SAL_DLLPRIVATE static const FmFormObj* GetFormObject( const SdrObject* _pSdrObject ); + + SAL_DLLPRIVATE virtual void SetUnoControlModel( const css::uno::Reference< css::awt::XControlModel >& _rxModel ) override; + +protected: + SAL_DLLPRIVATE virtual bool EndCreate( SdrDragStat& rStat, SdrCreateCmd eCmd ) override; + SAL_DLLPRIVATE virtual void BrkCreate( SdrDragStat& rStat ) override; + +private: + /** isolates the control model from its form component hierarchy, i.e. removes it from + its parent. + */ + SAL_DLLPRIVATE void impl_isolateControlModel_nothrow(); + + /** forwards the reference device of our SdrModel to the control model + */ + SAL_DLLPRIVATE void impl_checkRefDevice_nothrow( bool _force = false ); +}; + + +#endif // _FM_FMOBJ_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/inc/fmpgeimp.hxx b/svx/source/inc/fmpgeimp.hxx new file mode 100644 index 000000000..1e2b63207 --- /dev/null +++ b/svx/source/inc/fmpgeimp.hxx @@ -0,0 +1,144 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_SVX_SOURCE_INC_FMPGEIMP_HXX +#define INCLUDED_SVX_SOURCE_INC_FMPGEIMP_HXX + +#include <config_options.h> +#include <com/sun/star/sdbc/XDataSource.hpp> +#include <com/sun/star/form/XFormComponent.hpp> +#include <com/sun/star/form/XForm.hpp> +#include <com/sun/star/form/XForms.hpp> +#include <com/sun/star/container/XMap.hpp> + +#include <tools/link.hxx> +#include <cppuhelper/weakref.hxx> + +#include <svx/svxdllapi.h> + +class FmFormObj; +class FmFormPage; +class SdrObject; + + +// FmFormPageImpl +// Listens to all containers to determine when objects have been inserted +// and when they have been removed + + +class FmFormPageImpl final +{ + css::uno::Reference< css::form::XForm > xCurrentForm; + css::uno::Reference< css::form::XForms > m_xForms; + css::uno::WeakReference< css::container::XMap > m_aControlShapeMap; + + FmFormPage& m_rPage; + Link<FmFormPageImpl&,void> m_aFormsCreationHdl; + + bool m_bFirstActivation; + bool m_bAttemptedFormCreation; + +public: + explicit FmFormPageImpl( FmFormPage& _rPage ); + ~FmFormPageImpl(); + + void initFrom( FmFormPageImpl& i_foreignImpl ); + + // only important for the DesignMode + void setCurForm(const css::uno::Reference< css::form::XForm>& xForm); + css::uno::Reference< css::form::XForm> getDefaultForm(); + + /** finds a place in the form component hierarchy where to insert the given component + + Note that no actual insertion happens, this is the responsibility of the caller (as + the caller might decide on a suitable place where in the returned container the insertion + should happen). + */ + css::uno::Reference< css::form::XForm> findPlaceInFormComponentHierarchy( + const css::uno::Reference< css::form::XFormComponent>& rContent, + const css::uno::Reference< css::sdbc::XDataSource>& rDatabase = css::uno::Reference< css::sdbc::XDataSource>(), + const OUString& rDBTitle = OUString(), + const OUString& rCursorSource = OUString(), + sal_Int32 nCommandType = 0 + ); + + // activation handling + bool hasEverBeenActivated( ) const { return !m_bFirstActivation; } + void setHasBeenActivated( ) { m_bFirstActivation = false; } + + const css::uno::Reference< css::form::XForms>& getForms( bool _bForceCreate = true ); + + void SetFormsCreationHdl( const Link<FmFormPageImpl&,void>& _rFormsCreationHdl ) { m_aFormsCreationHdl = _rFormsCreationHdl; } + +private: + /** finds a form with a given data source signature + @param rForm + the form to start the search with. This form, including all possible sub forms, + will be examined + @param rDatabase + the data source which to which the found form must be bound + @param rCommand + the desired Command property value of the sought-after form + @param nCommandType + the desired CommandType property value of the sought-after form + */ + css::uno::Reference< css::form::XForm> findFormForDataSource( + const css::uno::Reference< css::form::XForm>& rForm, + const css::uno::Reference< css::sdbc::XDataSource>& rDatabase, + const OUString& rCommand, + sal_Int32 nCommandType + ); + +public: + static OUString setUniqueName(const css::uno::Reference< css::form::XFormComponent>& xFormComponent, const css::uno::Reference< css::form::XForm>& xControls); + + void formObjectInserted( const FmFormObj& _object ); + void formObjectRemoved( const FmFormObj& _object ); + void formModelAssigned( const FmFormObj& _object ); + + /** returns an object mapping from control models to drawing shapes. + */ + UNLESS_MERGELIBS(SVXCORE_DLLPUBLIC) css::uno::Reference< css::container::XMap > getControlToShapeMap(); + +private: + /** validates whether <member>xCurrentForm</member> is still valid and to be used + + There are situations where our current form becomes invalid, without us noticing this. Thus, + every method which accesses <member>xCurrentForm</member> should beforehand validate the current + form by calling this method. + + If <member>xCurrentForm</member> is not valid anymore, it is reset to <NULL/>. + + @return + <TRUE/> if and only if xCurrentForm is valid. + + @since #i40086# + */ + bool validateCurForm(); + + css::uno::Reference< css::container::XMap > + impl_createControlShapeMap_nothrow(); + + FmFormPageImpl( const FmFormPageImpl& ) = delete; + FmFormPageImpl& operator=( const FmFormPageImpl& ) = delete; +}; + + +#endif // INCLUDED_SVX_SOURCE_INC_FMPGEIMP_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/inc/fmprop.hxx b/svx/source/inc/fmprop.hxx new file mode 100644 index 000000000..0ea06e09f --- /dev/null +++ b/svx/source/inc/fmprop.hxx @@ -0,0 +1,151 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_SVX_SOURCE_INC_FMPROP_HXX +#define INCLUDED_SVX_SOURCE_INC_FMPROP_HXX + +// PropertyIds, which have an assignment to a PropertyName, could continue +// to be WhichIds in the future -> Itemset +#define FM_ATTR_START 0 + +#define FM_ATTR_FILTER ( FM_ATTR_START + 1 ) +#define FM_ATTR_FORM_OPERATIONS ( FM_ATTR_START + 2 ) + +#define FM_PROP_NAME "Name" +#define FM_PROP_CLASSID "ClassId" +#define FM_PROP_ALIGN "Align" +#define FM_PROP_ROWCOUNT "RowCount" +#define FM_PROP_ROWCOUNTFINAL "IsRowCountFinal" +#define FM_PROP_FETCHSIZE "FetchSize" +#define FM_PROP_VALUE "Value" +#define FM_PROP_VALUEMIN "ValueMin" +#define FM_PROP_VALUEMAX "ValueMax" +#define FM_PROP_VALUESTEP "ValueStep" +#define FM_PROP_TEXT "Text" +#define FM_PROP_LABEL "Label" +#define FM_PROP_NAVIGATION "NavigationBarMode" +#define FM_PROP_CYCLE "Cycle" +#define FM_PROP_CONTROLSOURCE "DataField" +#define FM_PROP_ENABLED "Enabled" +#define FM_PROP_SPIN "Spin" +#define FM_PROP_READONLY "ReadOnly" +#define FM_PROP_FILTER "Filter" +#define FM_PROP_AUTOINCREMENT "IsAutoIncrement" +#define FM_PROP_WIDTH "Width" +#define FM_PROP_SEARCHABLE "IsSearchable" +#define FM_PROP_MULTILINE "MultiLine" +#define FM_PROP_TARGET_URL "TargetURL" +#define FM_PROP_DEFAULTCONTROL "DefaultControl" +#define FM_PROP_MAXTEXTLEN "MaxTextLen" +#define FM_PROP_DATE "Date" +#define FM_PROP_TIME "Time" +#define FM_PROP_STATE "State" +#define FM_PROP_TRISTATE "TriState" +#define FM_PROP_STRINGITEMLIST "StringItemList" +#define FM_PROP_DEFAULT_TEXT "DefaultText" +#define FM_PROP_DEFAULTCHECKED "DefaultState" +#define FM_PROP_DEFAULT_DATE "DefaultDate" +#define FM_PROP_DEFAULT_TIME "DefaultTime" +#define FM_PROP_DEFAULT_VALUE "DefaultValue" +#define FM_PROP_FORMATKEY "FormatKey" +#define FM_PROP_FORMATSSUPPLIER "FormatsSupplier" +#define FM_PROP_LISTSOURCETYPE "ListSourceType" +#define FM_PROP_LISTSOURCE "ListSource" +#define FM_PROP_SELECT_SEQ "SelectedItems" +#define FM_PROP_VALUE_SEQ "ValueItemList" +#define FM_PROP_DEFAULT_SELECT_SEQ "DefaultSelection" +#define FM_PROP_DECIMAL_ACCURACY "DecimalAccuracy" +#define FM_PROP_EDITMASK "EditMask" +#define FM_PROP_ISREADONLY "IsReadOnly" +#define FM_PROP_FIELDTYPE "Type" +#define FM_PROP_REFVALUE "RefValue" +#define FM_PROP_STRICTFORMAT "StrictFormat" +#define FM_PROP_DATASOURCE "DataSourceName" +#define FM_PROP_LITERALMASK "LiteralMask" +#define FM_PROP_SHOWTHOUSANDSEP "ShowThousandsSeparator" +#define FM_PROP_CURRENCYSYMBOL "CurrencySymbol" +#define FM_PROP_DATEFORMAT "DateFormat" +#define FM_PROP_DATEMIN "DateMin" +#define FM_PROP_DATEMAX "DateMax" +#define FM_PROP_DATE_SHOW_CENTURY "DateShowCentury" +#define FM_PROP_TIMEFORMAT "TimeFormat" +#define FM_PROP_TIMEMIN "TimeMin" +#define FM_PROP_TIMEMAX "TimeMax" +#define FM_PROP_LINECOUNT "LineCount" +#define FM_PROP_BOUNDCOLUMN "BoundColumn" +#define FM_PROP_HASNAVIGATION "HasNavigationBar" +#define FM_PROP_FONT "FontDescriptor" +#define FM_PROP_BACKGROUNDCOLOR "BackgroundColor" +#define FM_PROP_TEXTCOLOR "TextColor" +#define FM_PROP_BORDER "Border" +#define FM_PROP_DROPDOWN "Dropdown" +#define FM_PROP_ROWHEIGHT "RowHeight" +#define FM_PROP_HELPTEXT "HelpText" +#define FM_PROP_HELPURL "HelpURL" +#define FM_PROP_RECORDMARKER "HasRecordMarker" +#define FM_PROP_BOUNDFIELD "BoundField" +#define FM_PROP_EFFECTIVE_VALUE "EffectiveValue" +#define FM_PROP_EFFECTIVE_DEFAULT "EffectiveDefault" +#define FM_PROP_EFFECTIVE_MIN "EffectiveMin" +#define FM_PROP_EFFECTIVE_MAX "EffectiveMax" +#define FM_PROP_HIDDEN "Hidden" +#define FM_PROP_FILTERPROPOSAL "UseFilterValueProposal" +#define FM_PROP_FIELDSOURCE "FieldSource" +#define FM_PROP_TABLENAME "TableName" +#define FM_PROP_CONTROLLABEL "LabelControl" +#define FM_PROP_CURSORCOLOR "CursorColor" +#define FM_PROP_ALWAYSSHOWCURSOR "AlwaysShowCursor" +#define FM_PROP_DISPLAYSYNCHRON "DisplayIsSynchron" +#define FM_PROP_ISMODIFIED "IsModified" +#define FM_PROP_ISNEW "IsNew" +#define FM_PROP_PRIVILEGES "Privileges" +#define FM_PROP_COMMAND "Command" +#define FM_PROP_COMMANDTYPE "CommandType" +#define FM_PROP_RESULTSET_CONCURRENCY "ResultSetConcurrency" +#define FM_PROP_INSERTONLY "IgnoreResult" +#define FM_PROP_RESULTSET_TYPE "ResultSetType" +#define FM_PROP_ESCAPE_PROCESSING "EscapeProcessing" +#define FM_PROP_APPLYFILTER "ApplyFilter" +#define FM_PROP_ISNULLABLE "IsNullable" +#define FM_PROP_ACTIVECOMMAND "ActiveCommand" +#define FM_PROP_ISCURRENCY "IsCurrency" +#define FM_PROP_URL "URL" +#define FM_PROP_ACTIVE_CONNECTION "ActiveConnection" +#define FM_PROP_CONTROLSOURCEPROPERTY "DataFieldProperty" +#define FM_PROP_REALNAME "RealName" +#define FM_PROP_TEXTLINECOLOR "TextLineColor" +#define FM_PROP_FONTEMPHASISMARK "FontEmphasisMark" +#define FM_PROP_FONTRELIEF "FontRelief" +#define FM_PROP_ORIENTATION "Orientation" +#define FM_PROP_LINEENDFORMAT "LineEndFormat" +#define FM_PROP_VISUALEFFECT "VisualEffect" +#define FM_PROP_BORDERCOLOR "BorderColor" +#define FM_PROP_DYNAMIC_CONTROL_BORDER "DynamicControlBorder" +#define FM_PROP_CONTROL_BORDER_COLOR_FOCUS "ControlBorderColorOnFocus" +#define FM_PROP_CONTROL_BORDER_COLOR_MOUSE "ControlBorderColorOnHover" +#define FM_PROP_CONTROL_BORDER_COLOR_INVALID "ControlBorderColorOnInvalid" +#define FM_PROP_BUTTON_TYPE "ButtonType" +#define FM_PROP_FORM_OPERATIONS "FormOperations" +#define FM_PROP_INPUT_REQUIRED "InputRequired" +#define FM_PROP_WRITING_MODE "WritingMode" +#define FM_PROP_MOUSE_WHEEL_BEHAVIOR "MouseWheelBehavior" +#define FM_PROP_DESCRIPTION "Description" + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/inc/fmscriptingenv.hxx b/svx/source/inc/fmscriptingenv.hxx new file mode 100644 index 000000000..ef4f29f80 --- /dev/null +++ b/svx/source/inc/fmscriptingenv.hxx @@ -0,0 +1,97 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_SVX_SOURCE_INC_FMSCRIPTINGENV_HXX +#define INCLUDED_SVX_SOURCE_INC_FMSCRIPTINGENV_HXX + +#include <com/sun/star/script/XEventAttacherManager.hpp> +#include <rtl/ref.hxx> +#include <salhelper/simplereferenceobject.hxx> + +class FmFormModel; + +namespace svxform +{ + class FormScriptListener; + + //= IFormScriptingEnvironment + + /** describes the interface implemented by a component which handles scripting requirements + in a form/control environment. + */ + class FormScriptingEnvironment : public ::salhelper::SimpleReferenceObject + { + friend class FormScriptListener; + public: + explicit FormScriptingEnvironment( FmFormModel& _rModel ); + FormScriptingEnvironment(const FormScriptingEnvironment&) = delete; + FormScriptingEnvironment& operator=(const FormScriptingEnvironment&) = delete; + + /** registers an XEventAttacherManager whose events should be monitored and handled + + @param _rxManager + the XEventAttacherManager to monitor. Must not be <NULL/>. + + @throws css::lang::IllegalArgumentException + if <arg>_rxManager</arg> is <NULL/> + @throws css::lang::DisposedException + if the instance is already disposed + @throws css::uno::RuntimeException + if attaching as script listener to the manager fails with a RuntimeException itself + */ + void registerEventAttacherManager( + const css::uno::Reference< css::script::XEventAttacherManager >& _rxManager ); + + /** registers an XEventAttacherManager whose events should not be monitored and handled anymore + + @param _rxManager + the XEventAttacherManager which was previously registered. Must not ne <NULL/>. + + @throws css::lang::IllegalArgumentException + if <arg>_rxManager</arg> is <NULL/> + @throws css::lang::DisposedException + if the instance is already disposed + @throws css::uno::RuntimeException + if removing as script listener from the manager fails with a RuntimeException itself + */ + void revokeEventAttacherManager( + const css::uno::Reference< css::script::XEventAttacherManager >& _rxManager ); + + /** disposes the scripting environment instance + */ + void dispose(); + + private: + ::osl::Mutex m_aMutex; + rtl::Reference<FormScriptListener> m_pScriptListener; + FmFormModel& m_rFormModel; + bool m_bDisposed; + + void impl_registerOrRevoke_throw( const css::uno::Reference< css::script::XEventAttacherManager >& _rxManager, bool _bRegister ); + // callback for FormScriptListener + void doFireScriptEvent( const css::script::ScriptEvent& _rEvent, css::uno::Any* _pSynchronousResult ); + + }; + +} + + +#endif // INCLUDED_SVX_SOURCE_INC_FMSCRIPTINGENV_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/inc/fmservs.hxx b/svx/source/inc/fmservs.hxx new file mode 100644 index 000000000..d575f8652 --- /dev/null +++ b/svx/source/inc/fmservs.hxx @@ -0,0 +1,110 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_SVX_SOURCE_INC_FMSERVS_HXX +#define INCLUDED_SVX_SOURCE_INC_FMSERVS_HXX + +#include <sal/config.h> + +#include <com/sun/star/uno/Reference.hxx> +#include <svx/svxdllapi.h> + +namespace com::sun::star::lang { class XMultiServiceFactory; } + +#define FM_COMPONENT_EDIT "stardiv.one.form.component.Edit" +#define FM_COMPONENT_TEXTFIELD "stardiv.one.form.component.TextField" +#define FM_COMPONENT_LISTBOX "stardiv.one.form.component.ListBox" +#define FM_COMPONENT_COMBOBOX "stardiv.one.form.component.ComboBox" +#define FM_COMPONENT_RADIOBUTTON "stardiv.one.form.component.RadioButton" +#define FM_COMPONENT_GROUPBOX "stardiv.one.form.component.GroupBox" +#define FM_COMPONENT_FIXEDTEXT "stardiv.one.form.component.FixedText" +#define FM_COMPONENT_COMMANDBUTTON "stardiv.one.form.component.CommandButton" +#define FM_COMPONENT_CHECKBOX "stardiv.one.form.component.CheckBox" +#define FM_COMPONENT_GRID "stardiv.one.form.component.Grid" +#define FM_COMPONENT_GRIDCONTROL "stardiv.one.form.component.GridControl" +#define FM_COMPONENT_IMAGEBUTTON "stardiv.one.form.component.ImageButton" +#define FM_COMPONENT_FILECONTROL "stardiv.one.form.component.FileControl" +#define FM_COMPONENT_TIMEFIELD "stardiv.one.form.component.TimeField" +#define FM_COMPONENT_DATEFIELD "stardiv.one.form.component.DateField" +#define FM_COMPONENT_NUMERICFIELD "stardiv.one.form.component.NumericField" +#define FM_COMPONENT_CURRENCYFIELD "stardiv.one.form.component.CurrencyField" +#define FM_COMPONENT_PATTERNFIELD "stardiv.one.form.component.PatternField" +#define FM_COMPONENT_FORMATTEDFIELD "stardiv.one.form.component.FormattedField" +#define FM_COMPONENT_HIDDEN "stardiv.one.form.component.Hidden" +#define FM_COMPONENT_HIDDENCONTROL "stardiv.one.form.component.HiddenControl" +#define FM_COMPONENT_IMAGECONTROL "stardiv.one.form.component.ImageControl" +#define FM_CONTROL_GRID "stardiv.one.form.control.Grid" +#define FM_CONTROL_GRIDCONTROL "stardiv.one.form.control.GridControl" +#define SRV_SDB_CONNECTION "com.sun.star.sdb.Connection" +#define FM_SUN_COMPONENT_FORM "com.sun.star.form.component.Form" +#define FM_SUN_COMPONENT_TEXTFIELD "com.sun.star.form.component.TextField" +#define FM_SUN_COMPONENT_LISTBOX "com.sun.star.form.component.ListBox" +#define FM_SUN_COMPONENT_COMBOBOX "com.sun.star.form.component.ComboBox" +#define FM_SUN_COMPONENT_RADIOBUTTON "com.sun.star.form.component.RadioButton" +#define FM_SUN_COMPONENT_GROUPBOX "com.sun.star.form.component.GroupBox" +#define FM_SUN_COMPONENT_FIXEDTEXT "com.sun.star.form.component.FixedText" +#define FM_SUN_COMPONENT_COMMANDBUTTON "com.sun.star.form.component.CommandButton" +#define FM_SUN_COMPONENT_CHECKBOX "com.sun.star.form.component.CheckBox" +#define FM_SUN_COMPONENT_GRIDCONTROL "com.sun.star.form.component.GridControl" +#define FM_SUN_COMPONENT_IMAGEBUTTON "com.sun.star.form.component.ImageButton" +#define FM_SUN_COMPONENT_FILECONTROL "com.sun.star.form.component.FileControl" +#define FM_SUN_COMPONENT_TIMEFIELD "com.sun.star.form.component.TimeField" +#define FM_SUN_COMPONENT_DATEFIELD "com.sun.star.form.component.DateField" +#define FM_SUN_COMPONENT_NUMERICFIELD "com.sun.star.form.component.NumericField" +#define FM_SUN_COMPONENT_CURRENCYFIELD "com.sun.star.form.component.CurrencyField" +#define FM_SUN_COMPONENT_PATTERNFIELD "com.sun.star.form.component.PatternField" +#define FM_SUN_COMPONENT_HIDDENCONTROL "com.sun.star.form.component.HiddenControl" +#define FM_SUN_COMPONENT_IMAGECONTROL "com.sun.star.form.component.DatabaseImageControl" +#define FM_SUN_COMPONENT_FORMATTEDFIELD "com.sun.star.form.component.FormattedField" +#define FM_SUN_COMPONENT_SCROLLBAR "com.sun.star.form.component.ScrollBar" +#define FM_SUN_COMPONENT_SPINBUTTON "com.sun.star.form.component.SpinButton" +#define FM_SUN_COMPONENT_NAVIGATIONBAR "com.sun.star.form.component.NavigationToolBar" +#define FM_SUN_CONTROL_GRIDCONTROL "com.sun.star.form.control.GridControl" + +namespace svxform +{ + SVXCORE_DLLPUBLIC void ImplSmartRegisterUnoServices(); + + css::uno::Reference<css::uno::XInterface> + OAddConditionDialog_Create( + css::uno::Reference<css::lang::XMultiServiceFactory> const &); + + OUString OAddConditionDialog_GetImplementationName(); + + css::uno::Sequence<OUString> + OAddConditionDialog_GetSupportedServiceNames(); +} + +/// @throws css::uno::Exception +css::uno::Reference<css::uno::XInterface> +FmXGridControl_NewInstance_Impl( + css::uno::Reference<css::lang::XMultiServiceFactory> const &); + +/// @throws css::uno::Exception +css::uno::Reference<css::uno::XInterface> +FormController_NewInstance_Impl( + css::uno::Reference<css::lang::XMultiServiceFactory> const &); + +/// @throws css::uno::Exception +css::uno::Reference<css::uno::XInterface> +LegacyFormController_NewInstance_Impl( + css::uno::Reference<css::lang::XMultiServiceFactory> const &); + +#endif // INCLUDED_SVX_SOURCE_INC_FMSERVS_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/inc/fmshimp.hxx b/svx/source/inc/fmshimp.hxx new file mode 100644 index 000000000..8bba0fbef --- /dev/null +++ b/svx/source/inc/fmshimp.hxx @@ -0,0 +1,557 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_SVX_SOURCE_INC_FMSHIMP_HXX +#define INCLUDED_SVX_SOURCE_INC_FMSHIMP_HXX + +#include <config_options.h> +#include <com/sun/star/sdbc/XResultSet.hpp> +#include <com/sun/star/container/ContainerEvent.hpp> +#include <com/sun/star/container/XContainerListener.hpp> +#include <com/sun/star/awt/XControl.hpp> +#include <com/sun/star/awt/XControlContainer.hpp> +#include <com/sun/star/form/XForm.hpp> +#include <com/sun/star/form/runtime/XFormController.hpp> +#include <com/sun/star/form/XFormComponent.hpp> +#include <com/sun/star/form/NavigationBarMode.hpp> +#include <com/sun/star/frame/XFrame.hpp> +#include <com/sun/star/view/XSelectionChangeListener.hpp> +#include <com/sun/star/beans/XPropertyChangeListener.hpp> +#include <com/sun/star/beans/PropertyChangeEvent.hpp> +#include <com/sun/star/form/runtime/FeatureState.hpp> +#include <vcl/builder.hxx> +#include <vcl/menu.hxx> +#include <vcl/timer.hxx> +#include <vcl/window.hxx> +#include <sfx2/shell.hxx> +#include <svx/svdmark.hxx> +#include <svx/fmsearch.hxx> + +#include <svx/fmtools.hxx> +#include <osl/mutex.hxx> +#include <comphelper/container.hxx> +#include <cppuhelper/compbase.hxx> +#include <unotools/configitem.hxx> +#include "formcontrolling.hxx" +#include "fmdocumentclassification.hxx" +#include <o3tl/typed_flags_set.hxx> + +#include <queue> +#include <vector> +#include <memory> + +typedef std::vector< css::uno::Reference< css::form::XForm > > FmFormArray; + +// catch database exceptions if they occur +#define DO_SAFE(statement) try { statement; } catch( const Exception& ) { OSL_FAIL("unhandled exception (I tried to move a cursor (or something like that).)"); } + +enum class LoopGridsSync { + DISABLE_SYNC = 1, + FORCE_SYNC = 2, + ENABLE_SYNC = 3 +}; +enum class LoopGridsFlags +{ + NONE = 0, + DISABLE_ROCTRLR = 4 +}; +namespace o3tl +{ + template<> struct typed_flags<LoopGridsFlags> : is_typed_flags<LoopGridsFlags, 0x04> {}; +} + + +// flags for controlling the behaviour when calling loadForms +enum class LoadFormsFlags { + Load = 0x0000, // default: simply load + Sync = 0x0000, // default: do in synchronous + Unload = 0x0001, // unload + Async = 0x0002 // do this async +}; +namespace o3tl { + template<> struct typed_flags<LoadFormsFlags> : is_typed_flags<LoadFormsFlags, 0x0003> {}; +} + +// a class iterating through all fields of a form which are bound to a field +// sub forms are ignored, grid columns (where the grid is a direct child of the form) are included +class FmXBoundFormFieldIterator : public ::comphelper::IndexAccessIterator +{ +public: + FmXBoundFormFieldIterator(const css::uno::Reference< css::uno::XInterface>& _rStartingPoint) : ::comphelper::IndexAccessIterator(_rStartingPoint) { } + +protected: + virtual bool ShouldHandleElement(const css::uno::Reference< css::uno::XInterface>& _rElement) override; + virtual bool ShouldStepInto(const css::uno::Reference< css::uno::XInterface>& _rContainer) const override; +}; + +class FmFormPage; +class FmFormPageImpl; + +struct FmLoadAction +{ + FmFormPage* pPage; + ImplSVEvent * nEventId; + LoadFormsFlags nFlags; + + FmLoadAction( FmFormPage* _pPage, LoadFormsFlags _nFlags, ImplSVEvent * _nEventId ) + :pPage( _pPage ), nEventId( _nEventId ), nFlags( _nFlags ) + { + } +}; + + +class SfxViewFrame; +typedef ::cppu::WeakComponentImplHelper< css::beans::XPropertyChangeListener + , css::container::XContainerListener + , css::view::XSelectionChangeListener + , css::form::XFormControllerListener + > FmXFormShell_BD_BASE; + + +class FmXFormShell_Base_Disambiguation : public FmXFormShell_BD_BASE +{ + using css::beans::XPropertyChangeListener::disposing; +protected: + FmXFormShell_Base_Disambiguation( ::osl::Mutex& _rMutex ); + using WeakComponentImplHelperBase::disposing; +}; + + +namespace svx +{ + class FmTextControlShell; +} + + +typedef FmXFormShell_Base_Disambiguation FmXFormShell_BASE; +typedef ::utl::ConfigItem FmXFormShell_CFGBASE; + +struct SdrViewEvent; +class FmFormShell; +class FmFormView; +class FmFormObj; +class UNLESS_MERGELIBS(SVXCORE_DLLPUBLIC) FmXFormShell final : public FmXFormShell_BASE + ,public FmXFormShell_CFGBASE + ,public svx::IControllerFeatureInvalidation +{ + friend class FmFormView; + friend class FmXFormView; + + class SuspendPropertyTracking; + friend class SuspendPropertyTracking; + + // timer for delayed mark + Timer m_aMarkTimer; + std::vector<SdrObject*> m_arrSearchedControls; + // We enable a permanent cursor for the grid we found a searched text, it's disabled in the next "found" event. + FmFormArray m_aSearchForms; + + struct SAL_DLLPRIVATE InvalidSlotInfo { + sal_uInt16 id; + sal_uInt8 flags; + InvalidSlotInfo(sal_uInt16 slotId, sal_uInt8 flgs) : id(slotId), flags(flgs) {}; + }; + std::vector<InvalidSlotInfo> m_arrInvalidSlots; + // we explicitly switch off the propbrw before leaving the design mode + // this flag tells us if we have to switch it on again when reentering + + css::form::NavigationBarMode m_eNavigate; // kind of navigation + + // since I want to mark an SdrObject when searching for the treatment of the "found", + // I get all relevant objects before yanking up of the search dialog + // (the array is thus only valid during the search process) + std::vector<long> m_arrRelativeGridColumn; + + ::osl::Mutex m_aMutex; + ImplSVEvent * m_nInvalidationEvent; + ImplSVEvent * m_nActivationEvent; + ::std::queue< FmLoadAction > + m_aLoadingPages; + + FmFormShell* m_pShell; + std::unique_ptr<svx::FmTextControlShell> m_pTextShell; + + svx::ControllerFeatures m_aActiveControllerFeatures; + svx::ControllerFeatures m_aNavControllerFeatures; + + // current form, controller + // only available in the alive mode + css::uno::Reference< css::form::runtime::XFormController > m_xActiveController; + css::uno::Reference< css::form::runtime::XFormController > m_xNavigationController; + css::uno::Reference< css::form::XForm > m_xActiveForm; + + // current container of a page + // only available in the design mode + css::uno::Reference< css::container::XIndexAccess> m_xForms; + + // the currently selected objects, as to be displayed in the property browser + InterfaceBag m_aCurrentSelection; + /// the currently selected form, or the form which all currently selected controls belong to, or <NULL/> + css::uno::Reference< css::form::XForm > m_xCurrentForm; + /// the last selection/marking of controls only. Necessary to implement the "Control properties" slot + InterfaceBag m_aLastKnownMarkedControls; + + + // And this is also for the 'found': When I find in GridControls, I need the column, + // but only get the number of the field corresponding to the number of the + // column + <offset>, where the offset depends on the position of the GridControl + // in the form. So here is a conversion. + css::uno::Reference< css::awt::XControlModel> m_xLastGridFound; + // the frame we live in + css::uno::Reference< css::frame::XFrame> m_xAttachedFrame; + // Administration of external form views (see the SID_FM_VIEW_AS_GRID-slot) + css::uno::Reference< css::frame::XController > m_xExternalViewController; // the controller for the external form view + css::uno::Reference< css::form::runtime::XFormController > m_xExtViewTriggerController; // the nav controller at the time the external display was triggered + css::uno::Reference< css::sdbc::XResultSet > m_xExternalDisplayedForm; // the form which the external view is based on + + mutable ::svxform::DocumentType + m_eDocumentType; /// the type of document we're living in + sal_Int16 m_nLockSlotInvalidation; + bool m_bHadPropertyBrowserInDesignMode : 1; + + bool m_bTrackProperties : 1; + // should I (or the owner of this impl class) take car of the update of the css::beans::Property-Browser? + + bool m_bUseWizards : 1; + + bool m_bDatabaseBar : 1; // is there a database bar + bool m_bInActivate : 1; // is a controller activated + bool m_bSetFocus : 1; // may the focus be changed over + bool m_bFilterMode : 1; // is a filter currently set to the controls + bool m_bChangingDesignMode:1; // sal_True within SetDesignMode + bool m_bPreparedClose : 1; // for the current modification state of the current form + // PrepareClose had been called and the user denied to save changes + bool m_bFirstActivation : 1; // has the shell ever been activated? + +public: + // attribute access + SAL_DLLPRIVATE const css::uno::Reference< css::frame::XFrame >& + getHostFrame_Lock() const { return m_xAttachedFrame; } + SAL_DLLPRIVATE const css::uno::Reference< css::sdbc::XResultSet >& + getExternallyDisplayedForm_Lock() const { return m_xExternalDisplayedForm; } + + SAL_DLLPRIVATE bool + didPrepareClose_Lock() const { return m_bPreparedClose; } + SAL_DLLPRIVATE void + didPrepareClose_Lock(bool bDid) { m_bPreparedClose = bDid; } + + SAL_DLLPRIVATE FmXFormShell(FmFormShell& _rShell, SfxViewFrame* _pViewFrame); + +private: + SAL_DLLPRIVATE virtual ~FmXFormShell() override; + +// EventListener + SAL_DLLPRIVATE virtual void SAL_CALL disposing(const css::lang::EventObject& Source) override; + +// css::container::XContainerListener + SAL_DLLPRIVATE virtual void SAL_CALL elementInserted(const css::container::ContainerEvent& rEvent) override; + SAL_DLLPRIVATE virtual void SAL_CALL elementReplaced(const css::container::ContainerEvent& rEvent) override; + SAL_DLLPRIVATE virtual void SAL_CALL elementRemoved(const css::container::ContainerEvent& rEvent) override; + +// XSelectionChangeListener + SAL_DLLPRIVATE virtual void SAL_CALL selectionChanged(const css::lang::EventObject& rEvent) override; + +// css::beans::XPropertyChangeListener + SAL_DLLPRIVATE virtual void SAL_CALL propertyChange(const css::beans::PropertyChangeEvent& evt) override; + +// css::form::XFormControllerListener + SAL_DLLPRIVATE virtual void SAL_CALL formActivated(const css::lang::EventObject& rEvent) override; + SAL_DLLPRIVATE virtual void SAL_CALL formDeactivated(const css::lang::EventObject& rEvent) override; + +// OComponentHelper + SAL_DLLPRIVATE virtual void SAL_CALL disposing() override; + +public: + SAL_DLLPRIVATE void EnableTrackProperties_Lock(bool bEnable) { m_bTrackProperties = bEnable; } + SAL_DLLPRIVATE bool IsTrackPropertiesEnabled_Lock() const { return m_bTrackProperties; } + + // activation handling + SAL_DLLPRIVATE void viewActivated_Lock(FmFormView& _rCurrentView, bool _bSyncAction = false); + SAL_DLLPRIVATE void viewDeactivated_Lock(FmFormView& _rCurrentView, bool _bDeactivateController = true); + + // IControllerFeatureInvalidation + SAL_DLLPRIVATE virtual void invalidateFeatures/*_NoLock*/( const ::std::vector< sal_Int32 >& _rFeatures ) override; + + SAL_DLLPRIVATE void ExecuteTabOrderDialog_Lock( // execute SID_FM_TAB_DIALOG + const css::uno::Reference< css::awt::XTabControllerModel >& _rxForForm + ); + + // stuff + SAL_DLLPRIVATE void AddElement_Lock(const css::uno::Reference< css::uno::XInterface>& Element); + SAL_DLLPRIVATE void RemoveElement_Lock(const css::uno::Reference< css::uno::XInterface>& Element); + + /** updates m_xForms, to be either <NULL/>, if we're in alive mode, or our current page's forms collection, + if in design mode + */ + SAL_DLLPRIVATE void UpdateForms_Lock(bool bInvalidate); + + SAL_DLLPRIVATE void ExecuteSearch_Lock(); // execute SID_FM_SEARCH + SAL_DLLPRIVATE void CreateExternalView_Lock(); // execute SID_FM_VIEW_AS_GRID + + SAL_DLLPRIVATE bool GetY2KState_Lock(sal_uInt16 & n); + SAL_DLLPRIVATE void SetY2KState_Lock(sal_uInt16 n); + +private: + // form handling + /// load or unload the forms on a page + SAL_DLLPRIVATE void loadForms_Lock( FmFormPage* _pPage, const LoadFormsFlags _nBehaviour ); + SAL_DLLPRIVATE void smartControlReset( const css::uno::Reference< css::container::XIndexAccess >& _rxModels ); + + + SAL_DLLPRIVATE void startListening_Lock(); + SAL_DLLPRIVATE void stopListening_Lock(); + + SAL_DLLPRIVATE css::uno::Reference< css::awt::XControl > + impl_getControl_Lock( + const css::uno::Reference< css::awt::XControlModel>& i_rxModel, + const FmFormObj& i_rKnownFormObj + ); + + // collects in strNames the names of all forms + SAL_DLLPRIVATE static void impl_collectFormSearchContexts_nothrow_Lock( + const css::uno::Reference< css::uno::XInterface>& _rxStartingPoint, + const OUString& _rCurrentLevelPrefix, + FmFormArray& _out_rForms, + ::std::vector< OUString >& _out_rNames ); + + /** checks whenever the instance is already disposed, if so, this is reported as assertion error (debug + builds only) and <TRUE/> is returned. + */ + SAL_DLLPRIVATE bool impl_checkDisposed_Lock() const; + +public: + // method for non design mode (alive mode) + SAL_DLLPRIVATE void setActiveController_Lock(const css::uno::Reference< css::form::runtime::XFormController>& _xController, bool _bNoSaveOldContent = false); + SAL_DLLPRIVATE const css::uno::Reference< css::form::runtime::XFormController>& getActiveController_Lock() const { return m_xActiveController; } + SAL_DLLPRIVATE const css::uno::Reference< css::form::runtime::XFormController>& getActiveInternalController_Lock() const { return m_xActiveController == m_xExternalViewController ? m_xExtViewTriggerController : m_xActiveController; } + SAL_DLLPRIVATE const css::uno::Reference< css::form::XForm>& getActiveForm_Lock() const { return m_xActiveForm; } + SAL_DLLPRIVATE const css::uno::Reference< css::form::runtime::XFormController>& getNavController_Lock() const { return m_xNavigationController; } + + SAL_DLLPRIVATE const svx::ControllerFeatures& getActiveControllerFeatures_Lock() const + { return m_aActiveControllerFeatures; } + SAL_DLLPRIVATE const svx::ControllerFeatures& getNavControllerFeatures_Lock() const + { return m_aNavControllerFeatures.isAssigned() ? m_aNavControllerFeatures : m_aActiveControllerFeatures; } + + /** announces a new "current selection" + @return + <TRUE/> if and only if the to-bet-set selection was different from the previous selection + */ + SAL_DLLPRIVATE bool setCurrentSelection_Lock(const InterfaceBag& rSelection); + + /** sets the new selection to the last known marked controls + */ + SAL_DLLPRIVATE bool selectLastMarkedControls_Lock(); + + /** retrieves the current selection + */ + void getCurrentSelection_Lock(InterfaceBag& /* [out] */ _rSelection) const; + + /** sets a new current selection as indicated by a mark list + @return + <TRUE/> if and only if the to-bet-set selection was different from the previous selection + */ + SAL_DLLPRIVATE bool setCurrentSelectionFromMark_Lock(const SdrMarkList& rMarkList); + + /// returns the currently selected form, or the form which all currently selected controls belong to, or <NULL/> + SAL_DLLPRIVATE const css::uno::Reference< css::form::XForm >& + getCurrentForm_Lock() const { return m_xCurrentForm; } + SAL_DLLPRIVATE void forgetCurrentForm_Lock(); + /// returns whether the last known marking contained only controls + SAL_DLLPRIVATE bool onlyControlsAreMarked_Lock() const { return !m_aLastKnownMarkedControls.empty(); } + + /// determines whether the current selection consists of exactly the given object + SAL_DLLPRIVATE bool isSolelySelected_Lock( + const css::uno::Reference< css::uno::XInterface >& _rxObject + ); + + /// handles a MouseButtonDown event of the FmFormView + SAL_DLLPRIVATE void handleMouseButtonDown_Lock( const SdrViewEvent& _rViewEvent ); + /// handles the request for showing the "Properties" + SAL_DLLPRIVATE void handleShowPropertiesRequest_Lock(); + + SAL_DLLPRIVATE bool hasForms_Lock() const { return m_xForms.is() && m_xForms->getCount() != 0; } + SAL_DLLPRIVATE bool hasDatabaseBar_Lock() const { return m_bDatabaseBar; } + + SAL_DLLPRIVATE void ShowSelectionProperties_Lock(bool bShow); + SAL_DLLPRIVATE bool IsPropBrwOpen_Lock() const; + + SAL_DLLPRIVATE void DetermineSelection_Lock(const SdrMarkList& rMarkList); + SAL_DLLPRIVATE void SetSelection_Lock(const SdrMarkList& rMarkList); + SAL_DLLPRIVATE void SetSelectionDelayed_Lock(); + + SAL_DLLPRIVATE void SetDesignMode_Lock(bool bDesign); + + SAL_DLLPRIVATE bool GetWizardUsing_Lock() const { return m_bUseWizards; } + SAL_DLLPRIVATE void SetWizardUsing_Lock(bool _bUseThem); + + // setting the filter mode + SAL_DLLPRIVATE bool isInFilterMode_Lock() const { return m_bFilterMode; } + SAL_DLLPRIVATE void startFiltering_Lock(); + SAL_DLLPRIVATE void stopFiltering_Lock(bool bSave); + + // a menu that contains all ControlConversion entries + SAL_DLLPRIVATE static std::unique_ptr<VclBuilder> GetConversionMenu_Lock(); + + /// checks whether a given control conversion slot can be applied to the current selection + SAL_DLLPRIVATE bool canConvertCurrentSelectionToControl_Lock(const OString& rIdent); + /// enables or disables all conversion slots in a menu, according to the current selection + SAL_DLLPRIVATE void checkControlConversionSlotsForCurrentSelection_Lock(Menu& rMenu); + /// executes a control conversion slot for a given object + SAL_DLLPRIVATE bool executeControlConversionSlot_Lock(const css::uno::Reference< css::form::XFormComponent >& _rxObject, const OString& rIdent); + /** executes a control conversion slot for the current selection + @precond canConvertCurrentSelectionToControl( <arg>_nSlotId</arg> ) must return <TRUE/> + */ + SAL_DLLPRIVATE void executeControlConversionSlot_Lock(const OString& rIdent); + /// checks whether the given slot id denotes a control conversion slot + SAL_DLLPRIVATE static bool isControlConversionSlot(const OString& rIdent); + + SAL_DLLPRIVATE void ExecuteTextAttribute_Lock(SfxRequest& _rReq); + SAL_DLLPRIVATE void GetTextAttributeState_Lock(SfxItemSet& _rSet); + SAL_DLLPRIVATE bool IsActiveControl_Lock(bool _bCountRichTextOnly) const; + SAL_DLLPRIVATE void ForgetActiveControl_Lock(); + SAL_DLLPRIVATE void SetControlActivationHandler_Lock(const Link<LinkParamNone*,void>& _rHdl); + + /// classifies our host document + SAL_DLLPRIVATE ::svxform::DocumentType getDocumentType_Lock() const; + SAL_DLLPRIVATE bool isEnhancedForm_Lock() const; + + /// determines whether our host document is currently read-only + SAL_DLLPRIVATE bool IsReadonlyDoc_Lock() const; + + // Setting the curObject/selObject/curForm is delayed (SetSelectionDelayed). With the + // following functions this can be inquired/enforced. + SAL_DLLPRIVATE inline bool IsSelectionUpdatePending_Lock() const; + SAL_DLLPRIVATE void ForceUpdateSelection_Lock(); + + SAL_DLLPRIVATE css::uno::Reference< css::frame::XModel> getContextDocument_Lock() const; + SAL_DLLPRIVATE css::uno::Reference< css::form::XForm> getInternalForm_Lock(const css::uno::Reference< css::form::XForm>& _xForm) const; + SAL_DLLPRIVATE css::uno::Reference< css::sdbc::XResultSet> getInternalForm_Lock(const css::uno::Reference< css::sdbc::XResultSet>& _xForm) const; + // if the form belongs to the controller (extern) displaying a grid, the according internal form will + // be displayed, _xForm else + + // check if the current control of the active controller has the focus + SAL_DLLPRIVATE bool HasControlFocus_Lock() const; + +private: + DECL_DLLPRIVATE_LINK(OnFoundData_Lock, FmFoundRecordInformation&, void); + DECL_DLLPRIVATE_LINK(OnCanceledNotFound_Lock, FmFoundRecordInformation&, void); + DECL_DLLPRIVATE_LINK(OnSearchContextRequest_Lock, FmSearchContext&, sal_uInt32); + DECL_DLLPRIVATE_LINK(OnTimeOut_Lock, Timer*, void); + DECL_DLLPRIVATE_LINK(OnFirstTimeActivation_Lock, void*, void); + DECL_DLLPRIVATE_LINK(OnFormsCreated_Lock, FmFormPageImpl&, void); + + SAL_DLLPRIVATE void LoopGrids_Lock(LoopGridsSync nSync, LoopGridsFlags nWhat = LoopGridsFlags::NONE); + + // invalidation of slots + SAL_DLLPRIVATE void InvalidateSlot_Lock(sal_Int16 nId, bool bWithId); + SAL_DLLPRIVATE void UpdateSlot_Lock(sal_Int16 nId); + // locking the invalidation - if the internal locking counter goes to 0, all accumulated slots + // are invalidated (asynchronously) + SAL_DLLPRIVATE void LockSlotInvalidation_Lock(bool bLock); + + DECL_DLLPRIVATE_LINK(OnInvalidateSlots_Lock, void*, void); + + SAL_DLLPRIVATE void CloseExternalFormViewer_Lock(); + // closes the task-local beamer displaying a grid view for a form + + // ConfigItem related stuff + SAL_DLLPRIVATE virtual void Notify( const css::uno::Sequence< OUString >& _rPropertyNames) override; + SAL_DLLPRIVATE void implAdjustConfigCache_Lock(); + + SAL_DLLPRIVATE css::uno::Reference< css::awt::XControlContainer > + getControlContainerForView_Lock() const; + + /** finds and sets a default for m_xCurrentForm, if it is currently NULL + */ + SAL_DLLPRIVATE void impl_defaultCurrentForm_nothrow_Lock(); + + /** sets m_xCurrentForm to the provided form, and updates everything which + depends on the current form + */ + SAL_DLLPRIVATE void impl_updateCurrentForm_Lock( const css::uno::Reference< css::form::XForm >& _rxNewCurForm ); + + /** adds or removes ourself as XEventListener at m_xActiveController + */ + SAL_DLLPRIVATE void impl_switchActiveControllerListening_Lock(const bool _bListen); + + /** add an element + */ + SAL_DLLPRIVATE void impl_AddElement_nothrow(const css::uno::Reference< css::uno::XInterface>& Element); + + /** remove an element + */ + SAL_DLLPRIVATE void impl_RemoveElement_nothrow_Lock(const css::uno::Reference< css::uno::XInterface>& Element); + + SAL_DLLPRIVATE virtual void ImplCommit() override; + + // asynchronous cursor actions/navigation slot handling + +public: + /** execute the given form slot + <p>Warning. Only a small set of slots implemented currently.</p> + @param _nSlot + the slot to execute + */ + SAL_DLLPRIVATE void ExecuteFormSlot_Lock(sal_Int32 _nSlot); + + /** determines whether the current form slot is currently enabled + */ + SAL_DLLPRIVATE bool IsFormSlotEnabled( sal_Int32 _nSlot, css::form::runtime::FeatureState* _pCompleteState ); + + SAL_DLLPRIVATE static OString SlotToIdent(sal_uInt16 nSlot); + +private: + DECL_DLLPRIVATE_LINK( OnLoadForms_Lock, void*, void ); +}; + + +inline bool FmXFormShell::IsSelectionUpdatePending_Lock() const +{ + return m_aMarkTimer.IsActive(); +} + + +// = An iterator that, emanating from an interface, looks for an object whose +// = css::beans::Property-Set has a ControlSource and a BoundField property, the +// = latter having a non-NULL value. If the interface itself does not meet this +// = condition, it is tested whether it is a container (that is, has a +// = css::container::XIndexAccess), then it is descended there and the same tried +// = for each element of the container (again possibly with descent). If any +// = object thereby has the required property, the part with the container test +// = for that object is omitted. +// = + +class SearchableControlIterator : public ::comphelper::IndexAccessIterator +{ + OUString m_sCurrentValue; + // the current value of the ControlSource css::beans::Property + +public: + const OUString& getCurrentValue() const { return m_sCurrentValue; } + +public: + SearchableControlIterator(css::uno::Reference< css::uno::XInterface> const & xStartingPoint); + + virtual bool ShouldHandleElement(const css::uno::Reference< css::uno::XInterface>& rElement) override; + virtual bool ShouldStepInto(const css::uno::Reference< css::uno::XInterface>& xContainer) const override; + virtual void Invalidate() override { IndexAccessIterator::Invalidate(); m_sCurrentValue.clear(); } +}; + +#endif // INCLUDED_SVX_SOURCE_INC_FMSHIMP_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/inc/fmslotinvalidator.hxx b/svx/source/inc/fmslotinvalidator.hxx new file mode 100644 index 000000000..aa000a4ea --- /dev/null +++ b/svx/source/inc/fmslotinvalidator.hxx @@ -0,0 +1,33 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_SVX_SOURCE_INC_FMSLOTINVALIDATOR_HXX +#define INCLUDED_SVX_SOURCE_INC_FMSLOTINVALIDATOR_HXX + +#include <sal/types.h> + +namespace svx +{ + typedef sal_uInt16 SfxSlotId; +} + +#endif // INCLUDED_SVX_SOURCE_INC_FMSLOTINVALIDATOR_HXX + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/inc/fmtextcontroldialogs.hxx b/svx/source/inc/fmtextcontroldialogs.hxx new file mode 100644 index 000000000..613f17bf5 --- /dev/null +++ b/svx/source/inc/fmtextcontroldialogs.hxx @@ -0,0 +1,50 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_SVX_SOURCE_INC_FMTEXTCONTROLDIALOGS_HXX +#define INCLUDED_SVX_SOURCE_INC_FMTEXTCONTROLDIALOGS_HXX + +#include <sfx2/tabdlg.hxx> +#include <editeng/flstitem.hxx> + +namespace svx +{ + + class TextControlCharAttribDialog : public SfxTabDialogController + { + private: + SvxFontListItem m_aFontList; + + public: + TextControlCharAttribDialog(weld::Window* pParent, const SfxItemSet& rCoreSet, const SvxFontListItem& rFontList); + + protected: + virtual void PageCreated(const OString& rId, SfxTabPage& _rPage) override; + }; + + class TextControlParaAttribDialog : public SfxTabDialogController + { + public: + TextControlParaAttribDialog(weld::Window* pParent, const SfxItemSet& rCoreSet); + }; +} + +#endif // INCLUDED_SVX_SOURCE_INC_FMTEXTCONTROLDIALOGS_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/inc/fmtextcontrolfeature.hxx b/svx/source/inc/fmtextcontrolfeature.hxx new file mode 100644 index 000000000..0acc884bc --- /dev/null +++ b/svx/source/inc/fmtextcontrolfeature.hxx @@ -0,0 +1,93 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_SVX_SOURCE_INC_FMTEXTCONTROLFEATURE_HXX +#define INCLUDED_SVX_SOURCE_INC_FMTEXTCONTROLFEATURE_HXX + +#include <com/sun/star/beans/PropertyValue.hpp> +#include <com/sun/star/frame/XDispatch.hpp> +#include <com/sun/star/frame/XStatusListener.hpp> +#include <com/sun/star/util/URL.hpp> +#include <cppuhelper/implbase.hxx> +#include "fmslotinvalidator.hxx" + + +namespace svx +{ + class FmTextControlShell; + + typedef ::cppu::WeakImplHelper < css::frame::XStatusListener + > FmTextControlFeature_Base; + + class FmTextControlFeature : public FmTextControlFeature_Base + { + private: + css::uno::Reference< css::frame::XDispatch > + m_xDispatcher; + css::util::URL m_aFeatureURL; + css::uno::Any m_aFeatureState; + SfxSlotId m_nSlotId; + FmTextControlShell* m_pInvalidator; + bool m_bFeatureEnabled; + + public: + /** constructs a FmTextControlFeature object + @param _rxDispatcher + the dispatcher which the instance should work with + @param _rFeatureURL + the URL which the instance should be responsible for + */ + FmTextControlFeature( + const css::uno::Reference< css::frame::XDispatch >& _rxDispatcher, + const css::util::URL& _rFeatureURL, + SfxSlotId _nId, + FmTextControlShell* _pInvalidator + ); + + /// determines whether the feature we're responsible for is currently enabled + bool isFeatureEnabled( ) const { return m_bFeatureEnabled; } + const css::uno::Any& getFeatureState( ) const { return m_aFeatureState; } + + /** dispatches the feature URL to the dispatcher + */ + void dispatch() const; + + /** dispatches the feature URL to the dispatcher, with passing the given arguments + */ + void dispatch( const css::uno::Sequence< css::beans::PropertyValue >& _rArgs ) const; + + /// releases any resources associated with this instance + void dispose(); + + protected: + virtual ~FmTextControlFeature() override; + + protected: + // XStatusListener + virtual void SAL_CALL statusChanged( const css::frame::FeatureStateEvent& State ) override; + virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override; + }; + + +} + + +#endif // INCLUDED_SVX_SOURCE_INC_FMTEXTCONTROLFEATURE_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/inc/fmtextcontrolshell.hxx b/svx/source/inc/fmtextcontrolshell.hxx new file mode 100644 index 000000000..42a61dea2 --- /dev/null +++ b/svx/source/inc/fmtextcontrolshell.hxx @@ -0,0 +1,202 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_SVX_SOURCE_INC_FMTEXTCONTROLSHELL_HXX +#define INCLUDED_SVX_SOURCE_INC_FMTEXTCONTROLSHELL_HXX + +#include <com/sun/star/frame/XDispatchProvider.hpp> +#include <com/sun/star/awt/FocusEvent.hpp> +#include <com/sun/star/awt/XTextComponent.hpp> +#include <com/sun/star/form/runtime/XFormController.hpp> +#include <com/sun/star/awt/XControl.hpp> +#include <com/sun/star/util/XURLTransformer.hpp> +#include <rtl/ref.hxx> +#include <tools/link.hxx> +#include <vcl/timer.hxx> +#include "fmslotinvalidator.hxx" + +#include <vector> +#include <map> + +class SfxRequest; +class SfxItemSet; +class SfxAllItemSet; +class SfxBindings; +class SfxViewFrame; +class SfxApplication; + + +namespace svx +{ + + + class FmFocusListenerAdapter; + class FmTextControlFeature; + class FmMouseListenerAdapter; + + class IFocusObserver + { + public: + virtual void focusGained( const css::awt::FocusEvent& _rEvent ) = 0; + virtual void focusLost( const css::awt::FocusEvent& _rEvent ) = 0; + + protected: + ~IFocusObserver() {} + }; + + + //= IFocusObserver + + class IContextRequestObserver + { + public: + virtual void contextMenuRequested() = 0; + + protected: + ~IContextRequestObserver() {} + }; + + class FmTextControlShell :public IFocusObserver + ,public IContextRequestObserver + { + private: + css::uno::Reference< css::util::XURLTransformer > m_xURLTransformer; + css::uno::Reference< css::awt::XControl > m_xActiveControl; + css::uno::Reference< css::awt::XTextComponent > m_xActiveTextComponent; + css::uno::Reference< css::form::runtime::XFormController > m_xActiveController; +#ifndef DONT_REMEMBER_LAST_CONTROL + // without this define, m_xActiveControl remembers the *last* active control, even + // if it, in the meantime, already lost the focus + bool m_bActiveControl; + // so we need an additional boolean flag telling whether the active control + // is really focused +#endif + bool m_bActiveControlIsReadOnly; + bool m_bActiveControlIsRichText; + + // listening at all controls of the active controller for focus changes + typedef rtl::Reference<FmFocusListenerAdapter> FocusListenerAdapter; + typedef ::std::vector< FocusListenerAdapter > FocusListenerAdapters; + FocusListenerAdapters m_aControlObservers; + + typedef rtl::Reference<FmMouseListenerAdapter> MouseListenerAdapter; + MouseListenerAdapter m_aContextMenuObserver; + + // translating between "slots" of the framework and "features" of the active control + typedef rtl::Reference<FmTextControlFeature> ControlFeature; + typedef ::std::map< SfxSlotId, ControlFeature > ControlFeatures; + ControlFeatures m_aControlFeatures; + + SfxViewFrame* m_pViewFrame; + // invalidating slots + SfxBindings& m_rBindings; + Link<LinkParamNone*,void> m_aControlActivationHandler; + AutoTimer m_aClipboardInvalidation; + bool m_bNeedClipboardInvalidation; + + public: + FmTextControlShell( SfxViewFrame* _pFrame ); + virtual ~FmTextControlShell(); + + // clean up any resources associated with this instance + void dispose(); + + void ExecuteTextAttribute( SfxRequest& _rReq ); + void GetTextAttributeState( SfxItemSet& _rSet ); + bool IsActiveControl( bool _bCountRichTextOnly = false ) const; + void ForgetActiveControl(); + void SetControlActivationHandler( const Link<LinkParamNone*,void>& _rHdl ) { m_aControlActivationHandler = _rHdl; } + + /** to be called when a form in our document has been activated + */ + void formActivated( const css::uno::Reference< css::form::runtime::XFormController >& _rxController ); + /** to be called when a form in our document has been deactivated + */ + void formDeactivated( const css::uno::Reference< css::form::runtime::XFormController >& _rxController ); + + /** notifies the instance that the design mode has changed + */ + void designModeChanged(); + + void Invalidate( SfxSlotId _nSlot ); + + protected: + // IFocusObserver + virtual void focusGained( const css::awt::FocusEvent& _rEvent ) override; + virtual void focusLost( const css::awt::FocusEvent& _rEvent ) override; + + // IContextRequestObserver + virtual void contextMenuRequested() override; + + enum AttributeSet { eCharAttribs, eParaAttribs }; + void executeAttributeDialog( AttributeSet _eSet, SfxRequest& _rReq ); + void executeSelectAll( ); + void executeClipboardSlot( SfxSlotId _nSlot ); + + private: + bool isControllerListening() const { return !m_aControlObservers.empty(); } + + FmTextControlFeature* + implGetFeatureDispatcher( + const css::uno::Reference< css::frame::XDispatchProvider >& _rxProvider, + SfxApplication const * _pApplication, + SfxSlotId _nSlot + ); + + // fills the given structure with dispatchers for the given slots, for the given control + void fillFeatureDispatchers( + const css::uno::Reference< css::awt::XControl >& _rxControl, + SfxSlotId* _pZeroTerminatedSlots, + ControlFeatures& _rDispatchers + ); + + /// creates SfxPoolItes for all features in the given set, and puts them into the given SfxAllItemSet + static void transferFeatureStatesToItemSet( + ControlFeatures& _rDispatchers, + SfxAllItemSet& _rSet, + bool _bTranslateLatin + ); + + /// to be called when a control has been activated + void controlActivated( const css::uno::Reference< css::awt::XControl >& _rxControl ); + /// to be called when the currently active control has been deactivated + void controlDeactivated( ); + + void implClearActiveControlRef(); + + /** starts listening at all controls of the given controller for focus events + @precond + we don't have an active controller currently + */ + void startControllerListening( const css::uno::Reference< css::form::runtime::XFormController >& _rxController ); + /** stops listening at the active controller + @precond + we have an active controller currently + */ + void stopControllerListening( ); + + DECL_LINK( OnInvalidateClipboard, Timer*, void ); + }; + + +} + + +#endif // INCLUDED_SVX_SOURCE_INC_FMTEXTCONTROLSHELL_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/inc/fmundo.hxx b/svx/source/inc/fmundo.hxx new file mode 100644 index 000000000..d914a0e74 --- /dev/null +++ b/svx/source/inc/fmundo.hxx @@ -0,0 +1,199 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_SVX_SOURCE_INC_FMUNDO_HXX +#define INCLUDED_SVX_SOURCE_INC_FMUNDO_HXX + +#include <svx/svdundo.hxx> +#include <svx/svdouno.hxx> +#include "fmscriptingenv.hxx" + + +#include <com/sun/star/util/XModifyListener.hpp> +#include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/beans/XPropertyChangeListener.hpp> +#include <com/sun/star/beans/PropertyChangeEvent.hpp> +#include <com/sun/star/script/ScriptEventDescriptor.hpp> +#include <com/sun/star/container/XIndexContainer.hpp> +#include <com/sun/star/container/XContainerListener.hpp> +#include <com/sun/star/container/ContainerEvent.hpp> +#include <com/sun/star/container/XNameContainer.hpp> +#include <cppuhelper/implbase.hxx> + + +#include <svl/lstner.hxx> + +class FmFormModel; +class FmFormObj; +class SdrObject; + +class FmUndoPropertyAction: public SdrUndoAction +{ + css::uno::Reference< css::beans::XPropertySet> xObj; + OUString aPropertyName; + css::uno::Any aNewValue; + css::uno::Any aOldValue; + +public: + FmUndoPropertyAction(FmFormModel& rMod, const css::beans::PropertyChangeEvent& evt); + + virtual void Undo() override; + virtual void Redo() override; + + virtual OUString GetComment() const override; + +}; + +class FmUndoContainerAction final : public SdrUndoAction +{ +public: + enum Action + { + Inserted = 1, + Removed = 2 + }; + + FmUndoContainerAction(FmFormModel& rMod, + Action _eAction, + const css::uno::Reference< css::container::XIndexContainer >& xCont, + const css::uno::Reference< css::uno::XInterface >& xElem, + sal_Int32 nIdx); + virtual ~FmUndoContainerAction() override; + + virtual void Undo() override; + virtual void Redo() override; + + static void DisposeElement( const css::uno::Reference< css::uno::XInterface >& xElem ); + +private: + void implReInsert( ); + void implReRemove( ); + + css::uno::Reference< css::container::XIndexContainer > + m_xContainer; // container which the action applies to + css::uno::Reference< css::uno::XInterface > + m_xElement; // object not owned by the action + css::uno::Reference< css::uno::XInterface > + m_xOwnElement; // object owned by the action + sal_Int32 m_nIndex; // index of the object within it's container + css::uno::Sequence< css::script::ScriptEventDescriptor > + m_aEvents; // events of the object + Action m_eAction; +}; + +class FmUndoModelReplaceAction : public SdrUndoAction +{ + css::uno::Reference< css::awt::XControlModel> m_xReplaced; + SdrUnoObj* m_pObject; + +public: + FmUndoModelReplaceAction(FmFormModel& rMod, SdrUnoObj* pObject, const css::uno::Reference< css::awt::XControlModel>& xReplaced); + virtual ~FmUndoModelReplaceAction() override; + + virtual void Undo() override; + virtual void Redo() override { Undo(); } + + virtual OUString GetComment() const override; + + static void DisposeElement( const css::uno::Reference< css::awt::XControlModel>& xReplaced ); +}; + + +class FmXUndoEnvironment final + : public ::cppu::WeakImplHelper< css::beans::XPropertyChangeListener + , css::container::XContainerListener + , css::util::XModifyListener + > + , public SfxListener +{ +public: + FmXUndoEnvironment(FmFormModel& _rModel); + virtual ~FmXUndoEnvironment() override; + + // UNO binding + // SMART_UNO_DECLARATION(FmXUndoEnvironment, ::cppu::OWeakObject); + // virtual sal_Bool queryInterface(UsrUik, css::uno::Reference< css::uno::XInterface>&); + // virtual css::uno::Sequence< css::uno::Reference< css::reflection::XIdlClass>> getIdlClasses(); + + void Lock() { osl_atomic_increment( &m_Locks ); } + void UnLock() { osl_atomic_decrement( &m_Locks ); } + bool IsLocked() const { return m_Locks != 0; } + + // access control + struct Accessor { friend class FmFormModel; private: Accessor() { } }; + + // addition and removal of form collections + void AddForms( const css::uno::Reference< css::container::XNameContainer>& rForms ); + void RemoveForms( const css::uno::Reference< css::container::XNameContainer>& rForms ); + + // readonly-ness + void SetReadOnly( bool bRead, const Accessor& ) { bReadOnly = bRead; } + bool IsReadOnly() const {return bReadOnly;} + + // Methods for assigning controls to forms, + // used by the page and the undo environment + void Inserted(SdrObject* pObj); + void Removed(SdrObject* pObj); + + static void Inserted(FmFormObj* pObj); + static void Removed(FmFormObj* pObj); + +private: + // XEventListener + virtual void SAL_CALL disposing(const css::lang::EventObject& Source) override; + + // XPropertyChangeListener + virtual void SAL_CALL propertyChange(const css::beans::PropertyChangeEvent& evt) override; + + // XContainerListener + virtual void SAL_CALL elementInserted(const css::container::ContainerEvent& rEvent) override; + virtual void SAL_CALL elementReplaced(const css::container::ContainerEvent& rEvent) override; + virtual void SAL_CALL elementRemoved(const css::container::ContainerEvent& rEvent) override; + + // XModifyListener + virtual void SAL_CALL modified( const css::lang::EventObject& aEvent ) override; + + void ModeChanged(); + void dispose(); + + virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override; + + void AddElement(const css::uno::Reference< css::uno::XInterface>& Element); + void RemoveElement(const css::uno::Reference< css::uno::XInterface>& Element); + void TogglePropertyListening(const css::uno::Reference< css::uno::XInterface>& Element); + + void implSetModified(); + + void switchListening( const css::uno::Reference< css::container::XIndexContainer >& _rxContainer, bool _bStartListening ); + void switchListening( const css::uno::Reference< css::uno::XInterface >& _rxObject, bool _bStartListening ); + + FmFormModel& rModel; + void* m_pPropertySetCache; + ::rtl::Reference<svxform::FormScriptingEnvironment> m_pScriptingEnv; + oslInterlockedCount m_Locks; + ::osl::Mutex m_aMutex; + bool bReadOnly; + bool m_bDisposed; + css::uno::Reference< css::script::XScriptListener > m_vbaListener; +}; + + +#endif // INCLUDED_SVX_SOURCE_INC_FMUNDO_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/inc/fmurl.hxx b/svx/source/inc/fmurl.hxx new file mode 100644 index 000000000..a354eae59 --- /dev/null +++ b/svx/source/inc/fmurl.hxx @@ -0,0 +1,53 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_SVX_SOURCE_INC_FMURL_HXX +#define INCLUDED_SVX_SOURCE_INC_FMURL_HXX + +#define FMURL_FORM_POSITION ".uno:FormController/positionForm" +#define FMURL_FORM_RECORDCOUNT ".uno:FormController/RecordCount" +#define FMURL_RECORD_MOVEFIRST ".uno:FormController/moveToFirst" +#define FMURL_RECORD_MOVEPREV ".uno:FormController/moveToPrev" +#define FMURL_RECORD_MOVENEXT ".uno:FormController/moveToNext" +#define FMURL_RECORD_MOVELAST ".uno:FormController/moveToLast" +#define FMURL_RECORD_MOVETONEW ".uno:FormController/moveToNew" +#define FMURL_RECORD_UNDO ".uno:FormController/undoRecord" +#define FMURL_RECORD_SAVE ".uno:FormController/saveRecord" +#define FMURL_RECORD_DELETE ".uno:FormController/deleteRecord" +#define FMURL_FORM_REFRESH ".uno:FormController/refreshForm" +#define FMURL_FORM_REFRESH_CURRENT_CONTROL ".uno:FormController/refreshCurrentControl" +#define FMURL_FORM_SORT_UP ".uno:FormController/sortUp" +#define FMURL_FORM_SORT_DOWN ".uno:FormController/sortDown" +#define FMURL_FORM_SORT ".uno:FormController/sort" +#define FMURL_FORM_AUTO_FILTER ".uno:FormController/autoFilter" +#define FMURL_FORM_FILTER ".uno:FormController/filter" +#define FMURL_FORM_APPLY_FILTER ".uno:FormController/applyFilter" +#define FMURL_FORM_REMOVE_FILTER ".uno:FormController/removeFilterOrder" +#define FMURL_CONFIRM_DELETION ".uno:FormSlots/ConfirmDeletion" +#define FMURL_COMPONENT_FORMGRIDVIEW ".component:DB/FormGridView" +#define FMURL_GRIDVIEW_CLEARVIEW ".uno:FormSlots/ClearView" +#define FMURL_GRIDVIEW_ADDCOLUMN ".uno:FormSlots/AddGridColumn" +#define FMURL_GRIDVIEW_ATTACHTOFORM ".uno:FormSlots/AttachToForm" +#define FMARG_ATTACHTO_MASTERFORM "MasterForm" +#define FMARG_ADDCOL_COLUMNTYPE "ColumnType" +#define FMARG_ADDCOL_COLUMNPOS "ColumnPosition" + +#endif // INCLUDED_SVX_SOURCE_INC_FMURL_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/inc/fmvwimp.hxx b/svx/source/inc/fmvwimp.hxx new file mode 100644 index 000000000..e90fcd217 --- /dev/null +++ b/svx/source/inc/fmvwimp.hxx @@ -0,0 +1,302 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_SVX_SOURCE_INC_FMVWIMP_HXX +#define INCLUDED_SVX_SOURCE_INC_FMVWIMP_HXX + +#include <sal/config.h> + +#include <map> +#include <memory> + +#include <svx/svdmark.hxx> +#include <svx/svdobj.hxx> +#include "fmdocumentclassification.hxx" + +#include <com/sun/star/form/XForm.hpp> +#include <com/sun/star/container/XIndexAccess.hpp> +#include <com/sun/star/form/runtime/XFormController.hpp> +#include <com/sun/star/form/runtime/XFormControllerContext.hpp> +#include <com/sun/star/container/XContainerListener.hpp> +#include <com/sun/star/container/ContainerEvent.hpp> +#include <com/sun/star/awt/XFocusListener.hpp> +#include <com/sun/star/sdb/SQLErrorEvent.hpp> +#include <com/sun/star/sdbc/XDataSource.hpp> +#include <com/sun/star/uno/XComponentContext.hpp> + +#include <tools/link.hxx> +#include <cppuhelper/implbase.hxx> +#include <rtl/ref.hxx> +#include <vcl/vclptr.hxx> + +class SdrPageWindow; + +class SdrObject; +class FmFormObj; +class FmFormModel; +class FmFormView; +class FmFormShell; +namespace vcl { class Window; } +class OutputDevice; +class SdrUnoObj; +struct ImplSVEvent; +enum class SdrInventor : sal_uInt32; + +namespace com::sun::star { + namespace awt { + class XControl; + class XWindow; + } + namespace beans { + class XPropertySet; + } + namespace util { + class XNumberFormats; + } +} + +class FmXFormView; + +namespace svx { + class ODataAccessDescriptor; + struct OXFormsDescriptor; +} + + +// FormViewPageWindowAdapter + +typedef ::cppu::WeakImplHelper < css::container::XIndexAccess + , css::form::runtime::XFormControllerContext + > FormViewPageWindowAdapter_Base; + +class FormViewPageWindowAdapter final : public FormViewPageWindowAdapter_Base +{ + friend class FmXFormView; + + ::std::vector< css::uno::Reference< css::form::runtime::XFormController > > m_aControllerList; + css::uno::Reference< css::awt::XControlContainer > m_xControlContainer; + css::uno::Reference<css::uno::XComponentContext> m_xContext; + FmXFormView* m_pViewImpl; + VclPtr<vcl::Window> m_pWindow; + +public: + FormViewPageWindowAdapter( const css::uno::Reference<css::uno::XComponentContext>& _rContext, + const SdrPageWindow&, FmXFormView* pView); + //const SdrPageViewWinRec*, FmXFormView* pView); + + // XElementAccess + virtual css::uno::Type SAL_CALL getElementType() override; + virtual sal_Bool SAL_CALL hasElements() override; + + // XIndexAccess + virtual sal_Int32 SAL_CALL getCount() override; + virtual css::uno::Any SAL_CALL getByIndex(sal_Int32 Index) override; + + // XFormControllerContext + virtual void SAL_CALL makeVisible( const css::uno::Reference< css::awt::XControl >& Control ) override; + + const ::std::vector< css::uno::Reference< css::form::runtime::XFormController > >& GetList() const {return m_aControllerList;} + +private: + virtual ~FormViewPageWindowAdapter() override; + + css::uno::Reference< css::form::runtime::XFormController > getController( const css::uno::Reference< css::form::XForm >& xForm ) const; + void setController( + const css::uno::Reference< css::form::XForm >& xForm, + const css::uno::Reference< css::form::runtime::XFormController >& _rxParentController ); + const css::uno::Reference< css::awt::XControlContainer >& getControlContainer() const { return m_xControlContainer; } + void updateTabOrder( const css::uno::Reference< css::form::XForm >& _rxForm ); + void dispose(); + vcl::Window* getWindow() const {return m_pWindow;} +}; + +typedef ::rtl::Reference< FormViewPageWindowAdapter > PFormViewPageWindowAdapter; +typedef ::std::vector< PFormViewPageWindowAdapter > PageWindowAdapterList; +typedef ::std::set< css::uno::Reference< css::form::XForm > > SetOfForms; +typedef ::std::map< css::uno::Reference< css::awt::XControlContainer >, SetOfForms > MapControlContainerToSetOfForms; +class SdrModel; + +class FmXFormView : public ::cppu::WeakImplHelper< + css::form::XFormControllerListener, + css::awt::XFocusListener, + css::container::XContainerListener> +{ + friend class FmFormView; + friend class FmFormShell; + friend class FmXFormShell; + friend class FormViewPageWindowAdapter; + class ObjectRemoveListener; + friend class ObjectRemoveListener; + + css::uno::Reference< css::awt::XWindow> m_xWindow; + css::uno::Reference< css::beans::XPropertySet > m_xLastCreatedControlModel; + + FmFormObj* m_pMarkedGrid; + FmFormView* m_pView; + ImplSVEvent * m_nActivationEvent; + ImplSVEvent * m_nErrorMessageEvent; // event for an asynchronous error message. See also m_aAsyncError + ImplSVEvent * m_nAutoFocusEvent; // event for asynchronously setting the focus to a control + ImplSVEvent * m_nControlWizardEvent; // event for asynchronously setting the focus to a control + + css::sdb::SQLErrorEvent + m_aAsyncError; // error event which is to be displayed asyn. See m_nErrorMessageEvent. + + PageWindowAdapterList + m_aPageWindowAdapters; // to be filled in alive mode only + MapControlContainerToSetOfForms + m_aNeedTabOrderUpdate; + + // list of selected objects, used for restoration when switching from Alive to DesignMode + SdrMarkList m_aMark; + std::unique_ptr<ObjectRemoveListener> + m_pWatchStoredList; + + bool m_bFirstActivation; + bool m_isTabOrderUpdateSuspended; + + FmFormShell* GetFormShell() const; + +protected: + FmXFormView( FmFormView* _pView ); + virtual ~FmXFormView() override; + + void saveMarkList(); + void restoreMarkList( SdrMarkList& _rRestoredMarkList ); + void stopMarkListWatching(); + void startMarkListWatching(); + + void notifyViewDying( ); + // notifies this impl class that the anti-impl instance (m_pView) is going to die + +public: + // UNO binding + +// css::lang::XEventListener + virtual void SAL_CALL disposing(const css::lang::EventObject& Source) override; + +// css::container::XContainerListener + virtual void SAL_CALL elementInserted(const css::container::ContainerEvent& rEvent) override; + virtual void SAL_CALL elementReplaced(const css::container::ContainerEvent& rEvent) override; + virtual void SAL_CALL elementRemoved(const css::container::ContainerEvent& rEvent) override; + +// css::form::XFormControllerListener + virtual void SAL_CALL formActivated(const css::lang::EventObject& rEvent) override; + virtual void SAL_CALL formDeactivated(const css::lang::EventObject& rEvent) override; + + // XFocusListener + virtual void SAL_CALL focusGained( const css::awt::FocusEvent& e ) override; + virtual void SAL_CALL focusLost( const css::awt::FocusEvent& e ) override; + + FmFormView* getView() const {return m_pView;} + PFormViewPageWindowAdapter findWindow( const css::uno::Reference< css::awt::XControlContainer >& _rxCC ) const; + + css::uno::Reference< css::form::runtime::XFormController > + getFormController( const css::uno::Reference< css::form::XForm >& _rxForm, const OutputDevice& _rDevice ) const; + + // activation handling + bool hasEverBeenActivated( ) const { return !m_bFirstActivation; } + void setHasBeenActivated( ) { m_bFirstActivation = false; } + + void onFirstViewActivation( const FmFormModel* _pDocModel ); + + /** suspends the calls to activateTabOrder, which normally happen whenever for any ControlContainer of the view, + new controls are inserted. Cannot be nested, i.e. you need to call resumeTabOrderUpdate before calling + suspendTabOrderUpdate, again. + */ + void suspendTabOrderUpdate(); + + /** resumes calls to activateTabOrder, and also does all pending calls which were collected since the last + suspendTabOrderUpdate call. + */ + void resumeTabOrderUpdate(); + + void onCreatedFormObject( FmFormObj const & _rFormObject ); + + void breakCreateFormObject(); + + static bool + isFocusable( const css::uno::Reference< css::awt::XControl >& i_rControl ); + +private: + //void addWindow(const SdrPageViewWinRec*); + void addWindow(const SdrPageWindow&); + void removeWindow( const css::uno::Reference< css::awt::XControlContainer >& _rxCC ); + void Activate(bool bSync = false); + void Deactivate(bool bDeactivateController = true); + + SdrObjectUniquePtr implCreateFieldControl( const svx::ODataAccessDescriptor& _rColumnDescriptor ); + SdrObjectUniquePtr implCreateXFormsControl( const svx::OXFormsDescriptor &_rDesc ); + + static bool createControlLabelPair( + OutputDevice const & _rOutDev, + sal_Int32 _nXOffsetMM, + sal_Int32 _nYOffsetMM, + const css::uno::Reference< css::beans::XPropertySet >& _rxField, + const css::uno::Reference< css::util::XNumberFormats >& _rxNumberFormats, + sal_uInt16 _nControlObjectID, + const OUString& _rFieldPostfix, + SdrInventor _nInventor, + sal_uInt16 _nLabelObjectID, + + // tdf#118963 Need a SdrModel for SdrObject creation. To make the + // demand clear, hand over a SdrMldel& + SdrModel& _rModel, + + std::unique_ptr<SdrUnoObj, SdrObjectFreeOp>& _rpLabel, + std::unique_ptr<SdrUnoObj, SdrObjectFreeOp>& _rpControl + ); + + bool createControlLabelPair( + OutputDevice const & _rOutDev, + sal_Int32 _nXOffsetMM, + sal_Int32 _nYOffsetMM, + const css::uno::Reference< css::beans::XPropertySet >& _rxField, + const css::uno::Reference< css::util::XNumberFormats >& _rxNumberFormats, + sal_uInt16 _nControlObjectID, + const OUString& _rFieldPostfix, + std::unique_ptr<SdrUnoObj, SdrObjectFreeOp>& _rpLabel, + std::unique_ptr<SdrUnoObj, SdrObjectFreeOp>& _rpControl, + const css::uno::Reference< css::sdbc::XDataSource >& _rxDataSource, + const OUString& _rDataSourceName, + const OUString& _rCommand, + const sal_Int32 _nCommandType + ); + + void ObjectRemovedInAliveMode(const SdrObject* pObject); + + // asynchronously displays an error message. See also OnDelayedErrorMessage. + void displayAsyncErrorMessage( const css::sdb::SQLErrorEvent& _rEvent ); + + // cancels all pending async events + void cancelEvents(); + + /// the auto focus to the first (in terms of the tab order) control + void AutoFocus(); + DECL_LINK( OnActivate, void*, void ); + DECL_LINK( OnAutoFocus, void*, void ); + DECL_LINK( OnDelayedErrorMessage, void*, void ); + DECL_LINK( OnStartControlWizard, void*, void ); + +private: + ::svxform::DocumentType impl_getDocumentType() const; +}; + + +#endif // INCLUDED_SVX_SOURCE_INC_FMVWIMP_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/inc/formcontrolfactory.hxx b/svx/source/inc/formcontrolfactory.hxx new file mode 100644 index 000000000..51dcb78fe --- /dev/null +++ b/svx/source/inc/formcontrolfactory.hxx @@ -0,0 +1,109 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ + +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_SVX_SOURCE_INC_FORMCONTROLFACTORY_HXX +#define INCLUDED_SVX_SOURCE_INC_FORMCONTROLFACTORY_HXX + +#include "fmdocumentclassification.hxx" + +#include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/util/XNumberFormats.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/uno/XComponentContext.hpp> +#include <com/sun/star/container/XNameAccess.hpp> + +#include <memory> + +class SdrUnoObj; +namespace tools { class Rectangle; } + +namespace comphelper { + class ComponentContext; +} + + +namespace svxform +{ + + struct FormControlFactory_Data; + + class FormControlFactory + { + public: + FormControlFactory( const css::uno::Reference<css::uno::XComponentContext>& _rContext ); + FormControlFactory(); + ~FormControlFactory(); + + /** initializes the given control model which is to be newly inserted into a document + + @param _eDocType + the type of the document which the control is to be inserted into + @param _rxControlModel + the control model to be inserted + @param _rControlBoundRect + the bound rect of the control, if applicable + @return + the class ID of the control + */ + sal_Int16 initializeControlModel( + const DocumentType _eDocType, + const css::uno::Reference< css::beans::XPropertySet >& _rxControlModel, + const tools::Rectangle& _rControlBoundRect + ); + + sal_Int16 initializeControlModel( const DocumentType _eDocType, const SdrUnoObj& _rObject ); + void initializeControlModel( const DocumentType _eDocType, const css::uno::Reference< css::beans::XPropertySet >& _rxControlModel ); + + void initializeTextFieldLineEnds( + const css::uno::Reference< css::beans::XPropertySet >& _rxModel + ); + + static void initializeFieldDependentProperties( + const css::uno::Reference< css::beans::XPropertySet >& _rxDatabaseField, + const css::uno::Reference< css::beans::XPropertySet >& _rxControlModel, + const css::uno::Reference< css::util::XNumberFormats >& _rxNumberFormats + ); + + static OUString getDefaultName( + const sal_Int16 nClassId, + const css::uno::Reference< css::lang::XServiceInfo >& _rxObject + ); + + static OUString getDefaultUniqueName_ByComponentType( + const css::uno::Reference< css::container::XNameAccess >& _rxContainer, + const css::uno::Reference< css::beans::XPropertySet >& _rxObject + ); + + static OUString getUniqueName( + const css::uno::Reference< css::container::XNameAccess >& _rxContainer, + const OUString& _rBaseName + ); + + private: + ::std::unique_ptr< FormControlFactory_Data > m_pData; + }; + + +} + + +#endif // INCLUDED_SVX_SOURCE_INC_FORMCONTROLFACTORY_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/inc/formcontroller.hxx b/svx/source/inc/formcontroller.hxx new file mode 100644 index 000000000..80538a839 --- /dev/null +++ b/svx/source/inc/formcontroller.hxx @@ -0,0 +1,565 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_SVX_SOURCE_INC_FORMCONTROLLER_HXX +#define INCLUDED_SVX_SOURCE_INC_FORMCONTROLLER_HXX + +#include <sal/config.h> + +#include <memory> +#include <vector> + +#include "delayedevent.hxx" +#include "fmcontrolbordermanager.hxx" +#include "formdispatchinterceptor.hxx" +#include "sqlparserclient.hxx" + +#include <com/sun/star/awt/XControl.hpp> +#include <com/sun/star/awt/XControlModel.hpp> +#include <com/sun/star/awt/XFocusListener.hpp> +#include <com/sun/star/awt/XItemListener.hpp> +#include <com/sun/star/awt/XMouseListener.hpp> +#include <com/sun/star/awt/XTabController.hpp> +#include <com/sun/star/awt/XTextComponent.hpp> +#include <com/sun/star/container/XContainerListener.hpp> +#include <com/sun/star/form/DatabaseParameterEvent.hpp> +#include <com/sun/star/form/validation/XFormComponentValidityListener.hpp> +#include <com/sun/star/form/XConfirmDeleteListener.hpp> +#include <com/sun/star/form/XDatabaseParameterListener.hpp> +#include <com/sun/star/form/runtime/XFormController.hpp> +#include <com/sun/star/form/runtime/XFilterController.hpp> +#include <com/sun/star/form/XFormControllerListener.hpp> +#include <com/sun/star/form/XGridControlListener.hpp> +#include <com/sun/star/form/XLoadListener.hpp> +#include <com/sun/star/form/XResetListener.hpp> +#include <com/sun/star/frame/XDispatch.hpp> +#include <com/sun/star/frame/XDispatchProviderInterception.hpp> +#include <com/sun/star/frame/XDispatchProviderInterceptor.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/script/XEventAttacherManager.hpp> +#include <com/sun/star/sdb/XRowSetApproveListener.hpp> +#include <com/sun/star/sdb/XSingleSelectQueryComposer.hpp> +#include <com/sun/star/sdb/XSQLErrorListener.hpp> +#include <com/sun/star/sdbc/XRowSetListener.hpp> +#include <com/sun/star/task/XInteractionHandler.hpp> +#include <com/sun/star/util/XModifyListener.hpp> + +#include <comphelper/proparrhlp.hxx> +#include <comphelper/interfacecontainer2.hxx> +#include <cppuhelper/basemutex.hxx> +#include <cppuhelper/propshlp.hxx> +#include <rtl/ref.hxx> +#include <vcl/timer.hxx> +#include <vcl/idle.hxx> + +#include <cppuhelper/compbase.hxx> + +struct FmXTextComponentLess +{ + bool operator() (const css::uno::Reference< css::awt::XTextComponent >& x, const css::uno::Reference< css::awt::XTextComponent >& y) const + { + return reinterpret_cast<sal_Int64>(x.get()) < reinterpret_cast<sal_Int64>(y.get()); + } +}; + +typedef ::std::map< css::uno::Reference< css::awt::XTextComponent >, OUString, FmXTextComponentLess> FmFilterRow; +typedef ::std::vector< FmFilterRow > FmFilterRows; +typedef ::std::vector< css::uno::Reference< css::form::runtime::XFormController > > FmFormControllers; + +namespace vcl { class Window; } + +namespace svxform +{ + typedef ::std::vector< css::uno::Reference< css::awt::XTextComponent > > FilterComponents; + class ControlBorderManager; + struct FmFieldInfo; + + typedef cppu::WeakComponentImplHelper < css::form::runtime::XFormController + , css::form::runtime::XFilterController + , css::awt::XFocusListener + , css::form::XLoadListener + , css::beans::XPropertyChangeListener + , css::awt::XTextListener + , css::awt::XItemListener + , css::container::XContainerListener + , css::util::XModifyListener + , css::form::XConfirmDeleteListener + , css::sdb::XSQLErrorListener + , css::sdbc::XRowSetListener + , css::sdb::XRowSetApproveListener + , css::form::XDatabaseParameterListener + , css::lang::XServiceInfo + , css::form::XResetListener + , css::frame::XDispatch + , css::awt::XMouseListener + , css::form::validation::XFormComponentValidityListener + , css::task::XInteractionHandler + , css::form::XGridControlListener + , css::form::runtime::XFeatureInvalidation + > FormController_BASE; + + class ColumnInfoCache; + class FormController final : public ::cppu::BaseMutex + ,public FormController_BASE + ,public ::cppu::OPropertySetHelper + ,public DispatchInterceptor + ,public ::comphelper::OAggregationArrayUsageHelper< FormController > + ,public ::svxform::OSQLParserClient + { + typedef ::std::map < sal_Int16, + css::uno::Reference< css::frame::XDispatch > + > DispatcherContainer; + + css::uno::Reference< css::uno::XAggregation> m_xAggregate; + css::uno::Reference< css::awt::XTabController> m_xTabController; + css::uno::Reference< css::awt::XControl> m_xActiveControl, m_xCurrentControl; + css::uno::Reference< css::container::XIndexAccess> m_xModelAsIndex; + css::uno::Reference< css::script::XEventAttacherManager> m_xModelAsManager; + css::uno::Reference< css::uno::XInterface> m_xParent; + css::uno::Reference< css::uno::XComponentContext> m_xComponentContext; + // Composer used for checking filter conditions + css::uno::Reference< css::sdb::XSingleSelectQueryComposer > m_xComposer; + css::uno::Reference< css::task::XInteractionHandler > m_xInteractionHandler; + css::uno::Reference< css::form::runtime::XFormControllerContext > m_xFormControllerContext; + + css::uno::Sequence< css::uno::Reference< css::awt::XControl> > m_aControls; + ::comphelper::OInterfaceContainerHelper2 + m_aActivateListeners, + m_aModifyListeners, + m_aErrorListeners, + m_aDeleteListeners, + m_aRowSetApproveListeners, + m_aParameterListeners, + m_aFilterListeners; + + FmFormControllers m_aChildren; + FilterComponents m_aFilterComponents; + FmFilterRows m_aFilterRows; + + Idle m_aTabActivationIdle; + Timer m_aFeatureInvalidationTimer; + + ::svxform::ControlBorderManager + m_aControlBorderManager; + + css::uno::Reference< css::form::runtime::XFormOperations > + m_xFormOperations; + DispatcherContainer m_aFeatureDispatchers; + ::std::set< sal_Int16 > m_aInvalidFeatures; // for asynchronous feature invalidation + + OUString m_aMode; + + ::svxform::DelayedEvent m_aLoadEvent; + ::svxform::DelayedEvent m_aToggleEvent; + ::svxform::DelayedEvent m_aActivationEvent; + ::svxform::DelayedEvent m_aDeactivationEvent; + + ::std::unique_ptr< ColumnInfoCache > + m_pColumnInfoCache; + + sal_Int32 m_nCurrentFilterPosition; // current level for filtering (or-criteria) + + bool m_bCurrentRecordModified : 1; + bool m_bCurrentRecordNew : 1; + bool m_bLocked : 1; + bool m_bDBConnection : 1; // focus listener only for database forms + bool m_bCycle : 1; + bool m_bCanInsert : 1; + bool m_bCanUpdate : 1; + bool m_bCommitLock : 1; // lock the committing of controls see focusGained + bool m_bModified : 1; // is the content of a control modified? + bool m_bControlsSorted : 1; + bool m_bFiltering : 1; + bool m_bAttachEvents : 1; + bool m_bDetachEvents : 1; + bool m_bAttemptedHandlerCreation : 1; + bool m_bSuspendFilterTextListening; // no bit field, passed around as reference + + // as we want to intercept dispatches of _all_ controls we're responsible for, and an object implementing + // the css::frame::XDispatchProviderInterceptor interface can intercept only _one_ objects dispatches, we need a helper class + std::vector<rtl::Reference<DispatchInterceptionMultiplexer>> m_aControlDispatchInterceptors; + + public: + FormController( const css::uno::Reference< css::uno::XComponentContext > & _rxORB ); + + private: + virtual ~FormController() override; + + // XInterface + virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type& type) override; + virtual void SAL_CALL acquire() throw () override; + virtual void SAL_CALL release() throw () override; + + // XTypeProvider + virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override; + virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes( ) override; + + // XDispatch + virtual void SAL_CALL dispatch( const css::util::URL& _rURL, const css::uno::Sequence< css::beans::PropertyValue >& _rArgs ) override; + virtual void SAL_CALL addStatusListener( const css::uno::Reference< css::frame::XStatusListener >& _rxListener, const css::util::URL& _rURL ) override; + virtual void SAL_CALL removeStatusListener( const css::uno::Reference< css::frame::XStatusListener >& _rxListener, const css::util::URL& _rURL ) override; + + // css::container::XChild + virtual css::uno::Reference< css::uno::XInterface> SAL_CALL getParent() override; + virtual void SAL_CALL setParent(const css::uno::Reference< css::uno::XInterface>& Parent) override; + + // css::lang::XEventListener + virtual void SAL_CALL disposing(const css::lang::EventObject& Source) override; + + // OComponentHelper + virtual void SAL_CALL disposing() override; + + // OPropertySetHelper + virtual sal_Bool SAL_CALL convertFastPropertyValue( css::uno::Any & rConvertedValue, css::uno::Any & rOldValue, + sal_Int32 nHandle, const css::uno::Any& rValue ) override; + + virtual void SAL_CALL setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const css::uno::Any& rValue ) override; + virtual void SAL_CALL getFastPropertyValue( css::uno::Any& rValue, sal_Int32 nHandle ) const override; + + virtual css::uno::Reference< css::beans::XPropertySetInfo> SAL_CALL getPropertySetInfo() override; + virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper() override; + + using OPropertySetHelper::getFastPropertyValue; + + // XFilterController + virtual ::sal_Int32 SAL_CALL getFilterComponents() override; + virtual ::sal_Int32 SAL_CALL getDisjunctiveTerms() override; + virtual void SAL_CALL addFilterControllerListener( const css::uno::Reference< css::form::runtime::XFilterControllerListener >& Listener ) override; + virtual void SAL_CALL removeFilterControllerListener( const css::uno::Reference< css::form::runtime::XFilterControllerListener >& Listener ) override; + virtual void SAL_CALL setPredicateExpression( ::sal_Int32 Component, ::sal_Int32 Term, const OUString& PredicateExpression ) override; + virtual css::uno::Reference< css::awt::XControl > SAL_CALL getFilterComponent( ::sal_Int32 Component ) override; + virtual css::uno::Sequence< css::uno::Sequence< OUString > > SAL_CALL getPredicateExpressions() override; + virtual void SAL_CALL removeDisjunctiveTerm( ::sal_Int32 Term ) override; + virtual void SAL_CALL appendEmptyDisjunctiveTerm() override; + virtual ::sal_Int32 SAL_CALL getActiveTerm() override; + virtual void SAL_CALL setActiveTerm( ::sal_Int32 ActiveTerm ) override; + + // XElementAccess + virtual css::uno::Type SAL_CALL getElementType() override; + virtual sal_Bool SAL_CALL hasElements() override; + + // css::container::XEnumerationAccess + virtual css::uno::Reference< css::container::XEnumeration> SAL_CALL createEnumeration() override; + + // css::container::XContainerListener + virtual void SAL_CALL elementInserted(const css::container::ContainerEvent& rEvent) override; + virtual void SAL_CALL elementReplaced(const css::container::ContainerEvent& rEvent) override; + virtual void SAL_CALL elementRemoved(const css::container::ContainerEvent& rEvent) override; + + // XLoadListener + virtual void SAL_CALL loaded(const css::lang::EventObject& rEvent) override; + virtual void SAL_CALL unloaded(const css::lang::EventObject& rEvent) override; + virtual void SAL_CALL unloading(const css::lang::EventObject& aEvent) override; + virtual void SAL_CALL reloading(const css::lang::EventObject& aEvent) override; + virtual void SAL_CALL reloaded(const css::lang::EventObject& aEvent) override; + + // XModeSelector + virtual void SAL_CALL setMode(const OUString& Mode) override; + virtual OUString SAL_CALL getMode() override; + virtual css::uno::Sequence< OUString > SAL_CALL getSupportedModes() override; + virtual sal_Bool SAL_CALL supportsMode(const OUString& Mode) override; + + // css::container::XIndexAccess + virtual sal_Int32 SAL_CALL getCount() override; + virtual css::uno::Any SAL_CALL getByIndex(sal_Int32 Index) override; + + // XModifyBroadcaster + virtual void SAL_CALL addModifyListener(const css::uno::Reference< css::util::XModifyListener>& l) override; + virtual void SAL_CALL removeModifyListener(const css::uno::Reference< css::util::XModifyListener>& l) override; + + // XFocusListener + virtual void SAL_CALL focusGained(const css::awt::FocusEvent& e) override; + virtual void SAL_CALL focusLost(const css::awt::FocusEvent& e) override; + + // XMouseListener + virtual void SAL_CALL mousePressed( const css::awt::MouseEvent& _rEvent ) override; + virtual void SAL_CALL mouseReleased( const css::awt::MouseEvent& _rEvent ) override; + virtual void SAL_CALL mouseEntered( const css::awt::MouseEvent& _rEvent ) override; + virtual void SAL_CALL mouseExited( const css::awt::MouseEvent& _rEvent ) override; + + // XFormComponentValidityListener + virtual void SAL_CALL componentValidityChanged( const css::lang::EventObject& _rSource ) override; + + // XInteractionHandler + virtual void SAL_CALL handle( const css::uno::Reference< css::task::XInteractionRequest >& Request ) override; + + // XGridControlListener + virtual void SAL_CALL columnChanged( const css::lang::EventObject& _event ) override; + + // css::beans::XPropertyChangeListener -> change of states + virtual void SAL_CALL propertyChange(const css::beans::PropertyChangeEvent& evt) override; + + // XTextListener -> set modify + virtual void SAL_CALL textChanged(const css::awt::TextEvent& rEvent) override; + + // XItemListener -> set modify + virtual void SAL_CALL itemStateChanged(const css::awt::ItemEvent& rEvent) override; + + // XModifyListener -> set modify + virtual void SAL_CALL modified(const css::lang::EventObject& rEvent) override; + + // XFormController + virtual css::uno::Reference< css::form::runtime::XFormOperations > SAL_CALL getFormOperations() override; + virtual css::uno::Reference< css::awt::XControl> SAL_CALL getCurrentControl() override; + virtual void SAL_CALL addActivateListener(const css::uno::Reference< css::form::XFormControllerListener>& l) override; + virtual void SAL_CALL removeActivateListener(const css::uno::Reference< css::form::XFormControllerListener>& l) override; + virtual void SAL_CALL addChildController( const css::uno::Reference< css::form::runtime::XFormController >& ChildController ) override; + + virtual css::uno::Reference< css::form::runtime::XFormControllerContext > SAL_CALL getContext() override; + virtual void SAL_CALL setContext( const css::uno::Reference< css::form::runtime::XFormControllerContext >& _context ) override; + virtual css::uno::Reference< css::task::XInteractionHandler > SAL_CALL getInteractionHandler() override; + virtual void SAL_CALL setInteractionHandler( const css::uno::Reference< css::task::XInteractionHandler >& _interactionHandler ) override; + + // XTabController + virtual css::uno::Sequence< css::uno::Reference< css::awt::XControl> > SAL_CALL getControls() override; + + virtual void SAL_CALL setModel(const css::uno::Reference< css::awt::XTabControllerModel>& Model) override; + virtual css::uno::Reference< css::awt::XTabControllerModel> SAL_CALL getModel() override; + + virtual void SAL_CALL setContainer(const css::uno::Reference< css::awt::XControlContainer>& Container) override; + virtual css::uno::Reference< css::awt::XControlContainer> SAL_CALL getContainer() override; + + virtual void SAL_CALL autoTabOrder() override; + virtual void SAL_CALL activateTabOrder() override; + + virtual void SAL_CALL activateFirst() override; + virtual void SAL_CALL activateLast() override; + + // css::sdbc::XRowSetListener + virtual void SAL_CALL cursorMoved(const css::lang::EventObject& event) override; + virtual void SAL_CALL rowChanged(const css::lang::EventObject& event) override; + virtual void SAL_CALL rowSetChanged(const css::lang::EventObject& event) override; + + // XRowSetApproveListener + virtual sal_Bool SAL_CALL approveCursorMove(const css::lang::EventObject& event) override; + virtual sal_Bool SAL_CALL approveRowChange(const css::sdb::RowChangeEvent& event) override; + virtual sal_Bool SAL_CALL approveRowSetChange(const css::lang::EventObject& event) override; + + // XRowSetApproveBroadcaster + virtual void SAL_CALL addRowSetApproveListener(const css::uno::Reference< css::sdb::XRowSetApproveListener>& listener) override; + virtual void SAL_CALL removeRowSetApproveListener(const css::uno::Reference< css::sdb::XRowSetApproveListener>& listener) override; + + // XSQLErrorBroadcaster + virtual void SAL_CALL errorOccured(const css::sdb::SQLErrorEvent& aEvent) override; + + // XSQLErrorListener + virtual void SAL_CALL addSQLErrorListener(const css::uno::Reference< css::sdb::XSQLErrorListener>& _rListener) override; + virtual void SAL_CALL removeSQLErrorListener(const css::uno::Reference< css::sdb::XSQLErrorListener>& _rListener) override; + + // XDatabaseParameterBroadcaster2 + virtual void SAL_CALL addDatabaseParameterListener(const css::uno::Reference< css::form::XDatabaseParameterListener>& aListener) override; + virtual void SAL_CALL removeDatabaseParameterListener(const css::uno::Reference< css::form::XDatabaseParameterListener>& aListener) override; + + // XDatabaseParameterBroadcaster + virtual void SAL_CALL addParameterListener(const css::uno::Reference< css::form::XDatabaseParameterListener>& aListener) override; + virtual void SAL_CALL removeParameterListener(const css::uno::Reference< css::form::XDatabaseParameterListener>& aListener) override; + + // XDatabaseParameterListener + virtual sal_Bool SAL_CALL approveParameter(const css::form::DatabaseParameterEvent& aEvent) override; + + // XConfirmDeleteBroadcaster + virtual void SAL_CALL addConfirmDeleteListener(const css::uno::Reference< css::form::XConfirmDeleteListener>& aListener) override; + virtual void SAL_CALL removeConfirmDeleteListener(const css::uno::Reference< css::form::XConfirmDeleteListener>& aListener) override; + + // XConfirmDeleteListener + virtual sal_Bool SAL_CALL confirmDelete(const css::sdb::RowChangeEvent& aEvent) override; + + // XServiceInfo + virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) override; + virtual OUString SAL_CALL getImplementationName() override; + virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override; + + // XResetListener + virtual sal_Bool SAL_CALL approveReset(const css::lang::EventObject& rEvent) override; + virtual void SAL_CALL resetted(const css::lang::EventObject& rEvent) override; + + // XFeatureInvalidation + virtual void SAL_CALL invalidateFeatures( const css::uno::Sequence< ::sal_Int16 >& Features ) override; + virtual void SAL_CALL invalidateAllFeatures( ) override; + +// method for registration + static css::uno::Sequence< OUString > const & getSupportedServiceNames_Static(); + + // comphelper::OPropertyArrayUsageHelper + virtual void fillProperties( + css::uno::Sequence< css::beans::Property >& /* [out] */ _rProps, + css::uno::Sequence< css::beans::Property >& /* [out] */ _rAggregateProps + ) const override; + + // DispatchInterceptor + virtual css::uno::Reference< css::frame::XDispatch> + interceptedQueryDispatch( + const css::util::URL& aURL, + const OUString& aTargetFrameName, + sal_Int32 nSearchFlags + ) override; + + virtual ::osl::Mutex* getInterceptorMutex() override { return &m_aMutex; } + + /// update all our dispatchers + void updateAllDispatchers() const; + + /** disposes all dispatchers in m_aFeatureDispatchers, and empties m_aFeatureDispatchers + */ + void disposeAllFeaturesAndDispatchers(); + + void startFiltering(); + void stopFiltering(); + void setFilter(::std::vector<FmFieldInfo>&); + void startListening(); + void stopListening(); + + /** ensures that we have an interaction handler, if possible + + If an interaction handler was provided at creation time (<member>initialize</member>), this + one will be used. Else, an attempt is made to create an <type scope="css::sdb">InteractionHandler</type> + is made. + + @return <TRUE/> + if and only if <member>m_xInteractionHandler</member> is valid when the method returns + */ + bool ensureInteractionHandler(); + + /** replaces one of our controls with another one + + Upon successful replacing, the old control will be disposed. Also, internal members pointing + to the current or active control will be adjusted. Yet more, if the replaced control was + the active control, the new control will be made active. + + @param _rxExistentControl + The control to replace. Must be one of the controls in our ControlContainer. + @param _rxNewControl + The control which should replace the existent control. + @return + <TRUE/> if and only if the control was successfully replaced + */ + bool replaceControl( + const css::uno::Reference< css::awt::XControl >& _rxExistentControl, + const css::uno::Reference< css::awt::XControl >& _rxNewControl + ); + + // we're listening at all bound controls for modifications + void startControlModifyListening(const css::uno::Reference< css::awt::XControl>& xControl); + void stopControlModifyListening(const css::uno::Reference< css::awt::XControl>& xControl); + + void setLocks(); + void setControlLock(const css::uno::Reference< css::awt::XControl>& xControl); + void addToEventAttacher(const css::uno::Reference< css::awt::XControl>& xControl); + void removeFromEventAttacher(const css::uno::Reference< css::awt::XControl>& xControl); + void toggleAutoFields(bool bAutoFields); + /// @throws css::uno::RuntimeException + void unload(); + void removeBoundFieldListener(); + + void startFormListening( const css::uno::Reference< css::beans::XPropertySet >& _rxForm, bool _bPropertiesOnly ); + void stopFormListening( const css::uno::Reference< css::beans::XPropertySet >& _rxForm, bool _bPropertiesOnly ); + + css::uno::Reference< css::awt::XControl> findControl( css::uno::Sequence< css::uno::Reference< css::awt::XControl> >& rCtrls, const css::uno::Reference< css::awt::XControlModel>& rxCtrlModel, bool _bRemove, bool _bOverWrite ) const; + + void insertControl(const css::uno::Reference< css::awt::XControl>& xControl); + void removeControl(const css::uno::Reference< css::awt::XControl>& xControl); + + /// called when a new control is to be handled by the controller + void implControlInserted( const css::uno::Reference< css::awt::XControl>& _rxControl, bool _bAddToEventAttacher ); + /// called when a control is not to be handled by the controller anymore + void implControlRemoved( const css::uno::Reference< css::awt::XControl>& _rxControl, bool _bRemoveFromEventAttacher ); + + /** sets m_xCurrentControl, plus does administrative tasks depending on it + */ + void implSetCurrentControl( const css::uno::Reference< css::awt::XControl >& _rxControl ); + + /** invalidates the FormFeatures which depend on the current control + */ + void implInvalidateCurrentControlDependentFeatures(); + + bool impl_isDisposed_nofail() const { return FormController_BASE::rBHelper.bDisposed; } + void impl_checkDisposed_throw() const; + + void impl_onModify(); + + /** adds the given filter row to m_aFilterRows, setting m_nCurrentFilterPosition to 0 if the newly added + row is the first one. + + @precond + our mutex is locked + */ + void impl_addFilterRow( const FmFilterRow& _row ); + + /** adds an empty filter row to m_aFilterRows, and notifies our listeners + */ + void impl_appendEmptyFilterRow( ::osl::ClearableMutexGuard& _rClearBeforeNotify ); + + bool isLocked() const {return m_bLocked;} + bool determineLockState() const; + + vcl::Window* getDialogParentWindow(); + // returns the window which should be used as parent window for dialogs + + css::uno::Reference< css::frame::XDispatchProviderInterceptor> createInterceptor(const css::uno::Reference< css::frame::XDispatchProviderInterception>& _xInterception); + // create a new interceptor, register it on the given object + void deleteInterceptor(const css::uno::Reference< css::frame::XDispatchProviderInterception>& _xInterception); + // if createInterceptor was called for the given object the according interceptor will be removed + // from the objects interceptor chain and released + + /** checks all form controls belonging to our form for validity + + If a form control supports the XValidatableFormComponent interface, this is used to determine + the validity of the control. If the interface is not supported, the control is supposed to be + valid. + + @param _rFirstInvalidityExplanation + if the method returns <FALSE/> (i.e. if there is an invalid control), this string contains + the explanation for the invalidity, as obtained from the validator. + + @param _rxFirstInvalidModel + if the method returns <FALSE/> (i.e. if there is an invalid control), this contains + the control model + + @return + <TRUE/> if and only if all controls belonging to our form are valid + */ + bool checkFormComponentValidity( + OUString& /* [out] */ _rFirstInvalidityExplanation, + css::uno::Reference< css::awt::XControlModel >& /* [out] */ _rxFirstInvalidModel + ); + + /** locates the control which belongs to a given model + */ + css::uno::Reference< css::awt::XControl > + locateControl( const css::uno::Reference< css::awt::XControlModel >& _rxModel ); + + // set the text for all filters + void impl_setTextOnAllFilter_throw(); + + // in filter mode we do not listen for changes + bool isListeningForChanges() const {return m_bDBConnection && !m_bFiltering && !isLocked();} + css::uno::Reference< css::awt::XControl> isInList(const css::uno::Reference< css::awt::XWindowPeer>& xPeer) const; + + DECL_LINK( OnActivateTabOrder, Timer*, void ); + DECL_LINK( OnInvalidateFeatures, Timer*, void ); + DECL_LINK( OnLoad, void*, void ); + DECL_LINK( OnToggleAutoFields, void*, void ); + DECL_LINK( OnActivated, void*, void ); + DECL_LINK( OnDeactivated, void*, void ); + }; + +} + +#endif // INCLUDED_SVX_SOURCE_INC_FORMCONTROLLER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/inc/formcontrolling.hxx b/svx/source/inc/formcontrolling.hxx new file mode 100644 index 000000000..dc93489c3 --- /dev/null +++ b/svx/source/inc/formcontrolling.hxx @@ -0,0 +1,215 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_SVX_SOURCE_INC_FORMCONTROLLING_HXX +#define INCLUDED_SVX_SOURCE_INC_FORMCONTROLLING_HXX + +#include <com/sun/star/form/runtime/XFormController.hpp> +#include <com/sun/star/form/runtime/FeatureState.hpp> +#include <com/sun/star/form/runtime/XFormOperations.hpp> +#include <com/sun/star/sdb/XSQLErrorListener.hpp> + +#include <cppuhelper/implbase.hxx> +#include <rtl/ref.hxx> + +#include <vector> + + +namespace svx +{ + + class FeatureSlotTranslation + { + public: + /// retrieves the feature id for a given feature URL + static sal_Int32 getControllerFeatureSlotIdForURL( const OUString& _rMainURL ); + + /// retrieves the css.form.runtime.FormFeature ID for a given slot ID + static sal_Int16 getFormFeatureForSlotId( sal_Int32 _nSlotId ); + + /// retrieves the slot id for a given css.form.runtime.FormFeature ID + static sal_Int32 getSlotIdForFormFeature( sal_Int16 _nFormFeature ); + }; + + class IControllerFeatureInvalidation + { + public: + /** invalidates the given features + + Invalidation means that any user interface representation (such as toolbox buttons), or + any dispatches associated with the features in question are potentially out-of-date, and + need to be updated + + @param _rFeatures + Ids of the features to be invalidated. + */ + virtual void invalidateFeatures( const ::std::vector< sal_Int32 >& _rFeatures ) = 0; + + protected: + ~IControllerFeatureInvalidation() {} + }; + + class FormControllerHelper; + /** easier access to a FormControllerHelper instance + */ + class ControllerFeatures final + { + IControllerFeatureInvalidation* m_pInvalidationCallback; // necessary as long as m_pImpl is not yet constructed + rtl::Reference<FormControllerHelper> m_pImpl; + + public: + /** standard ctor + + The instance is not functional until <method>assign</method> is used. + + @param _pInvalidationCallback + the callback for invalidating feature states + */ + ControllerFeatures( + IControllerFeatureInvalidation* _pInvalidationCallback + ); + + /** constructs the instance from a <type scope="css::form::runtime">XFormController<type> instance + + @param _rxController + The form controller which the helper should be responsible for. Must not + be <NULL/>, and must have a valid model (form). + */ + ControllerFeatures( + const css::uno::Reference< css::form::runtime::XFormController >& _rxController + ); + + /// dtor + ~ControllerFeatures(); + + /// checks whether the instance is properly assigned to a form and/or controller + bool isAssigned( ) const { return m_pImpl != nullptr; } + + /** assign to a controller + */ + void assign( + const css::uno::Reference< css::form::runtime::XFormController >& _rxController + ); + + /// clears the instance so that it cannot be used afterwards + void dispose(); + + // access to the instance which implements the functionality. Not to be used when not assigned + const FormControllerHelper* operator->() const { return m_pImpl.get(); } + FormControllerHelper* operator->() { return m_pImpl.get(); } + }; + + + //= FormControllerHelper + + typedef ::cppu::WeakImplHelper < css::form::runtime::XFeatureInvalidation + , css::sdb::XSQLErrorListener + > FormControllerHelper_Base; + /** is a helper class which manages form controller functionality (such as moveNext etc.). + + <p>The class helps implementing form controller functionality, by providing + methods to determine the state of, and execute, various common form features.<br/> + A <em>feature</em> is for instance moving the form associated with the controller + to a certain position, or reloading the form, and so on.</p> + */ + class FormControllerHelper : public FormControllerHelper_Base + { + protected: + IControllerFeatureInvalidation* m_pInvalidationCallback; + css::uno::Reference< css::form::runtime::XFormOperations > + m_xFormOperations; + + css::uno::Any m_aOperationError; + + public: + /** constructs the helper from a <type scope="css::form::runtime">XFormController<type> instance + + @param _rxController + The form controller which the helper should be responsible for. Must not + be <NULL/>, and must have a valid model (form). + @param _pInvalidationCallback + the callback for invalidating feature states + */ + FormControllerHelper( + const css::uno::Reference< css::form::runtime::XFormController >& _rxController, + IControllerFeatureInvalidation* _pInvalidationCallback + ); + + // forwards to the XFormOperations implementation + css::uno::Reference< css::sdbc::XRowSet > + getCursor() const; + void getState( + sal_Int32 _nSlotId, + css::form::runtime::FeatureState& _out_rState + ) const; + bool isEnabled( sal_Int32 _nSlotId ) const; + void execute( sal_Int32 _nSlotId ) const; + void execute( sal_Int32 _nSlotId, const OUString& _rParamName, const css::uno::Any& _rParamValue ) const; + bool commitCurrentRecord() const; + bool commitCurrentControl( ) const; + bool isInsertionRow() const; + bool isModifiedRow() const; + + bool canDoFormFilter() const; + + /** disposes this instance. + + After this method has been called, the instance is not functional anymore + */ + void dispose(); + + protected: + /// dtor + virtual ~FormControllerHelper() override; + + // XFeatureInvalidation + virtual void SAL_CALL invalidateFeatures( const css::uno::Sequence< ::sal_Int16 >& Features ) override; + virtual void SAL_CALL invalidateAllFeatures() override; + + // XSQLErrorListener + virtual void SAL_CALL errorOccured( const css::sdb::SQLErrorEvent& Event ) override; + + // XEventListener + virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override; + + private: + enum FormOperation { EXECUTE, EXECUTE_ARGS, COMMIT_CONTROL, COMMIT_RECORD }; + + bool impl_operateForm_nothrow( + const FormOperation _eWhat, + const sal_Int16 _nFeature, /* ignore for COMMIT_* */ + const css::uno::Sequence< css::beans::NamedValue >& _rArguments /* ignore except for EXECUTE_ARGS */ + ) const; + bool impl_operateForm_nothrow( const FormOperation _eWhat ) const + { + return impl_operateForm_nothrow( _eWhat, 0, css::uno::Sequence< css::beans::NamedValue >() ); + } + + private: + FormControllerHelper( const FormControllerHelper& ) = delete; + FormControllerHelper& operator=( const FormControllerHelper& ) = delete; + }; + + +} + + +#endif // INCLUDED_SVX_SOURCE_INC_FORMCONTROLLING_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/inc/formdispatchinterceptor.hxx b/svx/source/inc/formdispatchinterceptor.hxx new file mode 100644 index 000000000..d2947eec5 --- /dev/null +++ b/svx/source/inc/formdispatchinterceptor.hxx @@ -0,0 +1,107 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_SVX_SOURCE_INC_FORMDISPATCHINTERCEPTOR_HXX +#define INCLUDED_SVX_SOURCE_INC_FORMDISPATCHINTERCEPTOR_HXX + +#include <com/sun/star/frame/XDispatchProviderInterceptor.hpp> +#include <com/sun/star/frame/XDispatchProviderInterception.hpp> + +#include <cppuhelper/compbase.hxx> + + +namespace svxform +{ + + class DispatchInterceptor + { + public: + /// @throws css::uno::RuntimeException + virtual css::uno::Reference< css::frame::XDispatch> interceptedQueryDispatch( + const css::util::URL& aURL, const OUString& aTargetFrameName, sal_Int32 nSearchFlags) = 0; + + virtual ::osl::Mutex* getInterceptorMutex() = 0; + + protected: + DispatchInterceptor() {} + + ~DispatchInterceptor() {} + }; + + + //= + + typedef ::cppu::WeakComponentImplHelper< css::frame::XDispatchProviderInterceptor + , css::lang::XEventListener + > DispatchInterceptionMultiplexer_BASE; + + class DispatchInterceptionMultiplexer final : public DispatchInterceptionMultiplexer_BASE + { + public: + css::uno::Reference< css::frame::XDispatchProviderInterception> getIntercepted() const { return m_xIntercepted; } + + DispatchInterceptionMultiplexer( + const css::uno::Reference< css::frame::XDispatchProviderInterception>& _rToIntercept, + DispatchInterceptor* _pMaster + ); + + // css::frame::XDispatchProvider + virtual css::uno::Reference< css::frame::XDispatch > SAL_CALL queryDispatch( const css::util::URL& aURL, const OUString& aTargetFrameName, sal_Int32 nSearchFlags ) override; + virtual css::uno::Sequence< css::uno::Reference< css::frame::XDispatch > > SAL_CALL queryDispatches( const css::uno::Sequence< css::frame::DispatchDescriptor >& aDescripts ) override; + + // css::frame::XDispatchProviderInterceptor + virtual css::uno::Reference< css::frame::XDispatchProvider > SAL_CALL getSlaveDispatchProvider( ) override; + virtual void SAL_CALL setSlaveDispatchProvider( const css::uno::Reference< css::frame::XDispatchProvider >& xNewDispatchProvider ) override; + virtual css::uno::Reference< css::frame::XDispatchProvider > SAL_CALL getMasterDispatchProvider( ) override; + virtual void SAL_CALL setMasterDispatchProvider( const css::uno::Reference< css::frame::XDispatchProvider >& xNewSupplier ) override; + + // css::lang::XEventListener + virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override; + + // OComponentHelper + virtual void SAL_CALL disposing() override; + + private: + virtual ~DispatchInterceptionMultiplexer() override; + + void ImplDetach(); + + ::osl::Mutex m_aFallback; + ::osl::Mutex* m_pMutex; + + // the component which's dispatches we're intercepting + css::uno::WeakReference< css::frame::XDispatchProviderInterception > + m_xIntercepted; + bool m_bListening; + + // the real interceptor + DispatchInterceptor* m_pMaster; + + // chaining + css::uno::Reference< css::frame::XDispatchProvider> m_xSlaveDispatcher; + css::uno::Reference< css::frame::XDispatchProvider> m_xMasterDispatcher; + }; + + +} + + +#endif // INCLUDED_SVX_SOURCE_INC_FORMDISPATCHINTERCEPTOR_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/inc/formfeaturedispatcher.hxx b/svx/source/inc/formfeaturedispatcher.hxx new file mode 100644 index 000000000..b7a664c73 --- /dev/null +++ b/svx/source/inc/formfeaturedispatcher.hxx @@ -0,0 +1,111 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_SVX_SOURCE_INC_FORMFEATUREDISPATCHER_HXX +#define INCLUDED_SVX_SOURCE_INC_FORMFEATUREDISPATCHER_HXX + +#include <com/sun/star/frame/XDispatch.hpp> +#include <com/sun/star/form/runtime/XFormOperations.hpp> + +#include <cppuhelper/implbase.hxx> +#include <comphelper/interfacecontainer2.hxx> + + +namespace svx +{ + + typedef ::cppu::WeakImplHelper < css::frame::XDispatch + > OSingleFeatureDispatcher_Base; + + class OSingleFeatureDispatcher final : public OSingleFeatureDispatcher_Base + { + public: + /** constructs the dispatcher + + @param _rFeatureURL + the URL of the feature which this instance is responsible for + + @param _nFeatureId + the feature which this instance is responsible for + + @param _rController + the controller which is responsible for providing the state of feature of this instance, + and for executing it. After disposing the dispatcher instance, the controller will + not be accessed anymore + + @see dispose + */ + OSingleFeatureDispatcher( + const css::util::URL& _rFeatureURL, + const sal_Int16 _nFormFeature, + const css::uno::Reference< css::form::runtime::XFormOperations >& _rxFormOperations, + ::osl::Mutex& _rMutex + ); + + /** notifies all our listeners of the current state + */ + void updateAllListeners(); + + private: + // XDispatch + virtual void SAL_CALL dispatch( const css::util::URL& _rURL, const css::uno::Sequence< css::beans::PropertyValue >& _rArguments ) override; + virtual void SAL_CALL addStatusListener( const css::uno::Reference< css::frame::XStatusListener >& _rxControl, const css::util::URL& _rURL ) override; + virtual void SAL_CALL removeStatusListener( const css::uno::Reference< css::frame::XStatusListener >& _rxControl, const css::util::URL& _rURL ) override; + + /** notifies our current state to one or all listeners + + @param _rxListener + the listener to notify. May be NULL, in this case all our listeners will be + notified with the current state + + @param _rFreeForNotification + a guard which currently locks our mutex, and which is to be cleared + for actually doing the notification(s) + */ + void notifyStatus( + const css::uno::Reference< css::frame::XStatusListener >& _rxListener, + ::osl::ClearableMutexGuard& _rFreeForNotification + ); + + /** retrieves the current status of our feature, in a format which can be used + for UNO notifications + + @precond + our mutex is locked + */ + void getUnoState( css::frame::FeatureStateEvent& /* [out] */ _rState ) const; + + ::osl::Mutex& m_rMutex; + ::comphelper::OInterfaceContainerHelper2 m_aStatusListeners; + css::uno::Reference< css::form::runtime::XFormOperations > + m_xFormOperations; + const css::util::URL m_aFeatureURL; + css::uno::Any m_aLastKnownState; + const sal_Int16 m_nFormFeature; + bool m_bLastKnownEnabled; + + }; + + +} + + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/inc/formtoolbars.hxx b/svx/source/inc/formtoolbars.hxx new file mode 100644 index 000000000..1a77613bf --- /dev/null +++ b/svx/source/inc/formtoolbars.hxx @@ -0,0 +1,62 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_SVX_SOURCE_INC_FORMTOOLBARS_HXX +#define INCLUDED_SVX_SOURCE_INC_FORMTOOLBARS_HXX + +#include <com/sun/star/frame/XLayoutManager.hpp> + +namespace svxform +{ + class FormToolboxes + { + private: + css::uno::Reference< css::frame::XLayoutManager > m_xLayouter; + + public: + /** constructs an instance + @param _rxFrame + the frame to analyze + */ + FormToolboxes( + const css::uno::Reference< css::frame::XFrame >& _rxFrame + ); + + public: + /** retrieves the URI for the toolbox associated with the given slot, depending + on the type of our document + */ + static OUString + getToolboxResourceName( sal_uInt16 _nSlotId ); + + /** toggles the toolbox associated with the given slot + */ + void toggleToolbox( sal_uInt16 _nSlotId ) const; + + /** determines whether the toolbox associated with the given slot is currently visible + */ + bool isToolboxVisible( sal_uInt16 _nSlotId ) const; + + }; + +} + +#endif // INCLUDED_SVX_SOURCE_INC_FORMTOOLBARS_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/inc/frmselimpl.hxx b/svx/source/inc/frmselimpl.hxx new file mode 100644 index 000000000..09cc61882 --- /dev/null +++ b/svx/source/inc/frmselimpl.hxx @@ -0,0 +1,285 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_SVX_SOURCE_INC_FRMSELIMPL_HXX +#define INCLUDED_SVX_SOURCE_INC_FRMSELIMPL_HXX + +#include <vcl/virdev.hxx> +#include <vcl/image.hxx> +#include <svx/frmsel.hxx> +#include <svx/framelink.hxx> +#include <svx/framelinkarray.hxx> +#include <editeng/borderline.hxx> + +namespace svx { + +namespace a11y { + class AccFrameSelector; + class AccFrameSelectorChild; +} + +class FrameBorder +{ +public: + explicit FrameBorder(FrameBorderType eType); + static double GetDefaultPatternScale() { return 0.05; } + + FrameBorderType GetType() const + { + return meType; + } + + bool IsEnabled() const + { + return mbEnabled; + } + void Enable(FrameSelFlags nFlags); + + FrameBorderState GetState() const + { + return meState; + } + void SetState(FrameBorderState eState); + + bool IsSelected() const { return mbSelected; } + void Select( bool bSelect ) { mbSelected = bSelect; } + + const editeng::SvxBorderLine& GetCoreStyle() const { return maCoreStyle; } + void SetCoreStyle( const editeng::SvxBorderLine* pStyle ); + + void SetUIColorPrim( const Color& rColor ) {maUIStyle.SetColorPrim( rColor ); } + void SetUIColorSecn( const Color& rColor ) {maUIStyle.SetColorSecn( rColor ); } + const frame::Style& GetUIStyle() const { return maUIStyle; } + + void ClearFocusArea() { maFocusArea.Clear(); } + void AddFocusPolygon( const tools::Polygon& rFocus ); + void MergeFocusToPolyPolygon( tools::PolyPolygon& rPPoly ) const; + + void ClearClickArea() { maClickArea.Clear(); } + void AddClickRect( const tools::Rectangle& rRect ); + bool ContainsClickPoint( const Point& rPos ) const; + tools::Rectangle GetClickBoundRect() const; + + void SetKeyboardNeighbors(FrameBorderType eLeft, FrameBorderType eRight, + FrameBorderType eTop, FrameBorderType eBottom); + FrameBorderType GetKeyboardNeighbor( sal_uInt16 nKeyCode ) const; + +private: + const FrameBorderType meType; /// Frame border type (position in control). + FrameBorderState meState; /// Frame border state (on/off/don't care). + editeng::SvxBorderLine maCoreStyle; /// Core style from application. + frame::Style maUIStyle; /// Internal style to draw lines. + FrameBorderType meKeyLeft; /// Left neighbor for keyboard control. + FrameBorderType meKeyRight; /// Right neighbor for keyboard control. + FrameBorderType meKeyTop; /// Upper neighbor for keyboard control. + FrameBorderType meKeyBottom; /// Lower neighbor for keyboard control. + tools::PolyPolygon maFocusArea; /// Focus drawing areas. + tools::PolyPolygon maClickArea; /// Mouse click areas. + bool mbEnabled : 1; /// true = Border enabled in control. + bool mbSelected : 1; /// true = Border selected in control. +}; + + +typedef std::vector< FrameBorder* > FrameBorderPtrVec; + +struct FrameSelectorImpl +{ + FrameSelector& mrFrameSel; /// The control itself. + ScopedVclPtr<VirtualDevice> mpVirDev; /// For all buffered drawing operations. + std::vector<Image> maArrows; /// Arrows in current system colors. + Color maBackCol; /// Background color. + Color maArrowCol; /// Selection arrow color. + Color maMarkCol; /// Selection marker color. + Color maHCLineCol; /// High contrast line color. + Point maVirDevPos; /// Position of virtual device in the control. + + FrameBorder maLeft; /// All data of left frame border. + FrameBorder maRight; /// All data of right frame border. + FrameBorder maTop; /// All data of top frame border. + FrameBorder maBottom; /// All data of bottom frame border. + FrameBorder maHor; /// All data of inner horizontal frame border. + FrameBorder maVer; /// All data of inner vertical frame border. + FrameBorder maTLBR; /// All data of top-left to bottom-right frame border. + FrameBorder maBLTR; /// All data of bottom-left to top-right frame border. + editeng::SvxBorderLine maCurrStyle; /// Current style and color for new borders. + frame::Array maArray; /// Frame link array to draw an array of frame borders. + + FrameSelFlags mnFlags; /// Flags for enabled frame borders. + FrameBorderPtrVec maAllBorders; /// Pointers to all frame borders. + FrameBorderPtrVec maEnabBorders; /// Pointers to enables frame borders. + Link<LinkParamNone*,void> maSelectHdl; /// Selection handler. + + long mnCtrlSize; /// Size of the control (always square). + long mnArrowSize; /// Size of an arrow image. + long mnLine1; /// Middle of left/top frame borders. + long mnLine2; /// Middle of inner frame borders. + long mnLine3; /// Middle of right/bottom frame borders. + long mnFocusOffs; /// Offset from frame border middle to draw focus. + + bool mbHor; /// true = Inner horizontal frame border enabled. + bool mbVer; /// true = Inner vertical frame border enabled. + bool mbTLBR; /// true = Top-left to bottom-right frame border enabled. + bool mbBLTR; /// true = Bottom-left to top-right frame border enabled. + bool mbFullRepaint; /// Used for repainting (false = only copy virtual device). + bool mbAutoSelect; /// true = Auto select a frame border, if focus reaches control. + bool mbHCMode; /// true = High contrast mode. + + std::vector<rtl::Reference<a11y::AccFrameSelectorChild>> + maChildVec; /// Pointers to accessibility objects for frame borders. + explicit FrameSelectorImpl( FrameSelector& rFrameSel ); + ~FrameSelectorImpl(); + + // initialization + /** Initializes the control, enables/disables frame borders according to flags. */ + void Initialize( FrameSelFlags nFlags ); + + /** Fills all color members from current style settings. */ + void InitColors(); + /** Creates the image list with selection arrows regarding current style settings. */ + void InitArrowImageList(); + /** Initializes global coordinates. */ + void InitGlobalGeometry(); + /** Initializes coordinates of all frame borders. */ + void InitBorderGeometry(); + /** Draws the entire control into the internal virtual device. */ + void InitVirtualDevice(); + /** call this to recalculate based on parent size */ + void sizeChanged(); + + // frame border access + /** Returns the object representing the specified frame border. */ + const FrameBorder& GetBorder( FrameBorderType eBorder ) const; + /** Returns the object representing the specified frame border (write access). */ + FrameBorder& GetBorderAccess( FrameBorderType eBorder ); + + // drawing + /** Draws the background of the entire control (the gray areas between borders). */ + void DrawBackground(); + + /** Draws selection arrows for the specified frame border. */ + void DrawArrows( const FrameBorder& rBorder ); + + /** Returns the color that has to be used to draw a frame border. */ + Color GetDrawLineColor( const Color& rColor ) const; + /** Draws all frame borders. */ + void DrawAllFrameBorders(); + + /** Draws all contents of the control. */ + void DrawVirtualDevice(); + /** Copies contents of the virtual device to the control. */ + void CopyVirDevToControl(vcl::RenderContext& rRenderContext); + + /** Draws tracking rectangles for all selected frame borders. */ + void DrawAllTrackingRects(vcl::RenderContext& rRenderContext); + + /** Converts a mouse position to the virtual device position. */ + Point GetDevPosFromMousePos( const Point& rMousePos ) const; + + /** Invalidates the control. + @param bFullRepaint true = Full repaint; false = update selection only. */ + void DoInvalidate( bool bFullRepaint ); + + // frame border state and style + /** Sets the state of the specified frame border. */ + void SetBorderState( FrameBorder& rBorder, FrameBorderState eState ); + /** Sets the core style of the specified frame border, or hides the frame border, if pStyle is 0. */ + void SetBorderCoreStyle( FrameBorder& rBorder, const editeng::SvxBorderLine* pStyle ); + + /** Changes the state of a frame border after a control event (mouse/keyboard). */ + void ToggleBorderState( FrameBorder& rBorder ); + + // frame border selection + /** Selects a frame border and schedules redraw. */ + void SelectBorder( FrameBorder& rBorder, bool bSelect ); + /** Grabs focus without auto-selection of a frame border, if no border selected. */ + void SilentGrabFocus(); + + /** Returns true, if all selected frame borders are equal (or if nothing is selected). */ + bool SelectedBordersEqual() const; +}; + + +/** Dummy predicate for frame border iterators to use all borders in a container. */ +struct FrameBorderDummy_Pred +{ + bool operator()( const FrameBorder* ) const { return true; } +}; + +/** Predicate for frame border iterators to use only visible borders in a container. */ +struct FrameBorderVisible_Pred +{ + bool operator()( const FrameBorder* pBorder ) const { return pBorder->GetState() == FrameBorderState::Show; } +}; + +/** Predicate for frame border iterators to use only selected borders in a container. */ +struct FrameBorderSelected_Pred +{ + bool operator()( const FrameBorder* pBorder ) const { return pBorder->IsSelected(); } +}; + +/** Template class for all types of frame border iterators. */ +template< typename Cont, typename Iter, typename Pred > +class FrameBorderIterBase +{ +public: + typedef Cont container_type; + typedef Iter iterator_type; + typedef typename Cont::value_type value_type; + typedef FrameBorderIterBase<Cont, Iter, Pred> this_type; + + explicit FrameBorderIterBase( container_type& rCont ); + bool Is() const { return maIt != maEnd; } + this_type& operator++(); + value_type operator*() const { return *maIt; } + +private: + iterator_type maIt; + iterator_type maEnd; + Pred maPred; +}; + +/** Iterator for constant svx::FrameBorder containers, iterates over all borders. */ +typedef FrameBorderIterBase< const FrameBorderPtrVec, FrameBorderPtrVec::const_iterator, FrameBorderDummy_Pred > + FrameBorderCIter; + +/** Iterator for mutable svx::FrameBorder containers, iterates over all borders. */ +typedef FrameBorderIterBase< FrameBorderPtrVec, FrameBorderPtrVec::iterator, FrameBorderDummy_Pred > + FrameBorderIter; + +/** Iterator for constant svx::FrameBorder containers, iterates over visible borders. */ +typedef FrameBorderIterBase< const FrameBorderPtrVec, FrameBorderPtrVec::const_iterator, FrameBorderVisible_Pred > + VisFrameBorderCIter; + +/** Iterator for mutable svx::FrameBorder containers, iterates over visible borders. */ +typedef FrameBorderIterBase< FrameBorderPtrVec, FrameBorderPtrVec::iterator, FrameBorderVisible_Pred > + VisFrameBorderIter; + +/** Iterator for constant svx::FrameBorder containers, iterates over selected borders. */ +typedef FrameBorderIterBase< const FrameBorderPtrVec, FrameBorderPtrVec::const_iterator, FrameBorderSelected_Pred > + SelFrameBorderCIter; + +/** Iterator for mutable svx::FrameBorder containers, iterates over selected borders. */ +typedef FrameBorderIterBase< FrameBorderPtrVec, FrameBorderPtrVec::iterator, FrameBorderSelected_Pred > + SelFrameBorderIter; + +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/inc/gridcell.hxx b/svx/source/inc/gridcell.hxx new file mode 100644 index 000000000..4fff0ef46 --- /dev/null +++ b/svx/source/inc/gridcell.hxx @@ -0,0 +1,1101 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_SVX_SOURCE_INC_GRIDCELL_HXX +#define INCLUDED_SVX_SOURCE_INC_GRIDCELL_HXX + +#include <memory> +#include <svx/gridctrl.hxx> + +#include "sqlparserclient.hxx" + +#include <com/sun/star/sdb/XColumn.hpp> +#include <com/sun/star/form/XBoundControl.hpp> +#include <com/sun/star/awt/XTextComponent.hpp> +#include <com/sun/star/awt/XListBox.hpp> +#include <com/sun/star/awt/XComboBox.hpp> +#include <com/sun/star/awt/TextAlign.hpp> +#include <com/sun/star/awt/XControlModel.hpp> +#include <com/sun/star/awt/XControl.hpp> +#include <com/sun/star/awt/XCheckBox.hpp> +#include <com/sun/star/awt/XButton.hpp> +#include <com/sun/star/lang/XUnoTunnel.hpp> +#include <com/sun/star/form/XChangeBroadcaster.hpp> +#include <com/sun/star/awt/XWindow.hpp> +#include <com/sun/star/util/XNumberFormatsSupplier.hpp> + +#include <comphelper/propmultiplex.hxx> +#include <comphelper/interfacecontainer2.hxx> +#include <comphelper/uno3.hxx> +#include <connectivity/formattedcolumnvalue.hxx> +#include <cppuhelper/component.hxx> +#include <cppuhelper/implbase1.hxx> +#include <cppuhelper/implbase2.hxx> +#include <tools/diagnose_ex.h> + +class DbCellControl; +class Edit; +class FmXGridCell; +namespace dbtools { + class FormattedColumnValue; +} + +class FmMutexHelper +{ +protected: + ::osl::Mutex m_aMutex; +}; + + +// DbGridColumn, column description + +class DbGridColumn +{ + friend class DbGridControl; + + css::uno::Reference< css::beans::XPropertySet > m_xModel; + css::uno::Reference< css::beans::XPropertySet > m_xField; // connection to the database field + ::svt::CellControllerRef m_xController; // structure for managing the controls for a column + // this is positioned by the DbBrowseBox on the respective + // cells of a column + rtl::Reference<FmXGridCell> m_pCell; + +protected: + DbGridControl& m_rParent; + +private: + sal_Int32 m_nLastVisibleWidth; // only valid if m_bHidden == sal_True + sal_Int32 m_nFormatKey; + sal_Int16 m_nFieldType; + sal_Int16 m_nTypeId; + sal_uInt16 m_nId; + sal_Int16 m_nFieldPos; + sal_Int16 m_nAlign; // specified with TXT_ALIGN_LEFT... + bool m_bReadOnly : 1; + bool m_bAutoValue : 1; + bool m_bInSave : 1; + bool m_bNumeric : 1; + bool m_bObject : 1; // does the column reference an object datatype? + bool m_bHidden : 1; + bool m_bLocked : 1; + + static ::svt::CellControllerRef s_xEmptyController; + // used by locked columns +public: + DbGridColumn(sal_uInt16 _nId, DbGridControl& rParent) + :m_rParent(rParent) + ,m_nLastVisibleWidth(-1) + ,m_nFormatKey(0) + ,m_nFieldType(0) + ,m_nTypeId(0) + ,m_nId(_nId) + ,m_nFieldPos(-1) + ,m_nAlign(css::awt::TextAlign::LEFT) + ,m_bReadOnly(false) + ,m_bAutoValue(false) + ,m_bInSave(false) + ,m_bNumeric(false) + ,m_bObject(false) + ,m_bHidden(false) + ,m_bLocked(false) + { + } + + ~DbGridColumn(); + + const css::uno::Reference< css::beans::XPropertySet >& getModel() const { return m_xModel; } + void setModel(const css::uno::Reference< css::beans::XPropertySet >& _xModel); + + + sal_uInt16 GetId() const {return m_nId;} + bool IsReadOnly() const {return m_bReadOnly;} + bool IsAutoValue() const {return m_bAutoValue;} + sal_Int16 GetAlignment() const {return m_nAlign;} + sal_Int16 GetFieldPos() const {return m_nFieldPos; } + bool IsNumeric() const {return m_bNumeric;} + bool IsHidden() const {return m_bHidden;} + sal_Int32 GetKey() const {return m_nFormatKey;} + const ::svt::CellControllerRef& GetController() const {return m_bLocked ? s_xEmptyController : m_xController;} + const css::uno::Reference< css::beans::XPropertySet >& GetField() const {return m_xField;} + DbGridControl& GetParent() const {return m_rParent;} + FmXGridCell* GetCell() const {return m_pCell.get();} + + css::uno::Reference< css::sdb::XColumn > GetCurrentFieldValue() const; + + // Drawing a field at a position. If a view is set, it takes over the drawing, + // e.g., for checkboxes. + void Paint(OutputDevice& rDev, + const tools::Rectangle& rRect, + const DbGridRow* pRow, + const css::uno::Reference< css::util::XNumberFormatter >& xFormatter); + + + // Initializing in the alive mode. + // If no ColumnController is set, a default initialization is performed. + void CreateControl(sal_Int32 _nFieldPos, const css::uno::Reference< css::beans::XPropertySet >& xField, sal_Int32 nTypeId); + void UpdateControl() + { + css::uno::Reference< css::beans::XPropertySet > xField(m_xField); + CreateControl(m_nFieldPos, xField, m_nTypeId); + } + + // Editing a Zelle + void UpdateFromField(const DbGridRow* pRow, const css::uno::Reference< css::util::XNumberFormatter >& xFormatter); + bool Commit(); + + // releasing all the data required for the AliveMode + void Clear(); + + OUString GetCellText(const DbGridRow* pRow, const css::uno::Reference< css::util::XNumberFormatter >& xFormatter) const; + OUString GetCellText(const css::uno::Reference< css::sdb::XColumn >& xField, const css::uno::Reference< css::util::XNumberFormatter >& xFormatter) const; + + void SetReadOnly(bool bRead){m_bReadOnly = bRead;} + void SetObject(sal_Int16 nPos) {m_bObject = m_bReadOnly = true; m_nFieldPos = nPos;} + + void ImplInitWindow( vcl::Window const & rParent, const InitWindowFacet _eInitWhat ); + + // properties that can bleed through onto the css::frame::Controller + sal_Int16 SetAlignment(sal_Int16 _nAlign); + // if _nAlign is -1, the alignment is calculated from the type of the field we are bound to + // the value really set is returned + sal_Int16 SetAlignmentFromModel(sal_Int16 nStandardAlign); + // set the alignment according to the "Align"-property of m_xModel, use the given standard + // alignment if the property if void, return the really set alignment + + // column locking + bool isLocked() const { return m_bLocked; } + void setLock(bool _bLock); + +private: + /** attaches or detaches our cell object to the SctriptEventAttacherManager implemented + by our model's parent + */ + void impl_toggleScriptManager_nothrow( bool _bAttach ); +}; + + +// DbCellControl, provides the data for a CellController. +// Is usually only required for complex controls such as combo boxes. + +class DbCellControl + :public FmMutexHelper // _before_ the listener, so the listener is to be destroyed first! + ,public ::comphelper::OPropertyChangeListener +{ +private: + rtl::Reference<::comphelper::OPropertyChangeMultiplexer> m_pModelChangeBroadcaster; + rtl::Reference<::comphelper::OPropertyChangeMultiplexer> m_pFieldChangeBroadcaster; + +private: + bool m_bTransparent : 1; + bool m_bAlignedController : 1; + bool m_bAccessingValueProperty : 1; + + css::uno::Reference< css::sdbc::XRowSet > + m_xCursor; + +protected: + DbGridColumn& m_rColumn; + VclPtr<vcl::Window> m_pPainter; + VclPtr<vcl::Window> m_pWindow; + +protected: + // attribute access + const css::uno::Reference< css::sdbc::XRowSet >& getCursor() const { return m_xCursor; } + + // control transparency + bool isTransparent( ) const { return m_bTransparent; } + void setTransparent( bool _bSet ) { m_bTransparent = _bSet; } + + // control alignment + void setAlignedController( bool _bAlign ) { m_bAlignedController = _bAlign; } + + + /** determined whether or not the value property is locked + @see lockValueProperty + */ + inline bool isValuePropertyLocked() const; + + /** locks the listening at the value property. + <p>This means that every subsequent change now done on the value property of the model ("Text", or "Value", + or whatever) is then ignored.<br/> + This base class uses this setting in <method>Commit</method>.</p> + @precond + Value locking can't be nested + @see unlockValueProperty + */ + inline void lockValueProperty(); + /** unlocks the listening at the value property + @see lockValueProperty + */ + inline void unlockValueProperty(); + +protected: + // adds the given property to the list of properties which we listen for + void doPropertyListening( const OUString& _rPropertyName ); + + // called whenever a property which affects field settings in general is called + // you should overwrite this method for every property you add yourself as listener to + // with doPropertyListening + virtual void implAdjustGenericFieldSetting( const css::uno::Reference< css::beans::XPropertySet >& _rxModel ); + + // called by _propertyChanged if a property which denotes the column value has changed + void implValuePropertyChanged( ); + + +public: + DbCellControl(DbGridColumn& _rColumn); + virtual ~DbCellControl() override; + + + vcl::Window& GetWindow() const + { + ENSURE_OR_THROW( m_pWindow, "no window" ); + return *m_pWindow; + } + + // control alignment + bool isAlignedController() const { return m_bAlignedController; } + void AlignControl(sal_Int16 nAlignment); + + void SetTextLineColor(); + void SetTextLineColor(const Color& _rColor); + + // initializing before a control is displayed + virtual void Init( vcl::Window& rParent, const css::uno::Reference< css::sdbc::XRowSet >& xCursor ); + virtual ::svt::CellControllerRef CreateController() const = 0; + + // writing the value into the model + bool Commit(); + + // Formatting the field data to output text + virtual OUString GetFormatText(const css::uno::Reference< css::sdb::XColumn >& _rxField, const css::uno::Reference< css::util::XNumberFormatter >& xFormatter, Color** ppColor = nullptr) = 0; + + virtual void Update(){} + // Refresh the control by the field data + virtual void UpdateFromField(const css::uno::Reference< css::sdb::XColumn >& _rxField, const css::uno::Reference< css::util::XNumberFormatter >& xFormatter) = 0; + + // painting a cell content in the specified rectangle + virtual void PaintFieldToCell( OutputDevice& rDev, const tools::Rectangle& rRect, const css::uno::Reference< css::sdb::XColumn >& _rxField, const css::uno::Reference< css::util::XNumberFormatter >& xFormatter); + virtual void PaintCell( OutputDevice& _rDev, const tools::Rectangle& _rRect ); + + void ImplInitWindow( vcl::Window const & rParent, const InitWindowFacet _eInitWhat ); + + double GetValue(const css::uno::Reference< css::sdb::XColumn >& _rxField, const css::uno::Reference< css::util::XNumberFormatter >& xFormatter) const; + +protected: + void invalidatedController(); + + /** commits the content of the control (e.g. the text of an edit field) into the column model + (e.g. the "Text" property of the model). + <p>To be overwritten in derived classes.</p> + @see updateFromModel + */ + virtual bool commitControl( ) = 0; + + /** updates the current content of the control (e.g. the text of an edit field) from the column model + (e.g. the "Text" property of the model). + <p>To be overwritten in derived classes.</p> + @precond + NULL != _rxModel + @precond + NULL != m_pWindow + + @see commitControl + */ + virtual void updateFromModel( css::uno::Reference< css::beans::XPropertySet > _rxModel ) = 0; + +protected: +// OPropertyChangeListener + virtual void _propertyChanged(const css::beans::PropertyChangeEvent& evt) override; + +private: + void implDoPropertyListening( const OUString& _rPropertyName, bool _bWarnIfNotExistent ); + + /// updates the "readonly" setting on m_pWindow, according to the respective property value in the given model + void implAdjustReadOnly( const css::uno::Reference< css::beans::XPropertySet >& _rxModel,bool i_bReadOnly ); + + /// updates the "enabled" setting on m_pWindow, according to the respective property value in the given model + void implAdjustEnabled( const css::uno::Reference< css::beans::XPropertySet >& _rxModel ); +}; + + +inline bool DbCellControl::isValuePropertyLocked() const +{ + return m_bAccessingValueProperty; +} + + +inline void DbCellControl::lockValueProperty() +{ + OSL_ENSURE( !isValuePropertyLocked(), "DbCellControl::lockValueProperty: not to be nested!" ); + m_bAccessingValueProperty = true; +} + + +inline void DbCellControl::unlockValueProperty() +{ + OSL_ENSURE( isValuePropertyLocked(), "DbCellControl::lockValueProperty: not locked so far!" ); + m_bAccessingValueProperty = false; +} + + +/** a field which is bound to a column which supports the MaxTextLen property +*/ +class DbLimitedLengthField : public DbCellControl +{ +public: + +protected: + DbLimitedLengthField( DbGridColumn& _rColumn ); + +protected: + // DbCellControl + virtual void implAdjustGenericFieldSetting( const css::uno::Reference< css::beans::XPropertySet >& _rxModel ) override; + +protected: + void implSetMaxTextLen( sal_Int16 _nMaxLen ) + { + implSetEffectiveMaxTextLen( _nMaxLen ? _nMaxLen : EDIT_NOLIMIT ); + } + virtual void implSetEffectiveMaxTextLen( sal_Int32 _nMaxLen ); +}; + + +class DbTextField : public DbLimitedLengthField +{ + std::unique_ptr<::svt::IEditImplementation> m_pEdit; + std::unique_ptr<::svt::IEditImplementation> m_pPainterImplementation; + bool m_bIsSimpleEdit; + +protected: + virtual ~DbTextField( ) override; + +public: + DbTextField(DbGridColumn& _rColumn); + + ::svt::IEditImplementation* GetEditImplementation() { return m_pEdit.get(); } + bool IsSimpleEdit() const { return m_bIsSimpleEdit; } + + virtual void Init( vcl::Window& rParent, const css::uno::Reference< css::sdbc::XRowSet >& xCursor ) override; + virtual OUString GetFormatText(const css::uno::Reference< css::sdb::XColumn >& _rxField, const css::uno::Reference< css::util::XNumberFormatter >& xFormatter, Color** ppColor = nullptr) override; + virtual void UpdateFromField(const css::uno::Reference< css::sdb::XColumn >& _rxField, const css::uno::Reference< css::util::XNumberFormatter >& xFormatter) override; + virtual ::svt::CellControllerRef CreateController() const override; + virtual void PaintFieldToCell( OutputDevice& _rDev, const tools::Rectangle& _rRect, + const css::uno::Reference< css::sdb::XColumn >& _rxField, + const css::uno::Reference< css::util::XNumberFormatter >& _rxFormatter ) override; + +protected: + // DbCellControl + virtual bool commitControl( ) override; + virtual void updateFromModel( css::uno::Reference< css::beans::XPropertySet > _rxModel ) override; + // DbLimitedLengthField + virtual void implSetEffectiveMaxTextLen( sal_Int32 _nMaxLen ) override; +}; + + +class DbFormattedField final : public DbLimitedLengthField +{ +public: + DbFormattedField(DbGridColumn& _rColumn); + virtual ~DbFormattedField() override; + + virtual void Init( vcl::Window& rParent, const css::uno::Reference< css::sdbc::XRowSet >& xCursor ) override; + virtual OUString GetFormatText(const css::uno::Reference< css::sdb::XColumn >& _rxField, const css::uno::Reference< css::util::XNumberFormatter >& xFormatter, Color** ppColor = nullptr) override; + virtual void UpdateFromField(const css::uno::Reference< css::sdb::XColumn >& _rxField, const css::uno::Reference< css::util::XNumberFormatter >& xFormatter) override; + virtual ::svt::CellControllerRef CreateController() const override; + +private: + // DbCellControl + virtual bool commitControl( ) override; + virtual void updateFromModel( css::uno::Reference< css::beans::XPropertySet > _rxModel ) override; + + // OPropertyChangeListener + virtual void _propertyChanged(const css::beans::PropertyChangeEvent& evt) override; + + css::uno::Reference< css::util::XNumberFormatsSupplier > m_xSupplier; +}; + + +class DbCheckBox : public DbCellControl +{ +public: + DbCheckBox(DbGridColumn& _rColumn); + + virtual void Init( vcl::Window& rParent, const css::uno::Reference< css::sdbc::XRowSet >& xCursor ) override; + virtual void UpdateFromField(const css::uno::Reference< css::sdb::XColumn >& _rxField, const css::uno::Reference< css::util::XNumberFormatter >& xFormatter) override; + virtual ::svt::CellControllerRef CreateController() const override; + virtual void PaintFieldToCell(OutputDevice& rDev, const tools::Rectangle& rRect, + const css::uno::Reference< css::sdb::XColumn >& _rxField, + const css::uno::Reference< css::util::XNumberFormatter >& xFormatter) override; + virtual OUString GetFormatText(const css::uno::Reference< css::sdb::XColumn >& _rxField, const css::uno::Reference< css::util::XNumberFormatter >& xFormatter, Color** ppColor = nullptr) override; + +protected: + // DbCellControl + virtual bool commitControl( ) override; + virtual void updateFromModel( css::uno::Reference< css::beans::XPropertySet > _rxModel ) override; +}; + + +class DbComboBox : public DbCellControl +{ + +public: + DbComboBox(DbGridColumn& _rColumn); + + virtual void Init( vcl::Window& rParent, const css::uno::Reference< css::sdbc::XRowSet >& xCursor ) override; + virtual OUString GetFormatText(const css::uno::Reference< css::sdb::XColumn >& _rxField, const css::uno::Reference< css::util::XNumberFormatter >& xFormatter, Color** ppColor = nullptr) override; + virtual void UpdateFromField(const css::uno::Reference< css::sdb::XColumn >& _rxField, const css::uno::Reference< css::util::XNumberFormatter >& xFormatter) override; + virtual ::svt::CellControllerRef CreateController() const override; + + void SetList(const css::uno::Any& rItems); + +protected: + // DbCellControl + virtual bool commitControl( ) override; + virtual void updateFromModel( css::uno::Reference< css::beans::XPropertySet > _rxModel ) override; + + virtual void implAdjustGenericFieldSetting( const css::uno::Reference< css::beans::XPropertySet >& _rxModel ) override; + + // OPropertyChangeListener + virtual void _propertyChanged(const css::beans::PropertyChangeEvent& evt) override; +}; + + +class DbListBox :public DbCellControl +{ + bool m_bBound : 1; + css::uno::Sequence< OUString > m_aValueList; + +public: + DbListBox(DbGridColumn& _rColumn); + + virtual void Init( vcl::Window& rParent, const css::uno::Reference< css::sdbc::XRowSet >& xCursor ) override; + virtual OUString GetFormatText(const css::uno::Reference< css::sdb::XColumn >& _rxField, const css::uno::Reference< css::util::XNumberFormatter >& xFormatter, Color** ppColor = nullptr) override; + virtual void UpdateFromField(const css::uno::Reference< css::sdb::XColumn >& _rxField, const css::uno::Reference< css::util::XNumberFormatter >& xFormatter) override; + virtual ::svt::CellControllerRef CreateController() const override; + + void SetList(const css::uno::Any& rItems); + +protected: + // DbCellControl + virtual bool commitControl( ) override; + virtual void updateFromModel( css::uno::Reference< css::beans::XPropertySet > _rxModel ) override; + + virtual void implAdjustGenericFieldSetting( const css::uno::Reference< css::beans::XPropertySet >& _rxModel ) override; + + // OPropertyChangeListener + virtual void _propertyChanged(const css::beans::PropertyChangeEvent& evt) override; +}; + + +class DbPatternField : public DbCellControl +{ +public: + DbPatternField( DbGridColumn& _rColumn, const css::uno::Reference<css::uno::XComponentContext>& _rContext ); + virtual void Init( vcl::Window& rParent, const css::uno::Reference< css::sdbc::XRowSet >& xCursor ) override; + virtual OUString GetFormatText(const css::uno::Reference< css::sdb::XColumn >& _rxField, const css::uno::Reference< css::util::XNumberFormatter >& xFormatter, Color** ppColor = nullptr) override; + virtual void UpdateFromField(const css::uno::Reference< css::sdb::XColumn >& _rxField, const css::uno::Reference< css::util::XNumberFormatter >& xFormatter) override; + virtual ::svt::CellControllerRef CreateController() const override; + +protected: + /// DbCellControl + virtual bool commitControl( ) override; + virtual void updateFromModel( css::uno::Reference< css::beans::XPropertySet > _rxModel ) override; + + virtual void implAdjustGenericFieldSetting( const css::uno::Reference< css::beans::XPropertySet >& _rxModel ) override; + +private: + OUString impl_formatText(const OUString& _rText); + +private: + ::std::unique_ptr< ::dbtools::FormattedColumnValue > m_pValueFormatter; + ::std::unique_ptr< ::dbtools::FormattedColumnValue > m_pPaintFormatter; + css::uno::Reference<css::uno::XComponentContext> m_xContext; +}; + + +class DbSpinField : public DbCellControl +{ +private: + sal_Int16 m_nStandardAlign; + +public: + +protected: + DbSpinField( DbGridColumn& _rColumn, sal_Int16 _nStandardAlign = css::awt::TextAlign::RIGHT ); + +public: + virtual void Init( vcl::Window& rParent, const css::uno::Reference< css::sdbc::XRowSet >& _rxCursor ) override; + virtual ::svt::CellControllerRef CreateController() const override; + +protected: + virtual VclPtr<SpinField> createField( + vcl::Window* _pParent, + WinBits _nFieldStyle, + const css::uno::Reference< css::beans::XPropertySet >& _rxModel + ) = 0; +}; + + +class DbDateField : public DbSpinField +{ +public: + DbDateField(DbGridColumn& _rColumn); + virtual OUString GetFormatText(const css::uno::Reference< css::sdb::XColumn >& _rxField, const css::uno::Reference< css::util::XNumberFormatter >& xFormatter, Color** ppColor = nullptr) override; + virtual void UpdateFromField(const css::uno::Reference< css::sdb::XColumn >& _rxField, const css::uno::Reference< css::util::XNumberFormatter >& xFormatter) override; + +protected: + // DbCellControl + virtual bool commitControl( ) override; + virtual void updateFromModel( css::uno::Reference< css::beans::XPropertySet > _rxModel ) override; + + // DbSpinField + virtual VclPtr<SpinField> createField( + vcl::Window* _pParent, + WinBits _nFieldStyle, + const css::uno::Reference< css::beans::XPropertySet >& _rxModel + ) override; + + /// initializes everything which relates to the properties describing the numeric behaviour + virtual void implAdjustGenericFieldSetting( const css::uno::Reference< css::beans::XPropertySet >& _rxModel ) override; +}; + + +class DbTimeField : public DbSpinField +{ +public: + DbTimeField(DbGridColumn& _rColumn); + virtual OUString GetFormatText(const css::uno::Reference< css::sdb::XColumn >& _rxField, const css::uno::Reference< css::util::XNumberFormatter >& xFormatter, Color** ppColor = nullptr) override; + virtual void UpdateFromField(const css::uno::Reference< css::sdb::XColumn >& _rxField, const css::uno::Reference< css::util::XNumberFormatter >& xFormatter) override; + +protected: + // DbCellControl + virtual bool commitControl( ) override; + virtual void updateFromModel( css::uno::Reference< css::beans::XPropertySet > _rxModel ) override; + + // DbSpinField + virtual VclPtr<SpinField> createField( + vcl::Window* _pParent, + WinBits _nFieldStyle, + const css::uno::Reference< css::beans::XPropertySet >& _rxModel + ) override; + + /// initializes everything which relates to the properties describing the numeric behaviour + virtual void implAdjustGenericFieldSetting( const css::uno::Reference< css::beans::XPropertySet >& _rxModel ) override; +}; + + +class DbCurrencyField : public DbSpinField +{ + sal_Int16 m_nScale; + +public: + DbCurrencyField(DbGridColumn& _rColumn); + virtual OUString GetFormatText(const css::uno::Reference< css::sdb::XColumn >& _rxField, const css::uno::Reference< css::util::XNumberFormatter >& xFormatter, Color** ppColor = nullptr) override; + virtual void UpdateFromField(const css::uno::Reference< css::sdb::XColumn >& _rxField, const css::uno::Reference< css::util::XNumberFormatter >& xFormatter) override; + + double GetCurrency(const css::uno::Reference< css::sdb::XColumn >& _rxField, const css::uno::Reference< css::util::XNumberFormatter >& xFormatter) const; + +protected: + // DbCellControl + virtual bool commitControl( ) override; + virtual void updateFromModel( css::uno::Reference< css::beans::XPropertySet > _rxModel ) override; + + // DbSpinField + virtual VclPtr<SpinField> createField( + vcl::Window* _pParent, + WinBits _nFieldStyle, + const css::uno::Reference< css::beans::XPropertySet >& _rxModel + ) override; + + /// initializes everything which relates to the properties describing the numeric behaviour + virtual void implAdjustGenericFieldSetting( const css::uno::Reference< css::beans::XPropertySet >& _rxModel ) override; +}; + + +class DbNumericField : public DbSpinField +{ +public: + DbNumericField(DbGridColumn& _rColumn); + virtual OUString GetFormatText(const css::uno::Reference< css::sdb::XColumn >& _rxField, const css::uno::Reference< css::util::XNumberFormatter >& xFormatter, Color** ppColor = nullptr) override; + virtual void UpdateFromField(const css::uno::Reference< css::sdb::XColumn >& _rxField, const css::uno::Reference< css::util::XNumberFormatter >& xFormatter) override; + +protected: + // DbCellControl + virtual bool commitControl( ) override; + virtual void updateFromModel( css::uno::Reference< css::beans::XPropertySet > _rxModel ) override; + + // DbSpinField + virtual VclPtr<SpinField> createField( + vcl::Window* _pParent, + WinBits _nFieldStyle, + const css::uno::Reference< css::beans::XPropertySet >& _rxModel + ) override; + + /// initializes everything which relates to the properties describing the numeric behaviour + void implAdjustGenericFieldSetting( const css::uno::Reference< css::beans::XPropertySet >& _rxModel ) override; +}; + + +class DbFilterField final + :public DbCellControl + ,public ::svxform::OSQLParserClient +{ +public: + DbFilterField(const css::uno::Reference< css::uno::XComponentContext >& rxContext, DbGridColumn& _rColumn); + virtual ~DbFilterField() override; + + virtual void Init( vcl::Window& rParent, const css::uno::Reference< css::sdbc::XRowSet >& xCursor ) override; + virtual ::svt::CellControllerRef CreateController() const override; + virtual void PaintCell(OutputDevice& rDev, const tools::Rectangle& rRect) override; + virtual void Update() override; + virtual OUString GetFormatText(const css::uno::Reference< css::sdb::XColumn >& _rxField, const css::uno::Reference< css::util::XNumberFormatter >& xFormatter, Color** ppColor = nullptr) override; + virtual void UpdateFromField(const css::uno::Reference< css::sdb::XColumn >& _rxField, const css::uno::Reference< css::util::XNumberFormatter >& xFormatter) override; + + const OUString& GetText() const {return m_aText;} + void SetText(const OUString& rText); + + void SetCommitHdl( const Link<DbFilterField&,void>& rLink ) { m_aCommitLink = rLink; } + +private: + // DbCellControl + virtual bool commitControl( ) override; + virtual void updateFromModel( css::uno::Reference< css::beans::XPropertySet > _rxModel ) override; + + void SetList(const css::uno::Any& rItems, bool bComboBox); + void CreateControl(vcl::Window* pParent, const css::uno::Reference< css::beans::XPropertySet >& xModel); + DECL_LINK( OnClick, VclPtr<CheckBox>, void ); + + css::uno::Sequence< OUString > m_aValueList; + OUString m_aText; + Link<DbFilterField&,void> m_aCommitLink; + sal_Int16 m_nControlClass; + bool m_bFilterList : 1; + bool m_bFilterListFilled : 1; +}; + + +// Base class providing the access to a grid cell + +typedef ::cppu::ImplHelper2 < css::awt::XControl + , css::form::XBoundControl + > FmXGridCell_Base; +typedef ::cppu::ImplHelper1 < css::awt::XWindow + > FmXGridCell_WindowBase; +class FmXGridCell :public ::cppu::OComponentHelper + ,public FmXGridCell_Base + ,public FmXGridCell_WindowBase +{ +protected: + ::osl::Mutex m_aMutex; + DbGridColumn* m_pColumn; + std::unique_ptr<DbCellControl> m_pCellControl; + +private: + ::comphelper::OInterfaceContainerHelper2 m_aWindowListeners; + ::comphelper::OInterfaceContainerHelper2 m_aFocusListeners; + ::comphelper::OInterfaceContainerHelper2 m_aKeyListeners; + ::comphelper::OInterfaceContainerHelper2 m_aMouseListeners; + ::comphelper::OInterfaceContainerHelper2 m_aMouseMotionListeners; + +protected: + virtual ~FmXGridCell() override; + +public: + FmXGridCell( DbGridColumn* pColumn, std::unique_ptr<DbCellControl> pControl ); + void init(); + + DECLARE_UNO3_AGG_DEFAULTS(FmXGridCell, OComponentHelper) + virtual css::uno::Any SAL_CALL queryAggregation( const css::uno::Type& _rType ) override; + + void SetTextLineColor(); + void SetTextLineColor(const Color& _rColor); + +// XTypeProvider + virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes( ) override; + virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override; + +// OComponentHelper + virtual void SAL_CALL disposing() override; + +// css::lang::XComponent + virtual void SAL_CALL dispose() override {OComponentHelper::dispose();} + virtual void SAL_CALL addEventListener(const css::uno::Reference< css::lang::XEventListener >& aListener) override { OComponentHelper::addEventListener(aListener);} + virtual void SAL_CALL removeEventListener(const css::uno::Reference< css::lang::XEventListener >& aListener) override { OComponentHelper::removeEventListener(aListener);} + +// css::awt::XControl + virtual void SAL_CALL setContext(const css::uno::Reference< css::uno::XInterface >& /*Context*/) override {} + virtual css::uno::Reference< css::uno::XInterface > SAL_CALL getContext() override; + virtual void SAL_CALL createPeer(const css::uno::Reference< css::awt::XToolkit >& /*Toolkit*/, const css::uno::Reference< css::awt::XWindowPeer >& /*Parent*/) override {} + + virtual css::uno::Reference< css::awt::XWindowPeer > SAL_CALL getPeer() override {return css::uno::Reference< css::awt::XWindowPeer > ();} + virtual sal_Bool SAL_CALL setModel(const css::uno::Reference< css::awt::XControlModel >& /*Model*/) override {return false;} + virtual css::uno::Reference< css::awt::XControlModel > SAL_CALL getModel() override; + virtual css::uno::Reference< css::awt::XView > SAL_CALL getView() override {return css::uno::Reference< css::awt::XView > ();} + virtual void SAL_CALL setDesignMode(sal_Bool /*bOn*/) override {} + virtual sal_Bool SAL_CALL isDesignMode() override {return false;} + virtual sal_Bool SAL_CALL isTransparent() override {return false;} + +// css::form::XBoundControl + virtual sal_Bool SAL_CALL getLock() override; + virtual void SAL_CALL setLock(sal_Bool _bLock) override; + + // XWindow + virtual void SAL_CALL setPosSize( ::sal_Int32 X, ::sal_Int32 Y, ::sal_Int32 Width, ::sal_Int32 Height, ::sal_Int16 Flags ) override; + virtual css::awt::Rectangle SAL_CALL getPosSize( ) override; + virtual void SAL_CALL setVisible( sal_Bool Visible ) override; + virtual void SAL_CALL setEnable( sal_Bool Enable ) override; + virtual void SAL_CALL setFocus( ) override; + virtual void SAL_CALL addWindowListener( const css::uno::Reference< css::awt::XWindowListener >& xListener ) override; + virtual void SAL_CALL removeWindowListener( const css::uno::Reference< css::awt::XWindowListener >& xListener ) override; + virtual void SAL_CALL addFocusListener( const css::uno::Reference< css::awt::XFocusListener >& xListener ) override; + virtual void SAL_CALL removeFocusListener( const css::uno::Reference< css::awt::XFocusListener >& xListener ) override; + virtual void SAL_CALL addKeyListener( const css::uno::Reference< css::awt::XKeyListener >& xListener ) override; + virtual void SAL_CALL removeKeyListener( const css::uno::Reference< css::awt::XKeyListener >& xListener ) override; + virtual void SAL_CALL addMouseListener( const css::uno::Reference< css::awt::XMouseListener >& xListener ) override; + virtual void SAL_CALL removeMouseListener( const css::uno::Reference< css::awt::XMouseListener >& xListener ) override; + virtual void SAL_CALL addMouseMotionListener( const css::uno::Reference< css::awt::XMouseMotionListener >& xListener ) override; + virtual void SAL_CALL removeMouseMotionListener( const css::uno::Reference< css::awt::XMouseMotionListener >& xListener ) override; + virtual void SAL_CALL addPaintListener( const css::uno::Reference< css::awt::XPaintListener >& xListener ) override; + virtual void SAL_CALL removePaintListener( const css::uno::Reference< css::awt::XPaintListener >& xListener ) override; + + bool Commit() {return m_pCellControl->Commit();} + void ImplInitWindow( vcl::Window const & rParent, const InitWindowFacet _eInitWhat ) + { m_pCellControl->ImplInitWindow( rParent, _eInitWhat ); } + + bool isAlignedController() const { return m_pCellControl->isAlignedController(); } + void AlignControl(sal_Int16 nAlignment) + { m_pCellControl->AlignControl(nAlignment);} + +protected: + virtual vcl::Window* getEventWindow() const; + virtual void onWindowEvent( const VclEventId _nEventId, const vcl::Window& _rWindow, const void* _pEventData ); + + // default implementations call our focus listeners, don't forget to call them if you override this + virtual void onFocusGained( const css::awt::FocusEvent& _rEvent ); + virtual void onFocusLost( const css::awt::FocusEvent& _rEvent ); + +private: + DECL_LINK( OnWindowEvent, VclWindowEvent&, void ); +}; + + +class FmXDataCell : public FmXGridCell +{ +public: + FmXDataCell( DbGridColumn* pColumn, std::unique_ptr<DbCellControl> pControl ) + :FmXGridCell( pColumn, std::move(pControl) ) + { + } + + virtual void PaintFieldToCell(OutputDevice& rDev, + const tools::Rectangle& rRect, + const css::uno::Reference< css::sdb::XColumn >& xField, + const css::uno::Reference< css::util::XNumberFormatter >& xFormatter); + + void UpdateFromField(const css::uno::Reference< css::sdb::XColumn >& xField, + const css::uno::Reference< css::util::XNumberFormatter >& xFormatter) + { m_pCellControl->UpdateFromField(xField, xFormatter); } + +protected: + void UpdateFromColumn(); +}; + + +class FmXTextCell : public FmXDataCell +{ +protected: + /** determines whether the text of this cell can be painted directly, without + using the painter control + + If this is <TRUE/>, the <member>PaintCell</member> method will simply use the text as returned + by <member>GetText</member>, and draw it onto the device passed to <member>PaintFieldToCell</member>, + while respecting the current alignment settings. + + If this is <FALSE/>, the <member>PaintFieldToCell</member> request will be forwarded to the painter + control (<member>m_pPainter</member>). This is more expensive, but the only option + if your painting involves more that a simple DrawText. + + This member is <TRUE/> by default, and can be modified by derived classes. + */ + bool m_bFastPaint; + +public: + FmXTextCell( DbGridColumn* pColumn, std::unique_ptr<DbCellControl> pControl ); + + virtual void PaintFieldToCell(OutputDevice& rDev, + const tools::Rectangle& rRect, + const css::uno::Reference< css::sdb::XColumn >& xField, + const css::uno::Reference< css::util::XNumberFormatter >& xFormatter) override; + + OUString GetText(const css::uno::Reference< css::sdb::XColumn >& _rxField, + const css::uno::Reference< css::util::XNumberFormatter >& xFormatter, + Color** ppColor = nullptr) + {return m_pCellControl->GetFormatText(_rxField, xFormatter, ppColor);} +}; + + +typedef ::cppu::ImplHelper2 < css::awt::XTextComponent + , css::form::XChangeBroadcaster + > FmXEditCell_Base; +class FmXEditCell final : public FmXTextCell, + public FmXEditCell_Base +{ +public: + FmXEditCell( DbGridColumn* pColumn, std::unique_ptr<DbCellControl> pControl ); + + DECLARE_UNO3_AGG_DEFAULTS(FmXEditCell, FmXTextCell) + virtual css::uno::Any SAL_CALL queryAggregation( const css::uno::Type& _rType ) override; + +// XTypeProvider + virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes( ) override; + virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override; + +// OComponentHelper + virtual void SAL_CALL disposing() override; + +// css::awt::XTextComponent + virtual void SAL_CALL addTextListener(const css::uno::Reference< css::awt::XTextListener >& l) override; + virtual void SAL_CALL removeTextListener(const css::uno::Reference< css::awt::XTextListener >& l) override; + virtual void SAL_CALL setText(const OUString& aText) override; + virtual void SAL_CALL insertText(const css::awt::Selection& Sel, const OUString& Text) override; + virtual OUString SAL_CALL getText() override; + virtual OUString SAL_CALL getSelectedText() override; + virtual void SAL_CALL setSelection(const css::awt::Selection& aSelection) override; + virtual css::awt::Selection SAL_CALL getSelection() override; + virtual sal_Bool SAL_CALL isEditable() override; + virtual void SAL_CALL setEditable(sal_Bool bEditable) override; + virtual void SAL_CALL setMaxTextLen(sal_Int16 nLen) override; + virtual sal_Int16 SAL_CALL getMaxTextLen() override; + + // XChangeBroadcaster + virtual void SAL_CALL addChangeListener( const css::uno::Reference< css::form::XChangeListener >& aListener ) override; + virtual void SAL_CALL removeChangeListener( const css::uno::Reference< css::form::XChangeListener >& aListener ) override; + +private: + virtual ~FmXEditCell() override; + + virtual void onWindowEvent( const VclEventId _nEventId, const vcl::Window& _rWindow, const void* _pEventData ) override; + + virtual void onFocusGained( const css::awt::FocusEvent& _rEvent ) override; + virtual void onFocusLost( const css::awt::FocusEvent& _rEvent ) override; + + void onTextChanged(); + + OUString m_sValueOnEnter; + ::comphelper::OInterfaceContainerHelper2 m_aTextListeners; + ::comphelper::OInterfaceContainerHelper2 m_aChangeListeners; + ::svt::IEditImplementation* m_pEditImplementation; + bool m_bOwnEditImplementation; +}; + + +typedef ::cppu::ImplHelper2 < css::awt::XCheckBox + , css::awt::XButton + > FmXCheckBoxCell_Base; +class FmXCheckBoxCell : public FmXDataCell, + public FmXCheckBoxCell_Base +{ + ::comphelper::OInterfaceContainerHelper2 m_aItemListeners; + ::comphelper::OInterfaceContainerHelper2 m_aActionListeners; + OUString m_aActionCommand; + VclPtr<CheckBox> m_pBox; + +protected: + virtual ~FmXCheckBoxCell() override; + +public: + FmXCheckBoxCell( DbGridColumn* pColumn, std::unique_ptr<DbCellControl> pControl ); + +// UNO + DECLARE_UNO3_AGG_DEFAULTS(FmXCheckBoxCell, FmXDataCell) + virtual css::uno::Any SAL_CALL queryAggregation( const css::uno::Type& _rType ) override; + virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes( ) override; + virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override; + +// OComponentHelper + virtual void SAL_CALL disposing() override; + +// css::awt::XCheckBox + virtual void SAL_CALL addItemListener(const css::uno::Reference< css::awt::XItemListener >& l) override; + virtual void SAL_CALL removeItemListener(const css::uno::Reference< css::awt::XItemListener >& l) override; + virtual sal_Int16 SAL_CALL getState() override; + virtual void SAL_CALL setState(sal_Int16 n) override; + virtual void SAL_CALL setLabel(const OUString& Label) override; + virtual void SAL_CALL enableTriState(sal_Bool b) override; + + // XButton + virtual void SAL_CALL addActionListener( const css::uno::Reference< css::awt::XActionListener >& l ) override; + virtual void SAL_CALL removeActionListener( const css::uno::Reference< css::awt::XActionListener >& l ) override; + //virtual void SAL_CALL setLabel( const OUString& Label ) throw (css::uno::RuntimeException); + virtual void SAL_CALL setActionCommand( const OUString& Command ) override; + +protected: + virtual vcl::Window* getEventWindow() const override; + virtual void onWindowEvent( const VclEventId _nEventId, const vcl::Window& _rWindow, const void* _pEventData ) override; +}; + +typedef ::cppu::ImplHelper1 < css::awt::XListBox + > FmXListBoxCell_Base; +class FmXListBoxCell final : public FmXTextCell + , public FmXListBoxCell_Base +{ +public: + FmXListBoxCell( DbGridColumn* pColumn, std::unique_ptr<DbCellControl> pControl ); + + DECLARE_UNO3_AGG_DEFAULTS(FmXListBoxCell, FmXTextCell) + virtual css::uno::Any SAL_CALL queryAggregation( const css::uno::Type& _rType ) override; + virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes( ) override; + virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override; + +// OComponentHelper + virtual void SAL_CALL disposing() override; + +// css::awt::XListBox + virtual void SAL_CALL addItemListener(const css::uno::Reference< css::awt::XItemListener >& l) override; + virtual void SAL_CALL removeItemListener(const css::uno::Reference< css::awt::XItemListener >& l) override; + virtual void SAL_CALL addActionListener(const css::uno::Reference< css::awt::XActionListener >& l) override; + virtual void SAL_CALL removeActionListener(const css::uno::Reference< css::awt::XActionListener >& l) override; + virtual void SAL_CALL addItem(const OUString& aItem, sal_Int16 nPos) override; + virtual void SAL_CALL addItems(const css::uno::Sequence< OUString >& aItems, sal_Int16 nPos) override; + virtual void SAL_CALL removeItems(sal_Int16 nPos, sal_Int16 nCount) override; + virtual sal_Int16 SAL_CALL getItemCount() override; + virtual OUString SAL_CALL getItem(sal_Int16 nPos) override; + virtual css::uno::Sequence< OUString > SAL_CALL getItems() override; + virtual sal_Int16 SAL_CALL getSelectedItemPos() override; + virtual css::uno::Sequence< sal_Int16 > SAL_CALL getSelectedItemsPos() override; + virtual OUString SAL_CALL getSelectedItem() override; + virtual css::uno::Sequence< OUString > SAL_CALL getSelectedItems() override; + virtual void SAL_CALL selectItemPos(sal_Int16 nPos, sal_Bool bSelect) override; + virtual void SAL_CALL selectItemsPos(const css::uno::Sequence< sal_Int16 >& aPositions, sal_Bool bSelect) override; + virtual void SAL_CALL selectItem(const OUString& aItem, sal_Bool bSelect) override; + virtual sal_Bool SAL_CALL isMutipleMode() override; + virtual void SAL_CALL setMultipleMode(sal_Bool bMulti) override; + virtual sal_Int16 SAL_CALL getDropDownLineCount() override; + virtual void SAL_CALL setDropDownLineCount(sal_Int16 nLines) override; + virtual void SAL_CALL makeVisible(sal_Int16 nEntry) override; + +private: + virtual ~FmXListBoxCell() override; + + DECL_LINK(ChangedHdl, LinkParamNone*, void); + + void OnDoubleClick(); + + ::comphelper::OInterfaceContainerHelper2 m_aItemListeners, + m_aActionListeners; + VclPtr<::svt::ListBoxControl> m_pBox; + sal_uInt16 m_nLines; + bool m_bMulti; +}; + + +typedef ::cppu::ImplHelper1 < css::awt::XComboBox + > FmXComboBoxCell_Base; +class FmXComboBoxCell final : public FmXTextCell + , public FmXComboBoxCell_Base +{ +private: + ::comphelper::OInterfaceContainerHelper2 m_aItemListeners, + m_aActionListeners; + VclPtr<::svt::ComboBoxControl> m_pComboBox; + sal_uInt16 m_nLines; + + DECL_LINK(ChangedHdl, LinkParamNone*, void); + + virtual ~FmXComboBoxCell() override; + +public: + FmXComboBoxCell( DbGridColumn* pColumn, std::unique_ptr<DbCellControl> pControl ); + + DECLARE_UNO3_AGG_DEFAULTS(FmXListBoxCell, FmXTextCell) + virtual css::uno::Any SAL_CALL queryAggregation( const css::uno::Type& _rType ) override; + virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes( ) override; + virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override; + + // OComponentHelper + virtual void SAL_CALL disposing() override; + + // XComboBox + virtual void SAL_CALL addItemListener( const css::uno::Reference< css::awt::XItemListener >& Listener ) override; + virtual void SAL_CALL removeItemListener( const css::uno::Reference< css::awt::XItemListener >& Listener ) override; + virtual void SAL_CALL addActionListener( const css::uno::Reference< css::awt::XActionListener >& Listener ) override; + virtual void SAL_CALL removeActionListener( const css::uno::Reference< css::awt::XActionListener >& Listener ) override; + virtual void SAL_CALL addItem( const OUString& Item, ::sal_Int16 Pos ) override; + virtual void SAL_CALL addItems( const css::uno::Sequence< OUString >& Items, ::sal_Int16 Pos ) override; + virtual void SAL_CALL removeItems( ::sal_Int16 nPos, ::sal_Int16 nCount ) override; + virtual ::sal_Int16 SAL_CALL getItemCount( ) override; + virtual OUString SAL_CALL getItem( ::sal_Int16 Pos ) override; + virtual css::uno::Sequence< OUString > SAL_CALL getItems( ) override; + virtual ::sal_Int16 SAL_CALL getDropDownLineCount( ) override; + virtual void SAL_CALL setDropDownLineCount( ::sal_Int16 Lines ) override; +}; + +typedef ::cppu::ImplHelper2 < css::awt::XTextComponent + , css::lang::XUnoTunnel + > FmXFilterCell_Base; +class FmXFilterCell final : public FmXGridCell + ,public FmXFilterCell_Base +{ +public: + FmXFilterCell(DbGridColumn* pColumn, std::unique_ptr<DbFilterField> pControl); + + + DECLARE_UNO3_AGG_DEFAULTS(FmXFilterCell, FmXGridCell) + virtual css::uno::Any SAL_CALL queryAggregation( const css::uno::Type& _rType ) override; + virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes( ) override; + virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override; + +// XUnoTunnel + virtual sal_Int64 SAL_CALL getSomething( const css::uno::Sequence< sal_Int8 >& aIdentifier ) override; + +// helpers for XUnoTunnel + static const css::uno::Sequence<sal_Int8>& getUnoTunnelId(); + +// painting the filter text + void PaintCell(OutputDevice& rDev, const tools::Rectangle& rRect); + void Update(){m_pCellControl->Update();} + +// OComponentHelper + virtual void SAL_CALL disposing() override; + +// css::awt::XTextComponent + virtual void SAL_CALL addTextListener(const css::uno::Reference< css::awt::XTextListener >& l) override; + virtual void SAL_CALL removeTextListener(const css::uno::Reference< css::awt::XTextListener >& l) override; + virtual void SAL_CALL setText(const OUString& aText) override; + virtual void SAL_CALL insertText(const css::awt::Selection& Sel, const OUString& Text) override; + virtual OUString SAL_CALL getText() override; + virtual OUString SAL_CALL getSelectedText() override; + virtual void SAL_CALL setSelection(const css::awt::Selection& aSelection) override; + virtual css::awt::Selection SAL_CALL getSelection() override; + virtual sal_Bool SAL_CALL isEditable() override; + virtual void SAL_CALL setEditable(sal_Bool bEditable) override; + virtual void SAL_CALL setMaxTextLen(sal_Int16 nLen) override; + virtual sal_Int16 SAL_CALL getMaxTextLen() override; + +private: + DECL_LINK( OnCommit, DbFilterField&, void ); + virtual ~FmXFilterCell() override; + + ::comphelper::OInterfaceContainerHelper2 m_aTextListeners; +}; + +#endif // INCLUDED_SVX_SOURCE_INC_GRIDCELL_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/inc/gridcols.hxx b/svx/source/inc/gridcols.hxx new file mode 100644 index 000000000..180337f7f --- /dev/null +++ b/svx/source/inc/gridcols.hxx @@ -0,0 +1,54 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_SVX_SOURCE_INC_GRIDCOLS_HXX +#define INCLUDED_SVX_SOURCE_INC_GRIDCOLS_HXX + +#include <sal/types.h> +#include <rtl/ustring.hxx> + +#define FM_COL_TEXTFIELD "TextField" +#define FM_COL_COMBOBOX "ComboBox" +#define FM_COL_CHECKBOX "CheckBox" +#define FM_COL_TIMEFIELD "TimeField" +#define FM_COL_DATEFIELD "DateField" +#define FM_COL_NUMERICFIELD "NumericField" +#define FM_COL_CURRENCYFIELD "CurrencyField" +#define FM_COL_PATTERNFIELD "PatternField" +#define FM_COL_LISTBOX "ListBox" +#define FM_COL_FORMATTEDFIELD "FormattedField" + +// column type ids +#define TYPE_CHECKBOX 0 +#define TYPE_COMBOBOX 1 +#define TYPE_CURRENCYFIELD 2 +#define TYPE_DATEFIELD 3 +#define TYPE_FORMATTEDFIELD 4 +#define TYPE_LISTBOX 5 +#define TYPE_NUMERICFIELD 6 +#define TYPE_PATTERNFIELD 7 +#define TYPE_TEXTFIELD 8 +#define TYPE_TIMEFIELD 9 + + +sal_Int32 getColumnTypeByModelName(const OUString& aModelName); + + +#endif // INCLUDED_SVX_SOURCE_INC_GRIDCOLS_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/inc/sdbdatacolumn.hxx b/svx/source/inc/sdbdatacolumn.hxx new file mode 100644 index 000000000..76d8039c8 --- /dev/null +++ b/svx/source/inc/sdbdatacolumn.hxx @@ -0,0 +1,59 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_SVX_SOURCE_INC_SDBDATACOLUMN_HXX +#define INCLUDED_SVX_SOURCE_INC_SDBDATACOLUMN_HXX + +#include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/sdb/XColumn.hpp> +#include <com/sun/star/sdb/XColumnUpdate.hpp> + + +namespace svxform +{ + + + //= DataColumn - a class wrapping an object implementing a sdb::DataColumn service + + class DataColumn + { + // interfaces needed for sddb::Column + css::uno::Reference< css::beans::XPropertySet> m_xPropertySet; + // interfaces needed for sdb::DataColumn + css::uno::Reference< css::sdb::XColumn> m_xColumn; + css::uno::Reference< css::sdb::XColumnUpdate> m_xColumnUpdate; + + public: + DataColumn(const css::uno::Reference< css::beans::XPropertySet>& _rxIFace); + // if the object behind _rxIFace doesn't fully support the DataColumn service, + // (which is checked via the supported interfaces) _all_ members will be set to + // void !, even if the object has some of the needed interfaces. + + // 'conversions' + const css::uno::Reference< css::sdb::XColumn>& getColumn() const + { + return m_xColumn; + } + }; + +} + +#endif // INCLUDED_SVX_SOURCE_INC_SDBDATACOLUMN_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/inc/sqlparserclient.hxx b/svx/source/inc/sqlparserclient.hxx new file mode 100644 index 000000000..a14ea3671 --- /dev/null +++ b/svx/source/inc/sqlparserclient.hxx @@ -0,0 +1,70 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_SVX_SOURCE_INC_SQLPARSERCLIENT_HXX +#define INCLUDED_SVX_SOURCE_INC_SQLPARSERCLIENT_HXX + +#include <config_options.h> +#include <svx/ParseContext.hxx> + +#include <com/sun/star/uno/XComponentContext.hpp> + +#include <memory> + +namespace com::sun::star { + namespace util { + class XNumberFormatter; + } + namespace beans { + class XPropertySet; + } +} +namespace connectivity { + class OSQLParser; + class OSQLParseNode; +} + +namespace svxform +{ + //= OSQLParserClient + + class UNLESS_MERGELIBS(SVXCORE_DLLPUBLIC) OSQLParserClient : public ::svxform::OParseContextClient + { + protected: + mutable std::shared_ptr< ::connectivity::OSQLParser > m_pParser; + + OSQLParserClient( + const css::uno::Reference< css::uno::XComponentContext >& rxContext); + + std::unique_ptr< ::connectivity::OSQLParseNode > predicateTree( + OUString& _rErrorMessage, + const OUString& _rStatement, + const css::uno::Reference< css::util::XNumberFormatter >& _rxFormatter, + const css::uno::Reference< css::beans::XPropertySet >& _rxField + ) const; + }; + + +} + + +#endif // INCLUDED_SVX_SOURCE_INC_SQLPARSERCLIENT_HXX + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/inc/svdobjplusdata.hxx b/svx/source/inc/svdobjplusdata.hxx new file mode 100644 index 000000000..c5d0596ba --- /dev/null +++ b/svx/source/inc/svdobjplusdata.hxx @@ -0,0 +1,46 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* +* This file is part of the LibreOffice project. +* +* This Source Code Form is subject to the terms of the Mozilla Public +* License, v. 2.0. If a copy of the MPL was not distributed with this +* file, You can obtain one at http://mozilla.org/MPL/2.0/. +*/ + +#ifndef INCLUDED_SVX_SVDOBJPLUSDATA_HXX +#define INCLUDED_SVX_SVDOBJPLUSDATA_HXX + +#include <rtl/ustring.hxx> +#include <memory> + +class SdrObject; +class SfxBroadcaster; +class SdrObjUserDataList; +class SdrGluePointList; + +// Bitsack for DrawObjects +class SdrObjPlusData final +{ + friend class SdrObject; + + std::unique_ptr<SfxBroadcaster> pBroadcast; // broadcaster, if this object is referenced (bVirtObj=true). Also for connectors etc. + std::unique_ptr<SdrObjUserDataList> pUserDataList; // application specific data + std::unique_ptr<SdrGluePointList> pGluePoints; // glue points for glueing object connectors + + // #i68101# + // object name, title and description + OUString aObjName; + OUString aObjTitle; + OUString aObjDescription; + +public: + SdrObjPlusData(); + ~SdrObjPlusData(); + SdrObjPlusData* Clone(SdrObject* pObj1) const; + + void SetGluePoints(const SdrGluePointList& rPts); +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/inc/svdobjuserdatalist.hxx b/svx/source/inc/svdobjuserdatalist.hxx new file mode 100644 index 000000000..d2cb0e16a --- /dev/null +++ b/svx/source/inc/svdobjuserdatalist.hxx @@ -0,0 +1,37 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* +* This file is part of the LibreOffice project. +* +* This Source Code Form is subject to the terms of the Mozilla Public +* License, v. 2.0. If a copy of the MPL was not distributed with this +* file, You can obtain one at http://mozilla.org/MPL/2.0/. +*/ + +#ifndef INCLUDED_SVX_SVDOBJUSERDATALIST_HXX +#define INCLUDED_SVX_SVDOBJUSERDATALIST_HXX + +#include <svx/svdobj.hxx> + +#include <vector> +#include <memory> + +class SdrObjUserData; + +class SdrObjUserDataList +{ + typedef std::vector<std::unique_ptr<SdrObjUserData>> ListType; + ListType maList; + +public: + SdrObjUserDataList(); + ~SdrObjUserDataList(); + + size_t GetUserDataCount() const; + SdrObjUserData& GetUserData(size_t nNum); + void AppendUserData(std::unique_ptr<SdrObjUserData> pData); + void DeleteUserData(size_t nNum); +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/inc/svdoutlinercache.hxx b/svx/source/inc/svdoutlinercache.hxx new file mode 100644 index 000000000..01679f6b9 --- /dev/null +++ b/svx/source/inc/svdoutlinercache.hxx @@ -0,0 +1,51 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_SVX_SOURCE_INC_SVDOUTLINERCACHE_HXX +#define INCLUDED_SVX_SOURCE_INC_SVDOUTLINERCACHE_HXX + +#include <memory> +#include <vector> +#include <o3tl/sorted_vector.hxx> + +class SdrModel; +class SdrOutliner; +enum class OutlinerMode; + +class SdrOutlinerCache +{ +private: + SdrModel* mpModel; + std::vector< std::unique_ptr<SdrOutliner> > maModeOutline; + std::vector< std::unique_ptr<SdrOutliner> > maModeText; + o3tl::sorted_vector< SdrOutliner* > maActiveOutliners; + +public: + SdrOutlinerCache( SdrModel* pModel ); + ~SdrOutlinerCache(); + + std::unique_ptr<SdrOutliner> createOutliner( OutlinerMode nOutlinerMode ); + void disposeOutliner( std::unique_ptr<SdrOutliner> pOutliner ); + std::vector< SdrOutliner* > GetActiveOutliners() const; +}; + +#endif + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/inc/svdpdf.hxx b/svx/source/inc/svdpdf.hxx new file mode 100644 index 000000000..1f02b2151 --- /dev/null +++ b/svx/source/inc/svdpdf.hxx @@ -0,0 +1,148 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_SVX_SOURCE_SVDRAW_SVDPDF_HXX +#define INCLUDED_SVX_SOURCE_SVDRAW_SVDPDF_HXX + +#include <config_features.h> + +#if HAVE_FEATURE_PDFIUM +#include <sal/config.h> +#include <svx/svxdllapi.h> + +#include <memory> + +#include <tools/fract.hxx> +#include <vcl/virdev.hxx> +#include <vcl/graph.hxx> +#include <svx/svdobj.hxx> +#include <svx/xdash.hxx> + +#include <basegfx/matrix/b2dhommatrix.hxx> + +// Prevent workdir/UnpackedTarball/pdfium/public/fpdfview.h from including windows.h in a way that +// it will define e.g. Yield as a macro: +#include <prewin.h> +#include <postwin.h> +#include <fpdfview.h> + +#include <vcl/filter/PDFiumLibrary.hxx> + +// Forward Declarations + +class SfxItemSet; +class SdrObjList; +class SdrModel; +class SdrPage; +class SdrObject; +class SvdProgressInfo; + +// Helper Class to import PDF +class SVXCORE_DLLPUBLIC ImpSdrPdfImport final +{ + std::vector<SdrObject*> maTmpList; + ScopedVclPtr<VirtualDevice> mpVD; + tools::Rectangle maScaleRect; + size_t mnMapScalingOfs; // from here on, not edited with MapScaling + std::unique_ptr<SfxItemSet> mpLineAttr; + std::unique_ptr<SfxItemSet> mpFillAttr; + std::unique_ptr<SfxItemSet> mpTextAttr; + SdrModel* mpModel; + SdrLayerID mnLayer; + Color maOldLineColor; + sal_Int32 mnLineWidth; + static constexpr css::drawing::LineCap gaLineCap = css::drawing::LineCap_BUTT; + XDash maDash; + + bool mbMov; + bool mbSize; + Point maOfs; + double mfScaleX; + double mfScaleY; + Fraction maScaleX; + Fraction maScaleY; + + bool mbFntDirty; + + // to optimize (PenNULL,Brush,DrawPoly),(Pen,BrushNULL,DrawPoly) -> two-in-one + bool mbLastObjWasPolyWithoutLine; + bool mbNoLine; + bool mbNoFill; + + // clipregion + basegfx::B2DPolyPolygon maClip; + + FPDF_DOCUMENT mpPdfDocument; + int mnPageCount; + double mdPageWidthPts; + double mdPageHeightPts; + /// The current transformation matrix, typically used with Form objects. + basegfx::B2DHomMatrix maCurrentMatrix; + + /// Correct the vertical coordinate to start at the top. + /// PDF coordinate system has origin at the bottom right. + double correctVertOrigin(double offsetPts) const { return mdPageHeightPts - offsetPts; } + /// Convert PDF points to logic (twips). + tools::Rectangle PointsToLogic(double left, double right, double top, double bottom) const; + Point PointsToLogic(double x, double y) const; + + std::shared_ptr<vcl::pdf::PDFium> mpPDFium; + + // check for clip and evtl. fill maClip + void checkClip(); + bool isClip() const; + + void ImportPdfObject(FPDF_PAGEOBJECT pPageObject, FPDF_TEXTPAGE pTextPage, + int nPageObjectIndex); + void ImportForm(FPDF_PAGEOBJECT pPageObject, FPDF_TEXTPAGE pTextPage, int nPageObjectIndex); + void ImportImage(FPDF_PAGEOBJECT pPageObject, int nPageObjectIndex); + void ImportPath(FPDF_PAGEOBJECT pPageObject, int nPageObjectIndex); + void ImportText(FPDF_PAGEOBJECT pPageObject, FPDF_TEXTPAGE pTextPage, int nPageObjectIndex); + void InsertTextObject(const Point& rPos, const Size& rSize, const OUString& rStr); + + void SetupPageScale(const double dPageWidth, const double dPageHeight); + void SetAttributes(SdrObject* pObj, bool bForceTextAttr = false); + void InsertObj(SdrObject* pObj, bool bScale = true); + void MapScaling(); + + // #i73407# reformulation to use new B2DPolygon classes + bool CheckLastPolyLineAndFillMerge(const basegfx::B2DPolyPolygon& rPolyPolygon); + + void DoObjects(SvdProgressInfo* pProgrInfo, sal_uInt32* pActionsToReport, int nPageIndex); + + // Copy assignment is forbidden and not implemented. + ImpSdrPdfImport(const ImpSdrPdfImport&) = delete; + ImpSdrPdfImport& operator=(const ImpSdrPdfImport&) = delete; + +public: + ImpSdrPdfImport(SdrModel& rModel, SdrLayerID nLay, const tools::Rectangle& rRect, + Graphic const& rGraphic); + + ~ImpSdrPdfImport(); + + int GetPageCount() const { return mnPageCount; } + size_t DoImport(SdrObjList& rDestList, size_t nInsPos, int nPageNumber, + SvdProgressInfo* pProgrInfo = nullptr); +}; + +#endif // HAVE_FEATURE_PDFIUM + +#endif // INCLUDED_SVX_SOURCE_SVDRAW_SVDFMTF_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/inc/svxpixelctlaccessiblecontext.hxx b/svx/source/inc/svxpixelctlaccessiblecontext.hxx new file mode 100644 index 000000000..cdc767348 --- /dev/null +++ b/svx/source/inc/svxpixelctlaccessiblecontext.hxx @@ -0,0 +1,154 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_SVX_SOURCE_INC_SVXPIXELCTLACCESSIBLECONTEXT_HXX +#define INCLUDED_SVX_SOURCE_INC_SVXPIXELCTLACCESSIBLECONTEXT_HXX + +#include <com/sun/star/accessibility/XAccessible.hpp> +#include <com/sun/star/accessibility/XAccessibleContext.hpp> + +#include <com/sun/star/uno/Reference.hxx> +#include <comphelper/accessibleselectionhelper.hxx> + +#include <rtl/ref.hxx> +#include <tools/gen.hxx> + + +namespace com::sun::star::awt { + struct Point; + struct Rectangle; + struct Size; + class XFocusListener; +} +class SvxPixelCtl; +class SvxPixelCtlAccessible; + +typedef ::cppu::ImplHelper1<css::accessibility::XAccessible> OAccessibleHelper_Base; + +class SvxPixelCtlAccessibleChild final : public ::comphelper::OAccessibleComponentHelper, + public OAccessibleHelper_Base +{ +public: + SvxPixelCtlAccessibleChild( + SvxPixelCtl& rWindow, + bool bPixelColorOrBG, + const tools::Rectangle& rBounds, + const rtl::Reference<SvxPixelCtlAccessible>& xParent, + long nIndexInParent ); + + DECLARE_XINTERFACE( ) + DECLARE_XTYPEPROVIDER( ) + + //XAccessibleComponent + virtual void SAL_CALL grabFocus( ) override; + virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleAtPoint( const css::awt::Point& aPoint ) override; + + //XAccessibleContext + virtual sal_Int32 SAL_CALL getAccessibleChildCount( ) override; + virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleChild( sal_Int32 i ) override; + virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleParent( ) override; + virtual sal_Int16 SAL_CALL getAccessibleRole( ) override; + virtual OUString SAL_CALL getAccessibleDescription( ) override; + virtual OUString SAL_CALL getAccessibleName( ) override; + virtual css::uno::Reference< css::accessibility::XAccessibleRelationSet > SAL_CALL getAccessibleRelationSet( ) override; + virtual css::uno::Reference< css::accessibility::XAccessibleStateSet > SAL_CALL getAccessibleStateSet( ) override; + + //XAccessible + virtual css::uno::Reference< css::accessibility::XAccessibleContext > SAL_CALL getAccessibleContext( ) override; + + virtual sal_Int32 SAL_CALL getForeground( ) override; + virtual sal_Int32 SAL_CALL getBackground( ) override; + + void CheckChild(); + void SelectChild( bool bSelect); + void ChangePixelColorOrBG(bool bPixelColorOrBG){ m_bPixelColorOrBG = bPixelColorOrBG ;} + OUString GetName() const; + +private: + virtual ~SvxPixelCtlAccessibleChild() override; + + virtual void SAL_CALL disposing() override; + + // OCommonAccessibleComponent + /// implements the calculation of the bounding rectangle + virtual css::awt::Rectangle implGetBounds( ) override; + + SvxPixelCtl& mrParentWindow; + rtl::Reference<SvxPixelCtlAccessible> mxParent; + bool m_bPixelColorOrBG;//Pixel Color Or BackGround Color + tools::Rectangle maBoundingBox; + /// index of child in parent + long mnIndexInParent; +}; + +class SvxPixelCtlAccessible final : public ::comphelper::OAccessibleSelectionHelper, + public OAccessibleHelper_Base +{ +public: + SvxPixelCtlAccessible(SvxPixelCtl* pPixelCtl); + + DECLARE_XINTERFACE( ) + DECLARE_XTYPEPROVIDER( ) + + //XAccessibleComponent + virtual void SAL_CALL grabFocus( ) override; + virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleAtPoint( const css::awt::Point& aPoint ) override; + + //XAccessible + //XAccessibleContext + virtual sal_Int32 SAL_CALL getAccessibleChildCount( ) override; + virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleChild( sal_Int32 i ) override; + virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleParent( ) override; + virtual sal_Int16 SAL_CALL getAccessibleRole( ) override; + virtual OUString SAL_CALL getAccessibleDescription( ) override; + virtual OUString SAL_CALL getAccessibleName( ) override; + virtual css::uno::Reference< css::accessibility::XAccessibleRelationSet > SAL_CALL getAccessibleRelationSet( ) override; + virtual css::uno::Reference< css::accessibility::XAccessibleStateSet > SAL_CALL getAccessibleStateSet( ) override; + + virtual css::uno::Reference< css::accessibility::XAccessibleContext > SAL_CALL getAccessibleContext( ) override; + virtual sal_Int32 SAL_CALL getForeground( ) override; + virtual sal_Int32 SAL_CALL getBackground( ) override; + + css::uno::Reference< css::accessibility::XAccessible > + CreateChild (long nIndex, Point mPoint); + +private: + virtual ~SvxPixelCtlAccessible() override; + + // OCommonAccessibleSelection + // return if the specified child is visible => watch for special ChildIndexes (ACCESSIBLE_SELECTION_CHILD_xxx) + virtual bool implIsSelected(sal_Int32 nAccessibleChildIndex) override; + + // select the specified child => watch for special ChildIndexes (ACCESSIBLE_SELECTION_CHILD_xxx) + virtual void implSelect(sal_Int32 nAccessibleChildIndex, bool bSelect) override; + + // OCommonAccessibleComponent + virtual css::awt::Rectangle implGetBounds() override; + + virtual void SAL_CALL disposing() override; + + SvxPixelCtl* mpPixelCtl; + css::uno::Reference< css::accessibility::XAccessible> m_xCurChild; + +public: + void NotifyChild(long nIndex, bool bSelect, bool bCheck); +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/inc/svxrectctaccessiblecontext.hxx b/svx/source/inc/svxrectctaccessiblecontext.hxx new file mode 100644 index 000000000..291835b5e --- /dev/null +++ b/svx/source/inc/svxrectctaccessiblecontext.hxx @@ -0,0 +1,233 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + + +#ifndef INCLUDED_SVX_SOURCE_INC_SVXRECTCTACCESSIBLECONTEXT_HXX +#define INCLUDED_SVX_SOURCE_INC_SVXRECTCTACCESSIBLECONTEXT_HXX + +#include <com/sun/star/accessibility/XAccessible.hpp> +#include <com/sun/star/accessibility/XAccessibleContext.hpp> +#include <com/sun/star/accessibility/XAccessibleAction.hpp> +#include <com/sun/star/accessibility/XAccessibleValue.hpp> +#include <com/sun/star/uno/Reference.hxx> +#include <cppuhelper/implbase3.hxx> +#include <comphelper/accessibleselectionhelper.hxx> +#include <rtl/ref.hxx> +#include <svx/rectenum.hxx> +#include <tools/gen.hxx> +#include <vector> + +namespace com::sun::star::awt { + struct Point; + struct Rectangle; + struct Size; + class XFocusListener; +} +namespace tools { class Rectangle; } +class SvxRectCtl; +class SvxRectCtlChildAccessibleContext; +namespace vcl { class Window; } + +typedef ::cppu::ImplHelper1<css::accessibility::XAccessible> OAccessibleHelper_Base; + +class SvxRectCtlAccessibleContext final : public ::comphelper::OAccessibleSelectionHelper, + public OAccessibleHelper_Base +{ +public: + // internal + SvxRectCtlAccessibleContext(SvxRectCtl* pRepresentation); + + DECLARE_XINTERFACE( ) + DECLARE_XTYPEPROVIDER( ) + + // XAccessibleComponent + virtual void SAL_CALL grabFocus() override; + virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleAtPoint(const css::awt::Point& rPoint) override; + + // XAccessible + // XAccessibleContext + virtual sal_Int32 SAL_CALL getAccessibleChildCount() override; + virtual css::uno::Reference< css::accessibility::XAccessible> SAL_CALL getAccessibleChild(sal_Int32 nIndex) override; + virtual css::uno::Reference< css::accessibility::XAccessible> SAL_CALL getAccessibleParent() override; + virtual sal_Int16 SAL_CALL getAccessibleRole() override; + virtual OUString SAL_CALL getAccessibleDescription() override; + virtual OUString SAL_CALL getAccessibleName() override; + virtual css::uno::Reference< css::accessibility::XAccessibleRelationSet > SAL_CALL getAccessibleRelationSet() override; + virtual css::uno::Reference< css::accessibility::XAccessibleStateSet > SAL_CALL getAccessibleStateSet() override; + + virtual css::uno::Reference< css::accessibility::XAccessibleContext> SAL_CALL getAccessibleContext() override { return this; } + virtual sal_Int32 SAL_CALL getForeground() override; + virtual sal_Int32 SAL_CALL getBackground() override; + + /** Selects a new child by point. + + <p>If the child was not selected before, the state of the child will + be updated. If the point is not invalid, the index will internally set to NOCHILDSELECTED</p> + + @param eButton + Button which belongs to the child which should be selected. + */ + void selectChild( RectPoint ePoint ); + void FireChildFocus( RectPoint eButton ); + +private: + virtual ~SvxRectCtlAccessibleContext() override; + + // OCommonAccessibleSelection + // return if the specified child is visible => watch for special ChildIndexes (ACCESSIBLE_SELECTION_CHILD_xxx) + virtual bool implIsSelected(sal_Int32 nAccessibleChildIndex) override; + + // select the specified child => watch for special ChildIndexes (ACCESSIBLE_SELECTION_CHILD_xxx) + virtual void implSelect(sal_Int32 nAccessibleChildIndex, bool bSelect) override; + + // OCommonAccessibleComponent + virtual css::awt::Rectangle implGetBounds() override; + + virtual void SAL_CALL disposing() override; + + void checkChildIndex(long nIndex); + + /** Selects a new child by index. + + <p>If the child was not selected before, the state of the child will + be updated. If the index is invalid, the index will internally set to NOCHILDSELECTED</p> + + @param nIndexOfChild + Index of the new child which should be selected. + */ + void selectChild( long nIndexOfChild ); + + /** Description of this object. This is not a constant because it can + be set from the outside. + */ + OUString msDescription; + + /** Name of this object. + */ + OUString msName; + + /// pointer to internal representation + SvxRectCtl* mpRepr; + + /// array for all possible children + std::vector<rtl::Reference<SvxRectCtlChildAccessibleContext>> mvChildren; + + /// actual selected child + long mnSelectedChild; +}; + +typedef ::cppu::ImplHelper3 < css::accessibility::XAccessible, + css::accessibility::XAccessibleValue, + css::accessibility::XAccessibleAction + > OAccessibleHelper_Base_3; + +class SvxRectCtlChildAccessibleContext final : public ::comphelper::OAccessibleComponentHelper, + public OAccessibleHelper_Base_3 +{ +public: + SvxRectCtlChildAccessibleContext( + const css::uno::Reference< css::accessibility::XAccessible>& rxParent, + const OUString& rName, const OUString& rDescription, + const tools::Rectangle& rBoundingBox, + long nIndexInParent ); + + DECLARE_XINTERFACE( ) + DECLARE_XTYPEPROVIDER( ) + + // XAccessibleComponent + virtual void SAL_CALL grabFocus() override; + virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleAtPoint( const css::awt::Point& rPoint ) override; + + // XAccessibleContext + virtual sal_Int32 SAL_CALL getAccessibleChildCount() override; + virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleChild( sal_Int32 nIndex ) override; + virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleParent() override; + virtual sal_Int16 SAL_CALL getAccessibleRole() override; + virtual OUString SAL_CALL getAccessibleDescription() override; + virtual OUString SAL_CALL getAccessibleName() override; + virtual css::uno::Reference< css::accessibility::XAccessibleRelationSet > SAL_CALL getAccessibleRelationSet() override; + virtual css::uno::Reference< css::accessibility::XAccessibleStateSet > SAL_CALL getAccessibleStateSet() override; + + virtual css::uno::Reference< css::accessibility::XAccessibleContext> SAL_CALL getAccessibleContext() override { return this; } + + virtual sal_Int32 SAL_CALL getForeground() override; + virtual sal_Int32 SAL_CALL getBackground() override; + + // XAccessibleValue + virtual css::uno::Any SAL_CALL + getCurrentValue() override; + + virtual sal_Bool SAL_CALL + setCurrentValue( const css::uno::Any& aNumber ) override; + + virtual css::uno::Any SAL_CALL + getMaximumValue() override; + + virtual css::uno::Any SAL_CALL + getMinimumValue() override; + + // XAccessibleAction + virtual sal_Int32 SAL_CALL getAccessibleActionCount( ) override; + virtual sal_Bool SAL_CALL doAccessibleAction ( sal_Int32 nIndex ) override; + virtual OUString SAL_CALL getAccessibleActionDescription ( sal_Int32 nIndex ) override; + virtual css::uno::Reference< css::accessibility::XAccessibleKeyBinding > SAL_CALL getAccessibleActionKeyBinding( sal_Int32 nIndex ) override; + + // internal + /// Sets the checked status + void setStateChecked(bool bChecked); + void FireFocusEvent(); + +private: + virtual ~SvxRectCtlChildAccessibleContext() override; + + virtual void SAL_CALL disposing() override; + + // OCommonAccessibleComponent + /// implements the calculation of the bounding rectangle + virtual css::awt::Rectangle implGetBounds( ) override; + + /** Description of this object. This is not a constant because it can + be set from the outside. Furthermore, it changes according to the + draw page's display mode. + */ + OUString msDescription; + + /** Name of this object. It changes according the draw page's + display mode. + */ + OUString msName; + + /// Reference to the parent object. + css::uno::Reference< css::accessibility::XAccessible > + mxParent; + + /// Bounding box + tools::Rectangle maBoundingBox; + + /// index of child in parent + long mnIndexInParent; + + /// Indicates, if object is checked + bool mbIsChecked; +}; + + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/inc/tablemodel.hxx b/svx/source/inc/tablemodel.hxx new file mode 100644 index 000000000..c97b15be3 --- /dev/null +++ b/svx/source/inc/tablemodel.hxx @@ -0,0 +1,209 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_SVX_SOURCE_INC_TABLEMODEL_HXX +#define INCLUDED_SVX_SOURCE_INC_TABLEMODEL_HXX + +#include <sal/types.h> +#include <com/sun/star/util/XBroadcaster.hpp> +#include <com/sun/star/table/XTable.hpp> +#include <cppuhelper/compbase.hxx> +#include <cppuhelper/basemutex.hxx> +#include "celltypes.hxx" + +struct _xmlTextWriter; +typedef struct _xmlTextWriter* xmlTextWriterPtr; + +namespace sdr::table { + +class SdrTableObj; + +/** base class for each object implementing an XCellRange */ +class ICellRange +{ +public: + virtual sal_Int32 getLeft() = 0; + virtual sal_Int32 getTop() = 0; + virtual sal_Int32 getRight() = 0; + virtual sal_Int32 getBottom() = 0; + virtual css::uno::Reference< css::table::XTable > getTable() = 0; + +protected: + ~ICellRange() {} +}; + +typedef ::cppu::WeakComponentImplHelper< css::table::XTable, css::util::XBroadcaster > TableModelBase; + +class TableModel : public ::cppu::BaseMutex, + public TableModelBase, + public ICellRange +{ + friend class InsertRowUndo; + friend class RemoveRowUndo; + friend class InsertColUndo; + friend class RemoveColUndo; + friend class TableColumnUndo; + friend class TableRowUndo; + friend class TableColumn; + friend class TableRow; + friend class TableRows; + friend class TableColumns; + friend class TableModelNotifyGuard; + +public: + explicit TableModel( SdrTableObj* pTableObj ); + TableModel( SdrTableObj* pTableObj, const TableModelRef& xSourceTable ); + virtual ~TableModel() override; + + void init( sal_Int32 nColumns, sal_Int32 nRows ); + + SdrTableObj* getSdrTableObj() const { return mpTableObj; } + + /** deletes rows and columns that are completely merged. Must be called between BegUndo/EndUndo! */ + void optimize(); + + /// merges the cell at the given position with the given span + void merge( sal_Int32 nCol, sal_Int32 nRow, sal_Int32 nColSpan, sal_Int32 nRowSpan ); + /// Get the width of all columns in this table. + std::vector<sal_Int32> getColumnWidths(); + + void dumpAsXml(xmlTextWriterPtr pWriter) const; + + // ICellRange + virtual sal_Int32 getLeft() override; + virtual sal_Int32 getTop() override; + virtual sal_Int32 getRight() override; + virtual sal_Int32 getBottom() override; + virtual css::uno::Reference< css::table::XTable > getTable() override; + + // XTable + virtual css::uno::Reference< css::table::XCellCursor > SAL_CALL createCursor( ) override; + virtual css::uno::Reference< css::table::XCellCursor > SAL_CALL createCursorByRange( const css::uno::Reference< css::table::XCellRange >& rRange ) override; + virtual ::sal_Int32 SAL_CALL getRowCount() override; + virtual ::sal_Int32 SAL_CALL getColumnCount() override; + + // XComponent + virtual void SAL_CALL dispose( ) override; + + // XModifiable + virtual sal_Bool SAL_CALL isModified( ) override; + virtual void SAL_CALL setModified( sal_Bool bModified ) override; + + // XModifyBroadcaster + virtual void SAL_CALL addModifyListener( const css::uno::Reference< css::util::XModifyListener >& aListener ) override; + virtual void SAL_CALL removeModifyListener( const css::uno::Reference< css::util::XModifyListener >& aListener ) override; + + // XColumnRowRange + virtual css::uno::Reference< css::table::XTableColumns > SAL_CALL getColumns() override; + virtual css::uno::Reference< css::table::XTableRows > SAL_CALL getRows() override; + + // XCellRange + virtual css::uno::Reference< css::table::XCell > SAL_CALL getCellByPosition( ::sal_Int32 nColumn, ::sal_Int32 nRow ) override; + virtual css::uno::Reference< css::table::XCellRange > SAL_CALL getCellRangeByPosition( ::sal_Int32 nLeft, ::sal_Int32 nTop, ::sal_Int32 nRight, ::sal_Int32 nBottom ) override; + virtual css::uno::Reference< css::table::XCellRange > SAL_CALL getCellRangeByName( const OUString& aRange ) override; + + // XPropertySet + virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) override; + virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName, const css::uno::Any& aValue ) override; + virtual css::uno::Any SAL_CALL getPropertyValue( const OUString& PropertyName ) override; + virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener ) override; + virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener >& aListener ) override; + virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override; + virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override; + + // XFastPropertySet + virtual void SAL_CALL setFastPropertyValue( ::sal_Int32 nHandle, const css::uno::Any& aValue ) override; + virtual css::uno::Any SAL_CALL getFastPropertyValue( ::sal_Int32 nHandle ) override; + + // XBroadcaster + virtual void SAL_CALL lockBroadcasts() override; + virtual void SAL_CALL unlockBroadcasts() override; + +protected: + void notifyModification(); + + void insertColumns( sal_Int32 nIndex, sal_Int32 nCount ); + void removeColumns( sal_Int32 nIndex, sal_Int32 nCount ); + void insertRows( sal_Int32 nIndex, sal_Int32 nCount ); + void removeRows( sal_Int32 nIndex, sal_Int32 nCount ); + + sal_Int32 getRowCountImpl() const; + sal_Int32 getColumnCountImpl() const; + + CellRef createCell(); + CellRef getCell( ::sal_Int32 nCol, ::sal_Int32 nRow ) const; + + void UndoInsertRows( sal_Int32 nIndex, sal_Int32 nCount ); + void UndoRemoveRows( sal_Int32 nIndex, RowVector& aNewRows ); + + void UndoInsertColumns( sal_Int32 nIndex, sal_Int32 nCount ); + void UndoRemoveColumns( sal_Int32 nIndex, ColumnVector& aNewCols, CellVector& aCells ); + +private: + /** this function is called upon disposing the component + */ + virtual void SAL_CALL disposing() override; + + /// @throws css::lang::IndexOutOfBoundsException + TableRowRef const & getRow( sal_Int32 nRow ) const; + /// @throws css::lang::IndexOutOfBoundsException + TableColumnRef const & getColumn( sal_Int32 nColumn ) const; + + void updateRows(); + void updateColumns(); + + RowVector maRows; + ColumnVector maColumns; + + rtl::Reference< TableColumns > mxTableColumns; + rtl::Reference< TableRows > mxTableRows; + + SdrTableObj* mpTableObj; // TTTT should be reference + + bool mbModified; + bool mbNotifyPending; + + sal_Int32 mnNotifyLock; +}; + +class TableModelNotifyGuard +{ +public: + explicit TableModelNotifyGuard( TableModel* pModel ) + : mxBroadcaster( static_cast< css::util::XBroadcaster* >( pModel ) ) + { + if( mxBroadcaster.is() ) + mxBroadcaster->lockBroadcasts(); + } + + ~TableModelNotifyGuard() + { + if( mxBroadcaster.is() ) + mxBroadcaster->unlockBroadcasts(); + } + +private: + css::uno::Reference< css::util::XBroadcaster > mxBroadcaster; +}; + +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/inc/tabwin.hxx b/svx/source/inc/tabwin.hxx new file mode 100644 index 000000000..68cef73c0 --- /dev/null +++ b/svx/source/inc/tabwin.hxx @@ -0,0 +1,93 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_SVX_SOURCE_INC_TABWIN_HXX +#define INCLUDED_SVX_SOURCE_INC_TABWIN_HXX + +#include <sfx2/basedlgs.hxx> +#include <sfx2/childwin.hxx> +#include <sfx2/ctrlitem.hxx> +#include <svx/dbaexchange.hxx> +#include <com/sun/star/form/XForm.hpp> + +#include <comphelper/propmultiplex.hxx> +#include <connectivity/dbtools.hxx> + +class FmFormShell; +struct ColumnInfo; + +class FmFieldWin : public SfxModelessDialogController + , public SfxControllerItem + , public ::comphelper::OPropertyChangeListener +{ + ::osl::Mutex m_aMutex; + std::unique_ptr<weld::TreeView> m_xListBox; + std::vector<std::unique_ptr<ColumnInfo>> m_aListBoxData; + ::dbtools::SharedConnection + m_aConnection; + OUString m_aDatabaseName, + m_aObjectName; + sal_Int32 m_nObjectType; + + rtl::Reference<comphelper::OPropertyChangeMultiplexer> m_xChangeListener; + rtl::Reference<svx::OColumnTransferable> m_xHelper; + + void addToList(const css::uno::Reference<css::container::XNameAccess>& i_xColumns); + + DECL_LINK(RowActivatedHdl, weld::TreeView&, bool); + DECL_LINK(DragBeginHdl, bool&, bool); +public: + FmFieldWin(SfxBindings *pBindings, SfxChildWindow *pMgr, weld::Window* pParent); + + virtual ~FmFieldWin() override; + + virtual void StateChanged(sal_uInt16 nSID, SfxItemState eState, + const SfxPoolItem* pState) override; + + void UpdateContent(FmFormShell const *); + void UpdateContent(const css::uno::Reference< css::form::XForm > &); + void FillInfo( SfxChildWinInfo& rInfo ) const override; + + const OUString& GetDatabaseName() const { return m_aDatabaseName; } + const ::dbtools::SharedConnection& GetConnection() const { return m_aConnection; } + const OUString& GetObjectName() const { return m_aObjectName; } + sal_Int32 GetObjectType() const { return m_nObjectType; } + + bool createSelectionControls( ); + +protected: + // FmXChangeListener + virtual void _propertyChanged(const css::beans::PropertyChangeEvent& evt) override; + +protected: + using SfxControllerItem::GetBindings; +}; + + +class FmFieldWinMgr : public SfxChildWindow +{ +public: + FmFieldWinMgr(vcl::Window *pParent, sal_uInt16 nId, + SfxBindings *pBindings, SfxChildWinInfo const *pInfo); + SFX_DECL_CHILDWINDOW(FmFieldWinMgr); +}; + + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/inc/tbxform.hxx b/svx/source/inc/tbxform.hxx new file mode 100644 index 000000000..35471e9f1 --- /dev/null +++ b/svx/source/inc/tbxform.hxx @@ -0,0 +1,120 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_SVX_SOURCE_INC_TBXFORM_HXX +#define INCLUDED_SVX_SOURCE_INC_TBXFORM_HXX + +#include <sfx2/tbxctrl.hxx> +#include <vcl/InterimItemWindow.hxx> + +class SvxFmAbsRecWin final : public InterimItemWindow +{ +public: + SvxFmAbsRecWin( vcl::Window* _pParent, SfxToolBoxControl* _pController ); + virtual void dispose() override; + virtual ~SvxFmAbsRecWin() override; + + void set_text(const OUString& rText) { m_xWidget->set_text(rText); } + + virtual void GetFocus() override; + +private: + std::unique_ptr<weld::Entry> m_xWidget; + + DECL_LINK(KeyInputHdl, const KeyEvent&, bool); + DECL_LINK(ActivatedHdl, weld::Entry&, bool); + DECL_LINK(FocusOutHdl, weld::Widget&, void); // for invalidating our content when losing the focus + + void FirePosition( bool _bForce ); + + SfxToolBoxControl* m_pController; +}; + +class SvxFmTbxCtlAbsRec : public SfxToolBoxControl +{ +public: + SFX_DECL_TOOLBOX_CONTROL(); + + SvxFmTbxCtlAbsRec( sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx ); + virtual ~SvxFmTbxCtlAbsRec() override; + + virtual VclPtr<InterimItemWindow> CreateItemWindow( vcl::Window* pParent ) override; + + virtual void StateChanged( sal_uInt16 nSID, SfxItemState eState, + const SfxPoolItem* pState ) override; +}; + +class SvxFmTbxCtlRecText : public SfxToolBoxControl +{ +public: + SFX_DECL_TOOLBOX_CONTROL(); + + SvxFmTbxCtlRecText( sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx ); + virtual ~SvxFmTbxCtlRecText() override; + + virtual VclPtr<InterimItemWindow> CreateItemWindow( vcl::Window* pParent ) override; +}; + +class SvxFmTbxCtlRecFromText : public SfxToolBoxControl +{ +public: + SFX_DECL_TOOLBOX_CONTROL(); + + SvxFmTbxCtlRecFromText( sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx ); + virtual ~SvxFmTbxCtlRecFromText() override; + + virtual VclPtr<InterimItemWindow> CreateItemWindow( vcl::Window* pParent ) override; +}; + +class LabelItemWindow; + +class SvxFmTbxCtlRecTotal : public SfxToolBoxControl +{ + VclPtr<LabelItemWindow> m_xFixedText; + +public: + SFX_DECL_TOOLBOX_CONTROL(); + + SvxFmTbxCtlRecTotal( sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx ); + virtual ~SvxFmTbxCtlRecTotal() override; + + virtual VclPtr<InterimItemWindow> CreateItemWindow( vcl::Window* pParent ) override; + virtual void StateChanged( sal_uInt16 nSID, SfxItemState eState, + const SfxPoolItem* pState ) override; +}; + + +class SvxFmTbxNextRec : public SfxToolBoxControl +{ +public: + SFX_DECL_TOOLBOX_CONTROL(); + SvxFmTbxNextRec( sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx ); +}; + + +class SvxFmTbxPrevRec : public SfxToolBoxControl +{ +public: + SFX_DECL_TOOLBOX_CONTROL(); + SvxFmTbxPrevRec( sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx ); +}; + + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/inc/treevisitor.hxx b/svx/source/inc/treevisitor.hxx new file mode 100644 index 000000000..50e7d7a35 --- /dev/null +++ b/svx/source/inc/treevisitor.hxx @@ -0,0 +1,104 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_SVX_SOURCE_INC_TREEVISITOR_HXX +#define INCLUDED_SVX_SOURCE_INC_TREEVISITOR_HXX + +#include <stack> + +template< class ELEMENT, class NODEINFO, class PROCESSOR > +class TreeVisitor +{ +public: + TreeVisitor( NODEINFO _nodeInfo ) + :m_visitedRoot( false ) + ,m_root() + ,m_current() + ,m_nodeInfo( _nodeInfo ) + { + } + + void process( const ELEMENT& _root, PROCESSOR& _processor ) + { + m_root = _root; + m_visitedRoot = false; + + while ( do_step() ) + _processor.process( m_current ); + } + +private: + bool do_step(); + +private: + bool m_visitedRoot; + ELEMENT m_root; + ELEMENT m_current; + const NODEINFO m_nodeInfo; + + ::std::stack< size_t > m_pathToCurrent; + ::std::stack< ELEMENT > m_currentAncestors; +}; + +template< class ELEMENT, class NODEINFO, class PROCESSOR > +bool TreeVisitor< ELEMENT, NODEINFO, PROCESSOR >::do_step() +{ + if ( !m_visitedRoot ) + { + m_current = m_root; + m_visitedRoot = true; + return true; + } + + // can we step down from the current node? + size_t childCount = m_nodeInfo.childCount( m_current ); + if ( childCount ) + { + m_currentAncestors.push( m_current ); + m_current = m_nodeInfo.getChild( m_current, 0 ); + m_pathToCurrent.push( 0 ); + return true; + } + + // is there a right sibling of the current node? + while ( !m_pathToCurrent.empty() ) + { + const ELEMENT& currentParent = m_currentAncestors.top(); + childCount = m_nodeInfo.childCount( currentParent ); + + size_t currentChildPos = m_pathToCurrent.top(); + if ( ++currentChildPos < childCount ) + { + // yes there is + m_pathToCurrent.top() = currentChildPos; + m_current = m_nodeInfo.getChild( currentParent, currentChildPos ); + return true; + } + + // no there isn't => step up + m_currentAncestors.pop(); + m_pathToCurrent.pop(); + } + + return false; +} + +#endif // INCLUDED_SVX_SOURCE_INC_TREEVISITOR_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/inc/xfm_addcondition.hxx b/svx/source/inc/xfm_addcondition.hxx new file mode 100644 index 000000000..10d4674cb --- /dev/null +++ b/svx/source/inc/xfm_addcondition.hxx @@ -0,0 +1,76 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_SVX_SOURCE_INC_XFM_ADDCONDITION_HXX +#define INCLUDED_SVX_SOURCE_INC_XFM_ADDCONDITION_HXX + +#include <com/sun/star/lang/XMultiServiceFactory.hpp> +#include <com/sun/star/xforms/XModel.hpp> +#include <svtools/genericunodialog.hxx> +#include <comphelper/proparrhlp.hxx> + + +namespace svxform +{ + + typedef ::svt::OGenericUnoDialog OAddConditionDialogBase; + class OAddConditionDialog final + :public OAddConditionDialogBase + ,public ::comphelper::OPropertyArrayUsageHelper< OAddConditionDialog > + { + public: + static css::uno::Reference< css::uno::XInterface > + Create( const css::uno::Reference< css::lang::XMultiServiceFactory >& ); + + private: + OAddConditionDialog( const css::uno::Reference< css::uno::XComponentContext >& _rxORB ); + + // XTypeProvider + virtual css::uno::Sequence<sal_Int8> SAL_CALL getImplementationId( ) override; + + // XServiceInfo + virtual OUString SAL_CALL getImplementationName() override; + virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override; + + // XPropertySet + virtual css::uno::Reference<css::beans::XPropertySetInfo> SAL_CALL getPropertySetInfo() override; + virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper() override; + + // OPropertyArrayUsageHelper + virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const override; + + // OGenericUnoDialog overridables + virtual std::unique_ptr<weld::DialogController> createDialog(const css::uno::Reference<css::awt::XWindow>& rParent) override; + virtual void executedDialog(sal_Int16 _nExecutionResult) override; + + css::uno::Reference< css::beans::XPropertySet > + m_xBinding; + OUString m_sFacetName; + OUString m_sConditionValue; + css::uno::Reference< css::xforms::XModel > + m_xWorkModel; + }; + + +} + + +#endif // INCLUDED_SVX_SOURCE_INC_XFM_ADDCONDITION_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/inc/xmlxtexp.hxx b/svx/source/inc/xmlxtexp.hxx new file mode 100644 index 000000000..51435e5fb --- /dev/null +++ b/svx/source/inc/xmlxtexp.hxx @@ -0,0 +1,64 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_SVX_SOURCE_INC_XMLXTEXP_HXX +#define INCLUDED_SVX_SOURCE_INC_XMLXTEXP_HXX + +#include <xmloff/xmlexp.hxx> + +namespace com::sun::star { + namespace frame { class XModel; } + namespace uno { template<class X> class Reference; } + namespace uno { class XInterface; } + namespace container { class XNameContainer; } + namespace document { class XGraphicStorageHandler; } + namespace xml::sax { class XDocumentHandler; } +} + +class SvxXMLXTableExportComponent : public SvXMLExport +{ +public: + SvxXMLXTableExportComponent( + const css::uno::Reference< css::uno::XComponentContext >& xContext, + const OUString& rFileName, + const css::uno::Reference< css::xml::sax::XDocumentHandler > & xHandler, + const css::uno::Reference< css::container::XNameContainer > & xTable, + css::uno::Reference<css::document::XGraphicStorageHandler> const & xGraphicStorageHandler); + + virtual ~SvxXMLXTableExportComponent() override; + + /// @throws css::uno::RuntimeException + static bool save( const OUString& rURL, + const css::uno::Reference< css::container::XNameContainer >& xTable, + const css::uno::Reference< css::embed::XStorage > &xStorage, + OUString *pOptName ); + + // methods without content: + virtual void ExportAutoStyles_() override; + virtual void ExportMasterStyles_() override; + virtual void ExportContent_() override; + +private: + bool exportTable() throw(); + const css::uno::Reference< css::container::XNameContainer > & mxTable; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/inc/xmlxtimp.hxx b/svx/source/inc/xmlxtimp.hxx new file mode 100644 index 000000000..99d5b4135 --- /dev/null +++ b/svx/source/inc/xmlxtimp.hxx @@ -0,0 +1,56 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_SVX_SOURCE_INC_XMLXTIMP_HXX +#define INCLUDED_SVX_SOURCE_INC_XMLXTIMP_HXX + +#include <xmloff/xmlimp.hxx> + +namespace com::sun::star { + namespace uno { template<class X> class Reference; } + namespace uno { class XInterface; } + namespace document { class XGraphicStorageHandler; } + namespace container { class XNameContainer; } +} + +class SvxXMLXTableImport : public SvXMLImport +{ +public: + SvxXMLXTableImport( + const css::uno::Reference< css::uno::XComponentContext >& rContext, + const css::uno::Reference< css::container::XNameContainer > & rTable, + css::uno::Reference<css::document::XGraphicStorageHandler> const & rxGraphicStorageHandler); + + virtual ~SvxXMLXTableImport() throw () override; + + static bool load( const OUString &rPath, const OUString &rReferer, + const css::uno::Reference < css::embed::XStorage > &xStorage, + const css::uno::Reference< css::container::XNameContainer >& xTable, + bool *bOptLoadedFromStorage ) throw(); +protected: + virtual SvXMLImportContext *CreateFastContext( sal_Int32 Element, + const ::css::uno::Reference< ::css::xml::sax::XFastAttributeList >& xAttrList ) override; + +private: + const css::uno::Reference< css::container::XNameContainer > & mrTable; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |