diff options
Diffstat (limited to 'sc/source/ui/inc')
253 files changed, 30174 insertions, 0 deletions
diff --git a/sc/source/ui/inc/AccessibilityHints.hxx b/sc/source/ui/inc/AccessibilityHints.hxx new file mode 100644 index 000000000..fbb8ce65a --- /dev/null +++ b/sc/source/ui/inc/AccessibilityHints.hxx @@ -0,0 +1,60 @@ +/* -*- 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_SC_SOURCE_UI_INC_ACCESSIBILITYHINTS_HXX +#define INCLUDED_SC_SOURCE_UI_INC_ACCESSIBILITYHINTS_HXX + +#include "viewdata.hxx" +#include <svl/hint.hxx> + +class ScAccWinFocusLostHint : public SfxHint +{ +public: + virtual ~ScAccWinFocusLostHint() override; +}; + +class ScAccWinFocusGotHint : public SfxHint +{ +public: + virtual ~ScAccWinFocusGotHint() override; +}; + +class ScAccGridWinFocusLostHint : public ScAccWinFocusLostHint +{ + ScSplitPos eOldGridWin; +public: + ScAccGridWinFocusLostHint( ScSplitPos eOldGridWin ); + virtual ~ScAccGridWinFocusLostHint() override; + + ScSplitPos GetOldGridWin() const { return eOldGridWin; } +}; + +class ScAccGridWinFocusGotHint : public ScAccWinFocusGotHint +{ + ScSplitPos eNewGridWin; +public: + ScAccGridWinFocusGotHint( ScSplitPos eNewGridWin ); + virtual ~ScAccGridWinFocusGotHint() override; + + ScSplitPos GetNewGridWin() const { return eNewGridWin; } +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/AccessibleCell.hxx b/sc/source/ui/inc/AccessibleCell.hxx new file mode 100644 index 000000000..7cc5683a6 --- /dev/null +++ b/sc/source/ui/inc/AccessibleCell.hxx @@ -0,0 +1,169 @@ +/* -*- 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_SC_SOURCE_UI_INC_ACCESSIBLECELL_HXX +#define INCLUDED_SC_SOURCE_UI_INC_ACCESSIBLECELL_HXX + +#include <memory> +#include "AccessibleCellBase.hxx" +#include "viewdata.hxx" +#include <com/sun/star/accessibility/XAccessibleExtendedAttributes.hpp> +#include <rtl/ref.hxx> +#include <editeng/AccessibleStaticTextBase.hxx> +#include <comphelper/uno3.hxx> + +namespace com::sun::star::accessibility { class XAccessibleRelationSet; } +namespace utl { class AccessibleRelationSetHelper; } + +class ScTabViewShell; +class ScAccessibleDocument; + +typedef cppu::ImplHelper1< css::accessibility::XAccessibleExtendedAttributes> + ScAccessibleCellAttributeImpl; + +/** @descr + This base class provides an implementation of the + <code>AccessibleCell</code> service. +*/ +class ScAccessibleCell + : public ScAccessibleCellBase, + public accessibility::AccessibleStaticTextBase, + public ScAccessibleCellAttributeImpl +{ +public: + static rtl::Reference<ScAccessibleCell> create( + const css::uno::Reference<css::accessibility::XAccessible>& rxParent, + ScTabViewShell* pViewShell, + const ScAddress& rCellAddress, + sal_Int32 nIndex, + ScSplitPos eSplitPos, + ScAccessibleDocument* pAccDoc); + +private: + ScAccessibleCell( + const css::uno::Reference<css::accessibility::XAccessible>& rxParent, + ScTabViewShell* pViewShell, + const ScAddress& rCellAddress, + sal_Int32 nIndex, + ScSplitPos eSplitPos, + ScAccessibleDocument* pAccDoc); + + virtual void Init() override; + + using ScAccessibleCellBase::disposing; + virtual void SAL_CALL disposing() override; + +protected: + virtual ~ScAccessibleCell() override; + + using ScAccessibleCellBase::IsDefunc; + +public: + ///===== XInterface ===================================================== + + DECLARE_XINTERFACE() + + ///===== XTypeProvider =================================================== + + DECLARE_XTYPEPROVIDER() + + ///===== XAccessibleComponent ============================================ + + virtual css::uno::Reference< css::accessibility::XAccessible > + SAL_CALL getAccessibleAtPoint( const css::awt::Point& rPoint ) override; + + virtual void SAL_CALL grabFocus( ) override; + +protected: + /// Return the object's current bounding box relative to the desktop. + virtual tools::Rectangle GetBoundingBoxOnScreen() const override; + + /// Return the object's current bounding box relative to the parent object. + virtual tools::Rectangle GetBoundingBox() const override; + +public: + ///===== XAccessibleContext ============================================== + + /// Return the number of currently visible children. + /// override to calculate this on demand + virtual sal_Int32 SAL_CALL + getAccessibleChildCount() override; + + /// Return the specified child or NULL if index is invalid. + /// override to calculate this on demand + virtual css::uno::Reference< css::accessibility::XAccessible> SAL_CALL + getAccessibleChild(sal_Int32 nIndex) override; + + /// Return the set of current states. + virtual css::uno::Reference< + css::accessibility::XAccessibleStateSet> SAL_CALL + getAccessibleStateSet() override; + + virtual css::uno::Reference< + css::accessibility::XAccessibleRelationSet> SAL_CALL + getAccessibleRelationSet() override; + + ///===== XServiceInfo ==================================================== + + /** Returns an identifier for the implementation of this object. + */ + virtual OUString SAL_CALL + getImplementationName() override; + + /** Returns a list of all supported services. + */ + virtual css::uno::Sequence< OUString> SAL_CALL + getSupportedServiceNames() override; + + virtual css::uno::Any SAL_CALL getExtendedAttributes() override; + + // Override this method to handle cell's ParaIndent attribute specially. + virtual css::uno::Sequence< css::beans::PropertyValue > SAL_CALL getCharacterAttributes( sal_Int32 nIndex, const css::uno::Sequence< OUString >& aRequestedAttributes ) override; +private: + ScTabViewShell* mpViewShell; + ScAccessibleDocument* mpAccDoc; + + ScSplitPos meSplitPos; + + bool IsDefunc( + const css::uno::Reference<css::accessibility::XAccessibleStateSet>& rxParentStates); + virtual bool IsEditable( + const css::uno::Reference<css::accessibility::XAccessibleStateSet>& rxParentStates) override; + bool IsOpaque() const; + bool IsSelected(); + + static ScDocument* GetDocument(ScTabViewShell* mpViewShell); + + ::std::unique_ptr< SvxEditSource > CreateEditSource(ScTabViewShell* pViewShell, ScAddress aCell, ScSplitPos eSplitPos); + + void FillDependents(utl::AccessibleRelationSetHelper* pRelationSet); + void FillPrecedents(utl::AccessibleRelationSetHelper* pRelationSet); + void AddRelation(const ScAddress& rCell, + const sal_uInt16 aRelationType, + ::utl::AccessibleRelationSetHelper* pRelationSet); + void AddRelation(const ScRange& rRange, + const sal_uInt16 aRelationType, + ::utl::AccessibleRelationSetHelper* pRelationSet); + bool IsFormulaMode(); + bool IsDropdown() const; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/AccessibleCellBase.hxx b/sc/source/ui/inc/AccessibleCellBase.hxx new file mode 100644 index 000000000..2fb00ee47 --- /dev/null +++ b/sc/source/ui/inc/AccessibleCellBase.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_SC_SOURCE_UI_INC_ACCESSIBLECELLBASE_HXX +#define INCLUDED_SC_SOURCE_UI_INC_ACCESSIBLECELLBASE_HXX + +#include "AccessibleContextBase.hxx" +#include <address.hxx> +#include <com/sun/star/accessibility/XAccessibleValue.hpp> +#include <cppuhelper/implbase1.hxx> + +typedef cppu::ImplHelper1< css::accessibility::XAccessibleValue> + ScAccessibleCellBaseImpl; + +class ScAccessibleCellBase + : public ScAccessibleContextBase, + public ScAccessibleCellBaseImpl +{ +public: + //===== internal ======================================================== + ScAccessibleCellBase( + const css::uno::Reference<css::accessibility::XAccessible>& rxParent, + ScDocument* pDoc, + const ScAddress& rCellAddress, + sal_Int32 nIndex); +protected: + virtual ~ScAccessibleCellBase() override; +public: + + virtual bool isVisible() override; + + ///===== XInterface ===================================================== + + virtual css::uno::Any SAL_CALL queryInterface( + css::uno::Type const & rType ) override; + + virtual void SAL_CALL acquire() throw () override; + + virtual void SAL_CALL release() throw () override; + + ///===== XAccessibleComponent ============================================ + + virtual sal_Int32 SAL_CALL getForeground( ) override; + + virtual sal_Int32 SAL_CALL getBackground( ) override; + + ///===== XAccessibleContext ============================================== + + /// Return this objects index among the parents children. + virtual sal_Int32 SAL_CALL + getAccessibleIndexInParent() override; + +protected: + /// Return this object's description. + virtual OUString + createAccessibleDescription() override; + + /// Return the object's current name. + virtual OUString + createAccessibleName() override; + +public: + ///===== 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; + + ///===== XServiceInfo ==================================================== + + /** Returns an identifier for the implementation of this object. + */ + virtual OUString SAL_CALL + getImplementationName() override; + + ///===== XTypeProvider =================================================== + + /// returns the possible types + virtual css::uno::Sequence< css::uno::Type > SAL_CALL + getTypes() override; + + /** Returns an implementation id. + */ + virtual css::uno::Sequence<sal_Int8> SAL_CALL + getImplementationId() override; + +protected: + ScAddress maCellAddress; + + ScDocument* mpDoc; + + sal_Int32 mnIndex; + +private: + virtual bool IsEditable( + const css::uno::Reference<css::accessibility::XAccessibleStateSet>& rxParentStates); +protected: + /// @throw css::uno::RuntimeException + OUString GetNote() const; + + /// @throw css::uno::RuntimeException + OUString GetAllDisplayNote() const; + /// @throw css::uno::RuntimeException + OUString getShadowAttrs() const; + /// @throw css::uno::RuntimeException + OUString getBorderAttrs(); +public: + const ScAddress& GetCellAddress() const { return maCellAddress; } +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/AccessibleContextBase.hxx b/sc/source/ui/inc/AccessibleContextBase.hxx new file mode 100644 index 000000000..670f3add4 --- /dev/null +++ b/sc/source/ui/inc/AccessibleContextBase.hxx @@ -0,0 +1,289 @@ +/* -*- 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_SC_SOURCE_UI_INC_ACCESSIBLECONTEXTBASE_HXX +#define INCLUDED_SC_SOURCE_UI_INC_ACCESSIBLECONTEXTBASE_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/uno/Reference.hxx> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <cppuhelper/interfacecontainer.h> + +#include <svl/lstner.hxx> +#include <cppuhelper/basemutex.hxx> +#include <cppuhelper/compbase5.hxx> +#include <cppuhelper/implbase1.hxx> + +namespace tools { class Rectangle; } + +/** @descr + This base class provides an implementation of the + <code>AccessibleContext</code> service. +*/ + +typedef cppu::WeakAggComponentImplHelper5< + css::accessibility::XAccessible, + css::accessibility::XAccessibleComponent, + css::accessibility::XAccessibleContext, + css::accessibility::XAccessibleEventBroadcaster, + css::lang::XServiceInfo + > ScAccessibleContextBaseWeakImpl; + +typedef cppu::ImplHelper1< + css::accessibility::XAccessibleEventListener + > ScAccessibleContextBaseImplEvent; + +class ScAccessibleContextBase + : public cppu::BaseMutex, + public ScAccessibleContextBaseWeakImpl, + public ScAccessibleContextBaseImplEvent, + public SfxListener +{ +public: + //===== internal ======================================================== + ScAccessibleContextBase( + const css::uno::Reference<css::accessibility::XAccessible>& rxParent, + const sal_Int16 aRole); + + virtual void Init(); + virtual void SAL_CALL disposing() override; +protected: + virtual ~ScAccessibleContextBase() override; +public: + + /// @throws css::uno::RuntimeException + bool isShowing(); + + /// @throws css::uno::RuntimeException + virtual bool isVisible(); + + ///===== SfxListener ===================================================== + + virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override; + + ///===== XInterface ===================================================== + + virtual css::uno::Any SAL_CALL queryInterface( + css::uno::Type const & rType ) override; + + virtual void SAL_CALL acquire() throw () override; + + virtual void SAL_CALL release() throw () 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 ============================================== + + /// Return the number of currently visible children. + virtual sal_Int32 SAL_CALL getAccessibleChildCount() override; + + /// Return the specified child or NULL if index is invalid. + virtual css::uno::Reference< css::accessibility::XAccessible> SAL_CALL + getAccessibleChild(sal_Int32 nIndex) override; + + /// Return a reference to the parent. + virtual css::uno::Reference< css::accessibility::XAccessible> SAL_CALL + getAccessibleParent() override; + + /// Return this objects index among the parents children. + virtual sal_Int32 SAL_CALL + getAccessibleIndexInParent() override; + + /// Return this object's role. + virtual sal_Int16 SAL_CALL + getAccessibleRole() override; + + /// Return this object's description. + virtual OUString SAL_CALL + getAccessibleDescription() override; + + /// Return the object's current name. + virtual OUString SAL_CALL + getAccessibleName() override; + + /// Return NULL to indicate that an empty relation set. + virtual css::uno::Reference<css::accessibility::XAccessibleRelationSet> SAL_CALL + getAccessibleRelationSet() override; + + /// Return the set of current states. + virtual css::uno::Reference<css::accessibility::XAccessibleStateSet> SAL_CALL + getAccessibleStateSet() override; + + /** Return the parents locale or throw exception if this object has no + parent yet/anymore. + */ + virtual css::lang::Locale SAL_CALL + getLocale() override; + + ///===== XAccessibleEventBroadcaster ===================================== + + /** Add listener that is informed of future changes of name, + description and so on events. + */ + virtual void SAL_CALL + addAccessibleEventListener( + const css::uno::Reference<css::accessibility::XAccessibleEventListener>& xListener) override; + + // Remove an existing event listener. + virtual void SAL_CALL + removeAccessibleEventListener( + const css::uno::Reference<css::accessibility::XAccessibleEventListener>& xListener) override; + + ///===== XAccessibleEventListener ======================================== + + virtual void SAL_CALL + disposing( const css::lang::EventObject& Source ) override; + + virtual void SAL_CALL + notifyEvent( + const css::accessibility::AccessibleEventObject& aEvent ) override; + + ///===== XServiceInfo ==================================================== + + /** Returns an identifier for the implementation of this object. + */ + virtual OUString SAL_CALL + getImplementationName() override; + + /** Return whether the specified service is supported by this class. + */ + virtual sal_Bool SAL_CALL + supportsService(const OUString& sServiceName) override; + + /** Returns a list of all supported services. In this case that is just + the AccessibleContext and Accessible service. + */ + virtual css::uno::Sequence< OUString> SAL_CALL + getSupportedServiceNames() override; + + ///===== XTypeProvider =================================================== + + /// returns the possible types + virtual css::uno::Sequence< css::uno::Type > SAL_CALL + getTypes() override; + + /** Returns an implementation id. + */ + virtual css::uno::Sequence<sal_Int8> SAL_CALL + getImplementationId() override; + +protected: + /// Return this object's description. + /// + /// @throws css::uno::RuntimeException + virtual OUString + createAccessibleDescription(); + + /// Return the object's current name. + /// + /// @throws css::uno::RuntimeException + virtual OUString + createAccessibleName(); + + /// Return the object's current bounding box relative to the desktop. + /// + /// @throws css::uno::RuntimeException + virtual tools::Rectangle GetBoundingBoxOnScreen() const; + + /// Return the object's current bounding box relative to the parent object. + /// + /// @throws css::uno::RuntimeException + virtual tools::Rectangle GetBoundingBox() const; + +public: + /// Calls all Listener to tell they the change. + void + CommitChange(const css::accessibility::AccessibleEventObject& rEvent) const; + + /// Use this method to set initial Name without notification + void SetName(const OUString& rName) { msName = rName; } + + /// Use this method to set initial Description without notification + void SetDescription(const OUString& rDesc) { msDescription = rDesc; } + + void SetParent(const css::uno::Reference<css::accessibility::XAccessible>& rParent) { mxParent = rParent; } + +protected: + /// Calls all FocusListener to tell they that the focus is gained. + void CommitFocusGained() const; + + /// Calls all FocusListener to tell they that the focus is lost. + void CommitFocusLost() const; + + bool IsDefunc() const { return rBHelper.bDisposed; } + + /// @throws css::lang::DisposedException + void IsObjectValid() const; + + /// Reference to the parent object. + css::uno::Reference<css::accessibility::XAccessible> mxParent; + +private: + /** 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; + + /// client id in the AccessibleEventNotifier queue + sal_uInt32 mnClientId; + + /** This is the role of this object. + */ + sal_Int16 maRole; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/AccessibleCsvControl.hxx b/sc/source/ui/inc/AccessibleCsvControl.hxx new file mode 100644 index 000000000..575b855b7 --- /dev/null +++ b/sc/source/ui/inc/AccessibleCsvControl.hxx @@ -0,0 +1,517 @@ +/* -*- 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_SC_SOURCE_UI_INC_ACCESSIBLECSVCONTROL_HXX +#define INCLUDED_SC_SOURCE_UI_INC_ACCESSIBLECSVCONTROL_HXX + +#include <memory> +#include <com/sun/star/accessibility/AccessibleRole.hpp> +#include <com/sun/star/accessibility/AccessibleScrollType.hpp> +#include <com/sun/star/accessibility/XAccessibleText.hpp> +#include <com/sun/star/accessibility/XAccessibleTable.hpp> +#include <com/sun/star/accessibility/XAccessibleSelection.hpp> +#include <tools/gen.hxx> +#include <rtl/ustrbuf.hxx> +#include <comphelper/accessiblecomponenthelper.hxx> +#include <cppuhelper/implbase1.hxx> +#include <cppuhelper/implbase2.hxx> +#include <cppuhelper/implbase3.hxx> +#include <editeng/AccessibleStaticTextBase.hxx> +#include <comphelper/uno3.hxx> +#include <vcl/vclptr.hxx> +#include "AccessibleContextBase.hxx" +#include <map> + +class ScCsvControl; +namespace utl { class AccessibleStateSetHelper; } + +/** Accessible base class used for CSV controls. */ +class ScAccessibleCsvControl : public comphelper::OAccessibleComponentHelper +{ +private: + ScCsvControl* mpControl; /// Pointer to the VCL control. + +public: + explicit ScAccessibleCsvControl(ScCsvControl& rControl); + virtual ~ScAccessibleCsvControl() override; + + virtual void SAL_CALL disposing() override; + + virtual void SAL_CALL grabFocus( ) override; + virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleAtPoint( const css::awt::Point& aPoint ) override; + + // events ----------------------------------------------------------------- +public: + /** Sends a GetFocus or LoseFocus event to all listeners. */ + virtual void SendFocusEvent( bool bFocused ); + /** Sends a caret changed event to all listeners. */ + virtual void SendCaretEvent(); + /** Sends a visible area changed event to all listeners. */ + void SendVisibleEvent(); + /** Sends a selection changed event to all listeners. */ + void SendSelectionEvent(); + /** Sends a table model changed event for changed cell contents to all listeners. */ + virtual void SendTableUpdateEvent( sal_uInt32 nFirstColumn, sal_uInt32 nLastColumn, bool bAllRows ); + /** Sends a table model changed event for an inserted column to all listeners. */ + virtual void SendInsertColumnEvent( sal_uInt32 nFirstColumn, sal_uInt32 nLastColumn ); + /** Sends a table model changed event for a removed column to all listeners. */ + virtual void SendRemoveColumnEvent( sal_uInt32 nFirstColumn, sal_uInt32 nLastColumn ); + + // helpers ---------------------------------------------------------------- +protected: + virtual css::awt::Rectangle implGetBounds() override; + + /** Returns the VCL control. Assumes a living object. */ + ScCsvControl& implGetControl() const; + + /** Creates a StateSetHelper and fills it with DEFUNC, OPAQUE, ENABLED, SHOWING and VISIBLE. */ + ::utl::AccessibleStateSetHelper* implCreateStateSet(); +}; + +class ScCsvRuler; + +typedef ::cppu::ImplHelper2<css::accessibility::XAccessible, + css::accessibility::XAccessibleText> ScAccessibleCsvRulerImpl; + +/** Accessible class representing the CSV ruler control. */ +class ScAccessibleCsvRuler : public ScAccessibleCsvControl, public ScAccessibleCsvRulerImpl +{ +private: + OUStringBuffer maBuffer; /// Contains the text representation of the ruler. + +public: + explicit ScAccessibleCsvRuler( ScCsvRuler& rRuler ); + virtual ~ScAccessibleCsvRuler() override; + + // XAccessibleComponent ----------------------------------------------------- + virtual css::uno::Reference< css::accessibility::XAccessibleContext > SAL_CALL getAccessibleContext( ) override { return this; } + + virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleParent( ) override; + + virtual OUString SAL_CALL getAccessibleDescription( ) override; + virtual OUString SAL_CALL getAccessibleName( ) override; + + virtual sal_Int32 SAL_CALL getForeground( ) override; + + virtual sal_Int32 SAL_CALL getBackground( ) override; + + // XAccessibleContext ----------------------------------------------------- + + /** Returns the child count (the ruler does not have children). */ + virtual sal_Int32 SAL_CALL getAccessibleChildCount() override; + + /** Throws an exception (the ruler does not have children). */ + virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleChild( sal_Int32 nIndex ) override; + + virtual sal_Int16 SAL_CALL getAccessibleRole( ) override { return css::accessibility::AccessibleRole::TEXT; } + + /** Returns the relation to the grid control. */ + virtual css::uno::Reference< css::accessibility::XAccessibleRelationSet > SAL_CALL getAccessibleRelationSet() override; + + /** Returns the current set of states. */ + virtual css::uno::Reference< css::accessibility::XAccessibleStateSet > SAL_CALL getAccessibleStateSet() override; + + // XAccessibleText -------------------------------------------------------- + + /** Return the position of the caret. */ + virtual sal_Int32 SAL_CALL getCaretPosition() override; + + /** Sets the position of the caret. */ + virtual sal_Bool SAL_CALL setCaretPosition( sal_Int32 nIndex ) override; + + /** Returns the specified character. */ + virtual sal_Unicode SAL_CALL getCharacter( sal_Int32 nIndex ) override; + + /** Returns the attributes of the specified character. */ + virtual css::uno::Sequence< css::beans::PropertyValue > SAL_CALL getCharacterAttributes( sal_Int32 nIndex, const css::uno::Sequence< OUString >& aRequestedAttributes ) override; + + /** Returns the screen coordinates of the specified character. */ + virtual css::awt::Rectangle SAL_CALL getCharacterBounds( sal_Int32 nIndex ) override; + + /** Returns the count of characters. */ + virtual sal_Int32 SAL_CALL getCharacterCount() override; + + /** Returns the character index at the specified coordinate (object's coordinate system). */ + virtual sal_Int32 SAL_CALL getIndexAtPoint( const css::awt::Point& rPoint ) override; + + /** Returns the selected text (ruler returns empty string). */ + virtual OUString SAL_CALL getSelectedText() override; + + /** Returns the start index of the selection (ruler returns -1). */ + virtual sal_Int32 SAL_CALL getSelectionStart() override; + + /** Returns the end index of the selection (ruler returns -1). */ + virtual sal_Int32 SAL_CALL getSelectionEnd() override; + + /** Selects a part of the text (ruler does nothing). */ + virtual sal_Bool SAL_CALL setSelection( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) override; + + /** Returns the entire text. */ + virtual OUString SAL_CALL getText() override; + + /** Returns the specified range [Start,End) of the text. */ + virtual OUString SAL_CALL getTextRange( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) override; + + /** Returns the specified text portion. */ + virtual css::accessibility::TextSegment SAL_CALL getTextAtIndex( sal_Int32 nIndex, sal_Int16 aTextType ) override; + virtual css::accessibility::TextSegment SAL_CALL getTextBeforeIndex( sal_Int32 nIndex, sal_Int16 aTextType ) override; + virtual css::accessibility::TextSegment SAL_CALL getTextBehindIndex( sal_Int32 nIndex, sal_Int16 aTextType ) override; + + /** Copies the specified text range into the clipboard (ruler does nothing). */ + virtual sal_Bool SAL_CALL copyText( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) override; + + virtual sal_Bool SAL_CALL scrollSubstringTo( sal_Int32 nStartIndex, sal_Int32 nEndIndex, css::accessibility::AccessibleScrollType aScrollType) override; + + // XInterface ------------------------------------------------------------- + + DECLARE_XINTERFACE() + + // XTypeProvider ---------------------------------------------------------- + + DECLARE_XTYPEPROVIDER() + + // events ----------------------------------------------------------------- +public: + /** Sends a caret changed event to all listeners. */ + virtual void SendCaretEvent() override; + + // helpers ---------------------------------------------------------------- +private: + + /** @throws css::lang::IndexOutOfBoundsException if the specified character position is invalid (outside 0..len-1). */ + void ensureValidIndex( sal_Int32 nIndex ) const; + /** @throws css::lang::IndexOutOfBoundsException if the specified character position is invalid (outside 0..len). */ + void ensureValidIndexWithEnd( sal_Int32 nIndex ) const; + /** @throws css::lang::IndexOutOfBoundsException if the specified character range [Start,End) is invalid. + @descr If Start>End, swaps Start and End before checking. */ + void ensureValidRange( sal_Int32& rnStartIndex, sal_Int32& rnEndIndex ) const; + + /** Returns the VCL ruler control. Assumes a living object. */ + ScCsvRuler& implGetRuler() const; + + /** Builds the entire string buffer. + + @throws css::uno::RuntimeException + */ + void constructStringBuffer(); + /** Returns the character count of the text. */ + sal_Int32 implGetTextLength() const; + + /** Returns true, if the character at the specified index has a split. */ + bool implHasSplit( sal_Int32 nApiPos ); + + /** Returns the first character index with equal formatting as at nApiPos. */ + sal_Int32 implGetFirstEqualFormatted( sal_Int32 nApiPos ); + /** Returns the last character index with equal formatting as at nApiPos. */ + sal_Int32 implGetLastEqualFormatted( sal_Int32 nApiPos ); +}; + +class ScCsvGrid; +class ScAccessibleCsvCell; + +typedef ::cppu::ImplHelper3< + css::accessibility::XAccessible, + css::accessibility::XAccessibleTable, + css::accessibility::XAccessibleSelection > + ScAccessibleCsvGridImpl; + +/** Accessible class representing the CSV grid control. */ +class ScAccessibleCsvGrid : public ScAccessibleCsvControl, public ScAccessibleCsvGridImpl +{ +protected: + typedef std::map< sal_Int32, rtl::Reference<ScAccessibleCsvCell> > XAccessibleSet; + +private: + XAccessibleSet maAccessibleChildren; + +public: + explicit ScAccessibleCsvGrid( ScCsvGrid& rGrid ); + virtual ~ScAccessibleCsvGrid() override; + virtual void SAL_CALL disposing() override; + + // XAccessibleComponent --------------------------------------------------- + virtual css::uno::Reference< css::accessibility::XAccessibleContext > SAL_CALL getAccessibleContext( ) override { return this; } + + virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleParent( ) override; + + /** Returns the cell at the specified point. */ + virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleAtPoint( const css::awt::Point& rPoint ) override; + + virtual OUString SAL_CALL getAccessibleDescription( ) override; + virtual OUString SAL_CALL getAccessibleName( ) override; + + virtual sal_Int32 SAL_CALL getForeground( ) override; + + virtual sal_Int32 SAL_CALL getBackground( ) override; + + virtual sal_Int16 SAL_CALL getAccessibleRole( ) override { return css::accessibility::AccessibleRole::TABLE; } + + // XAccessibleContext ----------------------------------------------------- + + /** Returns the child count (count of cells in the table). */ + virtual sal_Int32 SAL_CALL getAccessibleChildCount() override; + + /** Returns the specified child cell. */ + virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleChild( sal_Int32 nIndex ) override; + + /** Returns the relation to the ruler control. */ + virtual css::uno::Reference< css::accessibility::XAccessibleRelationSet > SAL_CALL getAccessibleRelationSet() override; + + /** Returns the current set of states. */ + virtual css::uno::Reference< css::accessibility::XAccessibleStateSet > SAL_CALL getAccessibleStateSet() override; + + // XAccessibleTable ------------------------------------------------------- + + /** Returns the number of rows in the table. */ + virtual sal_Int32 SAL_CALL getAccessibleRowCount() override; + + /** Returns the number of columns in the table. */ + virtual sal_Int32 SAL_CALL getAccessibleColumnCount() override; + + /** Returns the description of the specified row in the table. */ + virtual OUString SAL_CALL getAccessibleRowDescription( sal_Int32 nRow ) override; + + /** Returns the description text of the specified column in the table. */ + virtual OUString SAL_CALL getAccessibleColumnDescription( sal_Int32 nColumn ) override; + + /** Returns the number of rows occupied at a specified row and column. + @descr Returns always 1 (Merged cells not supported). */ + virtual sal_Int32 SAL_CALL getAccessibleRowExtentAt( sal_Int32 nRow, sal_Int32 nColumn ) override; + + /** Returns the number of rows occupied at a specified row and column. + @descr Returns always 1 (Merged cells not supported). */ + virtual sal_Int32 SAL_CALL getAccessibleColumnExtentAt( sal_Int32 nRow, sal_Int32 nColumn ) override; + + /** Returns the row headers as an AccessibleTable. */ + virtual css::uno::Reference< css::accessibility::XAccessibleTable > SAL_CALL getAccessibleRowHeaders() override; + + /** Returns the column headers as an AccessibleTable. */ + virtual css::uno::Reference< css::accessibility::XAccessibleTable > SAL_CALL getAccessibleColumnHeaders() override; + + /** Returns the selected rows as a sequence. */ + virtual css::uno::Sequence< sal_Int32 > SAL_CALL getSelectedAccessibleRows() override; + + /** Returns the selected columns as a sequence. */ + virtual css::uno::Sequence< sal_Int32 > SAL_CALL getSelectedAccessibleColumns() override; + + /** Returns true, if the specified row is selected. */ + virtual sal_Bool SAL_CALL isAccessibleRowSelected( sal_Int32 nRow ) override; + + /** Returns true, if the specified column is selected. */ + virtual sal_Bool SAL_CALL isAccessibleColumnSelected( sal_Int32 nColumn ) override; + + /** Returns the accessible cell object at the specified position. */ + virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleCellAt( sal_Int32 nRow, sal_Int32 nColumn ) override; + + /** Returns the caption object of the table. */ + virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleCaption() override; + + /** Returns the summary description object of the table. */ + virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleSummary() override; + + /** Returns true, if the cell at a specified position is selected. */ + virtual sal_Bool SAL_CALL isAccessibleSelected( sal_Int32 nRow, sal_Int32 nColumn ) override; + + /** Returns the child index of the cell at the specified position. */ + virtual sal_Int32 SAL_CALL getAccessibleIndex( sal_Int32 nRow, sal_Int32 nColumn ) override; + + /** Returns the row index of the specified child. */ + virtual sal_Int32 SAL_CALL getAccessibleRow( sal_Int32 nChildIndex ) override; + + /** Returns the column index of the specified child. */ + virtual sal_Int32 SAL_CALL getAccessibleColumn( sal_Int32 nChildIndex ) override; + + // XAccessibleSelection --------------------------------------------------- + + /** Selects the specified child (selects the entire column or the entire table). */ + virtual void SAL_CALL selectAccessibleChild( sal_Int32 nChildIndex ) override; + + /** Returns true, if the specified child is selected. */ + virtual sal_Bool SAL_CALL isAccessibleChildSelected( sal_Int32 nChildIndex ) override; + + /** Deselects all cells. */ + virtual void SAL_CALL clearAccessibleSelection() override; + + /** Selects all cells. */ + virtual void SAL_CALL selectAllAccessibleChildren() override; + + /** Returns the count of selected children. */ + virtual sal_Int32 SAL_CALL getSelectedAccessibleChildCount() override; + + /** Returns the child with the specified index in all selected children. */ + virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex ) override; + + /** Deselects the child with the specified index in all selected children. */ + virtual void SAL_CALL deselectAccessibleChild( sal_Int32 nSelectedChildIndex ) override; + + // XInterface ------------------------------------------------------------- + + virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type& rType ) override; + + virtual void SAL_CALL acquire() throw() override; + + virtual void SAL_CALL release() throw() override; + + // XTypeProvider ---------------------------------------------------------- + + /** Returns a sequence with all supported interface types. */ + virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override; + + /** Returns an implementation ID. */ + virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override; + + // events ----------------------------------------------------------------- +public: + /** Sends a GetFocus or LoseFocus event to all listeners. */ + virtual void SendFocusEvent( bool bFocused ) override; + /** Sends a table model changed event for changed cell contents to all listeners. */ + virtual void SendTableUpdateEvent( sal_uInt32 nFirstColumn, sal_uInt32 nLastColumn, bool bAllRows ) override; + /** Sends a table model changed event for an inserted column to all listeners. */ + virtual void SendInsertColumnEvent( sal_uInt32 nFirstColumn, sal_uInt32 nLastColumn ) override; + /** Sends a table model changed event for a removed column to all listeners. */ + virtual void SendRemoveColumnEvent( sal_uInt32 nFirstColumn, sal_uInt32 nLastColumn ) override; + + // helpers ---------------------------------------------------------------- +private: + + /** @throws css::lang::IndexOutOfBoundsException if nIndex is not a valid child index. */ + void ensureValidIndex( sal_Int32 nIndex ) const; + /** @Throws css::lang::IndexOutOfBoundsException if the specified position is invalid. */ + void ensureValidPosition( sal_Int32 nRow, sal_Int32 nColumn ) const; + + /** Returns the VCL grid control. Assumes a living object. */ + ScCsvGrid& implGetGrid() const; + + /** Returns true, if the specified column (including header) is selected. */ + bool implIsColumnSelected( sal_Int32 nColumn ) const; + /** Selects the specified column (including header). */ + void implSelectColumn( sal_Int32 nColumn, bool bSelect ); + + /** Returns the count of visible rows in the table (including header). */ + sal_Int32 implGetRowCount() const; + /** Returns the total column count in the table (including header). */ + sal_Int32 implGetColumnCount() const; + /** Returns the count of selected columns in the table. */ + sal_Int32 implGetSelColumnCount() const; + /** Returns the total cell count in the table (including header). */ + sal_Int32 implGetCellCount() const { return implGetRowCount() * implGetColumnCount(); } + + /** Returns the row index from cell index (including header). */ + sal_Int32 implGetRow( sal_Int32 nIndex ) const { return nIndex / implGetColumnCount(); } + /** Returns the column index from cell index (including header). */ + sal_Int32 implGetColumn( sal_Int32 nIndex ) const { return nIndex % implGetColumnCount(); } + /** Returns the absolute column index of the nSelColumn-th selected column. */ + sal_Int32 implGetSelColumn( sal_Int32 nSelColumn ) const; + /** Returns the child index from cell position (including header). */ + sal_Int32 implGetIndex( sal_Int32 nRow, sal_Int32 nColumn ) const { return nRow * implGetColumnCount() + nColumn; } + + /** Returns the contents of the specified cell (including header). Indexes must be valid. */ + OUString implGetCellText( sal_Int32 nRow, sal_Int32 nColumn ) const; + /** Creates a new accessible object of the specified cell. Indexes must be valid. */ + ScAccessibleCsvCell* implCreateCellObj(sal_Int32 nRow, sal_Int32 nColumn); + + css::uno::Reference<css::accessibility::XAccessible> getAccessibleCell(sal_Int32 nRow, sal_Int32 nColumn); +}; + +typedef ::cppu::ImplHelper1<css::accessibility::XAccessible> ScAccessibleCsvCellImpl; + +/** Accessible class representing a cell of the CSV grid control. */ +class ScAccessibleCsvCell : public ScAccessibleCsvControl + , public ScAccessibleCsvCellImpl + , public ::accessibility::AccessibleStaticTextBase +{ +protected: + typedef ::std::unique_ptr< SvxEditSource > SvxEditSourcePtr; + +private: + OUString maCellText; /// The text contents of this cell. + sal_Int32 mnLine; /// The grid line index (core index). + sal_uInt32 mnColumn; /// The grid column index (core index). + sal_Int32 mnIndex; /// The index of the cell in the table. + +public: + explicit ScAccessibleCsvCell( + ScCsvGrid& rGrid, + const OUString& rCellText, + sal_Int32 nRow, sal_Int32 nColumn); + virtual ~ScAccessibleCsvCell() override; + + virtual void SAL_CALL disposing() override; + + // XAccessibleComponent --------------------------------------------------- + + /** Sets the focus to the column of this cell. */ + virtual void SAL_CALL grabFocus() override; + + virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleParent( ) override; + + virtual css::uno::Reference< css::accessibility::XAccessibleContext > SAL_CALL getAccessibleContext( ) override { return this; } + + virtual OUString SAL_CALL getAccessibleDescription( ) override; + virtual OUString SAL_CALL getAccessibleName( ) override; + virtual sal_Int16 SAL_CALL getAccessibleRole( ) override { return css::accessibility::AccessibleRole::TEXT; } + + virtual sal_Int32 SAL_CALL getForeground( ) override; + + virtual sal_Int32 SAL_CALL getBackground( ) override; + + // XAccessibleContext ----------------------------------------------------- + + /** Returns the child count. */ + virtual sal_Int32 SAL_CALL getAccessibleChildCount() override; + + /** Returns the specified child. */ + virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleChild( sal_Int32 nIndex ) override; + + /** Returns the index of this cell in the table. */ + virtual sal_Int32 SAL_CALL getAccessibleIndexInParent() override; + + /** Returns the relation to the ruler control. */ + virtual css::uno::Reference< css::accessibility::XAccessibleRelationSet > SAL_CALL getAccessibleRelationSet() override; + + /** Returns the current set of states. */ + virtual css::uno::Reference< css::accessibility::XAccessibleStateSet > SAL_CALL getAccessibleStateSet() override; + + // XInterface ------------------------------------------------------------- + + DECLARE_XINTERFACE() + + // XTypeProvider ---------------------------------------------------------- + + DECLARE_XTYPEPROVIDER() + +private: + /** Returns the VCL grid control. Assumes a living object. */ + ScCsvGrid& implGetGrid() const; + /** Returns the pixel position of the cell (rel. to parent), regardless of visibility. */ + Point implGetRealPos() const; + /** Returns the width of the character count */ + sal_uInt32 implCalcPixelWidth(sal_uInt32 nChars) const; + /** Returns the pixel size of the cell, regardless of visibility. */ + Size implGetRealSize() const; + /** Returns the bounding box of the cell relative in the table. */ + virtual css::awt::Rectangle implGetBounds() override; + + /** Creates the edit source the text helper needs. */ + ::std::unique_ptr< SvxEditSource > implCreateEditSource(); +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/AccessibleDocument.hxx b/sc/source/ui/inc/AccessibleDocument.hxx new file mode 100644 index 000000000..364fbcb3e --- /dev/null +++ b/sc/source/ui/inc/AccessibleDocument.hxx @@ -0,0 +1,267 @@ +/* -*- 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_SC_SOURCE_UI_INC_ACCESSIBLEDOCUMENT_HXX +#define INCLUDED_SC_SOURCE_UI_INC_ACCESSIBLEDOCUMENT_HXX + +#include "AccessibleDocumentBase.hxx" +#include "viewdata.hxx" +#include <com/sun/star/accessibility/XAccessibleSelection.hpp> +#include <com/sun/star/view/XSelectionChangeListener.hpp> +#include <cppuhelper/implbase3.hxx> +#include <com/sun/star/accessibility/XAccessibleExtendedAttributes.hpp> +#include <svx/IAccessibleViewForwarder.hxx> + +class ScTabViewShell; +class ScAccessibleSpreadsheet; +class ScChildrenShapes; +class ScAccessibleEditObject; +class VclWindowEvent; + +namespace utl +{ + class AccessibleRelationSetHelper; +} + +/** @descr + This base class provides an implementation of the + <code>AccessibleContext</code> service. +*/ + +typedef cppu::ImplHelper3< css::accessibility::XAccessibleSelection, + css::accessibility::XAccessibleExtendedAttributes, + css::view::XSelectionChangeListener > + ScAccessibleDocumentImpl; + +class ScAccessibleDocument + : public ScAccessibleDocumentBase, + public ScAccessibleDocumentImpl, + public accessibility::IAccessibleViewForwarder +{ +public: + //===== internal ======================================================== + ScAccessibleDocument( + const css::uno::Reference<css::accessibility::XAccessible>& rxParent, + ScTabViewShell* pViewShell, + ScSplitPos eSplitPos); + + void PreInit(); + + virtual void Init() override; + + DECL_LINK( WindowChildEventListener, VclWindowEvent&, void ); +protected: + virtual ~ScAccessibleDocument() override; + + using ScAccessibleDocumentBase::IsDefunc; + +public: + + virtual void SAL_CALL disposing() override; + + ///===== SfxListener ===================================================== + + virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override; + + ///===== XInterface ===================================================== + + virtual css::uno::Any SAL_CALL queryInterface( + css::uno::Type const & rType ) override; + + virtual void SAL_CALL acquire() throw () override; + + virtual void SAL_CALL release() throw () override; + + ///===== XAccessibleComponent ============================================ + + virtual css::uno::Reference< css::accessibility::XAccessible > + SAL_CALL getAccessibleAtPoint( + const css::awt::Point& rPoint ) override; + + virtual void SAL_CALL grabFocus( ) override; + + ///===== XAccessibleContext ============================================== + + /// Return the number of currently visible children. + virtual sal_Int32 SAL_CALL + getAccessibleChildCount() override; + + /// Return the specified child or NULL if index is invalid. + virtual css::uno::Reference< css::accessibility::XAccessible> SAL_CALL + getAccessibleChild(sal_Int32 nIndex) override; + + /// Return the set of current states. + virtual css::uno::Reference< + css::accessibility::XAccessibleStateSet> SAL_CALL + getAccessibleStateSet() override; + + virtual OUString SAL_CALL + getAccessibleName() override; + + virtual css::uno::Any SAL_CALL getExtendedAttributes() 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 nChildIndex ) override; + + ///===== XSelectionListener ============================================= + + virtual void SAL_CALL selectionChanged( const css::lang::EventObject& aEvent ) override; + + virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override; + + ///===== XServiceInfo =================================================== + + /** Returns an identifier for the implementation of this object. + */ + virtual OUString SAL_CALL + getImplementationName() override; + + /** Returns a list of all supported services. + */ + virtual css::uno::Sequence< OUString> SAL_CALL + getSupportedServiceNames() override; + + ///===== XTypeProvider =================================================== + + /// returns the possible types + virtual css::uno::Sequence< css::uno::Type > SAL_CALL + getTypes() override; + + /** Returns an implementation id. + */ + virtual css::uno::Sequence<sal_Int8> SAL_CALL + getImplementationId() override; + + ///===== IAccessibleViewForwarder ======================================== + + /** Returns the area of the underlying document that is visible in the + * corresponding window. + + @return + The rectangle of the visible part of the document. The values + are, contrary to the base class, in internal coordinates. + */ + virtual tools::Rectangle GetVisibleArea() const override; + + /** Transform the specified point from internal coordinates to an + absolute screen position. + + @param rPoint + Point in internal coordinates. + + @return + The same point but in screen coordinates relative to the upper + left corner of the (current) screen. + */ + virtual Point LogicToPixel (const Point& rPoint) const override; + + /** Transform the specified size from internal coordinates to a screen + * oriented pixel size. + + @param rSize + Size in internal coordinates. + + @return + The same size but in screen coordinates. + */ + virtual Size LogicToPixel (const Size& rSize) const override; + + ///======== internal ===================================================== + + utl::AccessibleRelationSetHelper* GetRelationSet(const ScAddress* pAddress) const; + + css::uno::Reference< css::accessibility::XAccessible > + GetAccessibleSpreadsheet(); + +protected: + /// Return this object's description. + virtual OUString + createAccessibleDescription() override; + + /// Return the object's current name. + virtual OUString + createAccessibleName() override; + + /// Return the object's current bounding box relative to the desktop. + virtual tools::Rectangle GetBoundingBoxOnScreen() const override; + + /// Return the object's current bounding box relative to the parent object. + virtual tools::Rectangle GetBoundingBox() const override; + +private: + ScTabViewShell* mpViewShell; + ScSplitPos meSplitPos; + rtl::Reference<ScAccessibleSpreadsheet> mpAccessibleSpreadsheet; + std::unique_ptr<ScChildrenShapes> mpChildrenShapes; + ScAccessibleEditObject* mpTempAccEdit; + css::uno::Reference<css::accessibility::XAccessible> mxTempAcc; + tools::Rectangle maVisArea; + bool mbCompleteSheetSelected; + +public: + SCTAB getVisibleTable() const; // use it in ScChildrenShapes + +private: + void FreeAccessibleSpreadsheet(); + + bool IsTableSelected() const; + + bool IsDefunc( + const css::uno::Reference<css::accessibility::XAccessibleStateSet>& rxParentStates); + + void AddChild(const css::uno::Reference<css::accessibility::XAccessible>& xAcc, bool bFireEvent); + void RemoveChild(const css::uno::Reference<css::accessibility::XAccessible>& xAcc, bool bFireEvent); + + OUString GetCurrentCellName() const; + static OUString GetCurrentCellDescription(); + + tools::Rectangle GetVisibleArea_Impl() const; + css::uno::Sequence< css::uno::Any > GetScAccFlowToSequence(); +public: + ScDocument *GetDocument() const ; + ScAddress GetCurCellAddress() const; + + virtual sal_Int32 SAL_CALL getForeground( ) override; + + virtual sal_Int32 SAL_CALL getBackground( ) override; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/AccessibleDocumentBase.hxx b/sc/source/ui/inc/AccessibleDocumentBase.hxx new file mode 100644 index 000000000..bd2a27aa3 --- /dev/null +++ b/sc/source/ui/inc/AccessibleDocumentBase.hxx @@ -0,0 +1,38 @@ +/* -*- 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_SC_SOURCE_UI_INC_ACCESSIBLEDOCUMENTBASE_HXX +#define INCLUDED_SC_SOURCE_UI_INC_ACCESSIBLEDOCUMENTBASE_HXX + +#include "AccessibleContextBase.hxx" + +class ScAccessibleDocumentBase + : public ScAccessibleContextBase +{ +public: + //===== internal ======================================================== + ScAccessibleDocumentBase( + const css::uno::Reference<css::accessibility::XAccessible>& rxParent); +protected: + virtual ~ScAccessibleDocumentBase() override; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/AccessibleDocumentPagePreview.hxx b/sc/source/ui/inc/AccessibleDocumentPagePreview.hxx new file mode 100644 index 000000000..a433c46de --- /dev/null +++ b/sc/source/ui/inc/AccessibleDocumentPagePreview.hxx @@ -0,0 +1,135 @@ +/* -*- 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_SC_SOURCE_UI_INC_ACCESSIBLEDOCUMENTPAGEPREVIEW_HXX +#define INCLUDED_SC_SOURCE_UI_INC_ACCESSIBLEDOCUMENTPAGEPREVIEW_HXX + +#include <sal/config.h> + +#include <rtl/ref.hxx> + +#include "AccessibleDocumentBase.hxx" + +class ScPreviewShell; +class ScNotesChildren; +class ScShapeChildren; +class ScAccessiblePreviewTable; +class ScAccessiblePageHeader; + +class ScAccessibleDocumentPagePreview + : public ScAccessibleDocumentBase +{ +public: + //===== internal ======================================================== + ScAccessibleDocumentPagePreview( + const css::uno::Reference<css::accessibility::XAccessible>& rxParent, + ScPreviewShell* pViewShell ); +protected: + virtual ~ScAccessibleDocumentPagePreview() override; + + using ScAccessibleDocumentBase::IsDefunc; + +public: + using ScAccessibleContextBase::disposing; + + virtual void SAL_CALL disposing() override; + + ///===== SfxListener ===================================================== + + virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override; + + ///===== XAccessibleComponent ============================================ + + virtual css::uno::Reference< css::accessibility::XAccessible > + SAL_CALL getAccessibleAtPoint( + const css::awt::Point& rPoint ) override; + + virtual void SAL_CALL grabFocus( ) override; + + ///===== XAccessibleContext ============================================== + + /// Return the number of currently visible children. + virtual sal_Int32 SAL_CALL getAccessibleChildCount() override; + + /// Return the specified child or NULL if index is invalid. + virtual css::uno::Reference< css::accessibility::XAccessible> SAL_CALL + getAccessibleChild(sal_Int32 nIndex) override; + + /// Return the set of current states. + virtual css::uno::Reference< + css::accessibility::XAccessibleStateSet> SAL_CALL + getAccessibleStateSet() override; + + virtual OUString SAL_CALL getAccessibleName() override; + ///===== XServiceInfo ==================================================== + + /** Returns an identifier for the implementation of this object. + */ + virtual OUString SAL_CALL + getImplementationName() override; + + /** Returns a list of all supported services. + */ + virtual css::uno::Sequence< OUString> SAL_CALL + getSupportedServiceNames() override; + + ///===== XTypeProvider =================================================== + + /** Returns an implementation id. + */ + virtual css::uno::Sequence<sal_Int8> SAL_CALL + getImplementationId() override; + + ///===== internal ======================================================== + +protected: + /// Return this object's description. + virtual OUString + createAccessibleDescription() override; + + /// Return the object's current name. + virtual OUString + createAccessibleName() override; + +public: // needed in ScShapeChildren + /// Return the object's current bounding box relative to the desktop. + virtual tools::Rectangle GetBoundingBoxOnScreen() const override; + +protected: + /// Return the object's current bounding box relative to the parent object. + virtual tools::Rectangle GetBoundingBox() const override; + +private: + ScPreviewShell* mpViewShell; + std::unique_ptr<ScNotesChildren> mpNotesChildren; + std::unique_ptr<ScShapeChildren> mpShapeChildren; + rtl::Reference<ScAccessiblePreviewTable> mpTable; + rtl::Reference<ScAccessiblePageHeader> mpHeader; + rtl::Reference<ScAccessiblePageHeader> mpFooter; + + bool IsDefunc( + const css::uno::Reference<css::accessibility::XAccessibleStateSet>& rxParentStates); + + ScNotesChildren* GetNotesChildren(); + ScShapeChildren* GetShapeChildren(); +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/AccessibleEditObject.hxx b/sc/source/ui/inc/AccessibleEditObject.hxx new file mode 100644 index 000000000..aee06efb3 --- /dev/null +++ b/sc/source/ui/inc/AccessibleEditObject.hxx @@ -0,0 +1,225 @@ +/* -*- 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_SC_SOURCE_UI_INC_ACCESSIBLEEDITOBJECT_HXX +#define INCLUDED_SC_SOURCE_UI_INC_ACCESSIBLEEDITOBJECT_HXX + +#include "AccessibleContextBase.hxx" + +#include <com/sun/star/accessibility/XAccessibleSelection.hpp> +#include <address.hxx> +#include <vcl/vclptr.hxx> +#include <vcl/customweld.hxx> + +#include <memory> + +namespace accessibility +{ + class AccessibleTextHelper; +} +class EditView; +namespace vcl { class Window; } + +/** @descr + This base class provides an implementation of the + <code>AccessibleCell</code> service. +*/ +class ScAccessibleEditObject + : public ScAccessibleContextBase, + public css::accessibility::XAccessibleSelection +{ +public: + enum EditObjectType + { + CellInEditMode, + EditLine, + EditControl + }; + + ScAccessibleEditObject( + const css::uno::Reference<css::accessibility::XAccessible>& rxParent, + EditView* pEditView, vcl::Window* pWin, const OUString& rName, + const OUString& rDescription, EditObjectType eObjectType); + + void InitAcc( + const css::uno::Reference<css::accessibility::XAccessible>& rxParent, + EditView* pEditView, vcl::Window* pWin, const OUString& rName, + const OUString& rDescription); + +protected: + virtual ~ScAccessibleEditObject() override; + + ScAccessibleEditObject(EditObjectType eObjectType); + + using ScAccessibleContextBase::IsDefunc; + +public: + using ScAccessibleContextBase::disposing; + + virtual void SAL_CALL disposing() override; + + void LostFocus(); + + void GotFocus(); +///===== XInterface ===================================================== + + virtual css::uno::Any SAL_CALL queryInterface( + css::uno::Type const & rType ) override; + + virtual void SAL_CALL acquire() throw () override; + + virtual void SAL_CALL release() throw () override; + ///===== XAccessibleComponent ============================================ + + virtual css::uno::Reference< css::accessibility::XAccessible > + SAL_CALL getAccessibleAtPoint( + const css::awt::Point& rPoint ) override; + + virtual OutputDevice* GetOutputDeviceForView(); + +protected: + /// Return the object's current bounding box relative to the desktop. + virtual tools::Rectangle GetBoundingBoxOnScreen() const override; + + /// Return the object's current bounding box relative to the parent object. + virtual tools::Rectangle GetBoundingBox() const override; + +public: + ///===== XAccessibleContext ============================================== + + /// Return the number of currently visible children. + /// override to calculate this on demand + virtual sal_Int32 SAL_CALL + getAccessibleChildCount() override; + + /// Return the specified child or NULL if index is invalid. + /// override to calculate this on demand + virtual css::uno::Reference< css::accessibility::XAccessible> SAL_CALL + getAccessibleChild(sal_Int32 nIndex) override; + + /// Return the set of current states. + virtual css::uno::Reference< + css::accessibility::XAccessibleStateSet> SAL_CALL + getAccessibleStateSet() 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; + virtual css::uno::Reference< css::accessibility::XAccessibleRelationSet > SAL_CALL getAccessibleRelationSet( ) override; +protected: + /// Return this object's description. + virtual OUString + createAccessibleDescription() override; + + /// Return the object's current name. + virtual OUString + createAccessibleName() override; + +public: + ///===== XAccessibleEventBroadcaster ===================================== + + /** Add listener that is informed of future changes of name, + description and so on events. + */ + virtual void SAL_CALL + addAccessibleEventListener( + const css::uno::Reference<css::accessibility::XAccessibleEventListener>& xListener) override; + + // Remove an existing event listener. + virtual void SAL_CALL + removeAccessibleEventListener( + const css::uno::Reference<css::accessibility::XAccessibleEventListener>& xListener) override; + + ///===== XServiceInfo ==================================================== + + /** Returns an identifier for the implementation of this object. + */ + virtual OUString SAL_CALL + getImplementationName() override; + + ///===== XTypeProvider =================================================== + + /** Returns an implementation id. + */ + virtual css::uno::Sequence<sal_Int8> SAL_CALL + getImplementationId() override; + +private: + std::unique_ptr<accessibility::AccessibleTextHelper> mpTextHelper; + EditView* mpEditView; + VclPtr<vcl::Window> mpWindow; + EditObjectType meObjectType; + bool mbHasFocus; + + bool IsDefunc( + const css::uno::Reference<css::accessibility::XAccessibleStateSet>& rxParentStates); + + void CreateTextHelper(); + ScDocument *m_pScDoc; + ScAddress m_curCellAddress; + + ///===== XAccessibleComponent ============================================ + virtual sal_Int32 SAL_CALL getForeground( ) override; + + virtual sal_Int32 SAL_CALL getBackground( ) override; + + sal_Int32 GetFgBgColor( const OUString &strPropColor) ; +}; + +class ScAccessibleEditControlObject : public ScAccessibleEditObject +{ +private: + weld::CustomWidgetController* m_pController; + +protected: + /// Return the object's current bounding box relative to the desktop. + virtual tools::Rectangle GetBoundingBoxOnScreen() const override; + + /// Return the object's current bounding box relative to the parent object. + virtual tools::Rectangle GetBoundingBox() const override; + +public: + ScAccessibleEditControlObject(weld::CustomWidgetController* pController) + : ScAccessibleEditObject(ScAccessibleEditObject::EditControl) + , m_pController(pController) + { + } + + virtual css::uno::Reference< css::accessibility::XAccessibleRelationSet > SAL_CALL getAccessibleRelationSet( ) override; + + // for mapping positions/sizes within the TextView to a11y + virtual OutputDevice* GetOutputDeviceForView() override; + + using ScAccessibleContextBase::disposing; + virtual void SAL_CALL disposing() override; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/AccessiblePageHeader.hxx b/sc/source/ui/inc/AccessiblePageHeader.hxx new file mode 100644 index 000000000..82262186e --- /dev/null +++ b/sc/source/ui/inc/AccessiblePageHeader.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_SC_SOURCE_UI_INC_ACCESSIBLEPAGEHEADER_HXX +#define INCLUDED_SC_SOURCE_UI_INC_ACCESSIBLEPAGEHEADER_HXX + +#include "AccessibleContextBase.hxx" +#include <editeng/svxenum.hxx> +#include <rtl/ref.hxx> + +class ScPreviewShell; +class EditTextObject; +class ScAccessiblePageHeaderArea; + +class ScAccessiblePageHeader : public ScAccessibleContextBase +{ +public: + ScAccessiblePageHeader( const css::uno::Reference<css::accessibility::XAccessible>& rxParent, + ScPreviewShell* pViewShell, bool bHeader, sal_Int32 nIndex ); + +protected: + virtual ~ScAccessiblePageHeader() override; + + using ScAccessibleContextBase::IsDefunc; + +public: + using ScAccessibleContextBase::disposing; + virtual void SAL_CALL disposing() override; + + //===== SfxListener ===================================================== + + virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override; + + //===== XAccessibleComponent ============================================ + + virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL + getAccessibleAtPoint( const css::awt::Point& aPoint ) override; + virtual void SAL_CALL grabFocus() override; + + //===== XAccessibleContext ============================================== + + virtual sal_Int32 SAL_CALL getAccessibleChildCount() override; + virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL + getAccessibleChild( sal_Int32 i ) override; + virtual sal_Int32 SAL_CALL getAccessibleIndexInParent() override; + virtual css::uno::Reference< css::accessibility::XAccessibleStateSet > SAL_CALL + getAccessibleStateSet() override; + + //===== XServiceInfo ==================================================== + + virtual OUString SAL_CALL getImplementationName() override; + virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override; + +protected: + virtual OUString createAccessibleDescription() override; + virtual OUString createAccessibleName() override; + + virtual tools::Rectangle GetBoundingBoxOnScreen() const override; + virtual tools::Rectangle GetBoundingBox() const override; + +private: + ScPreviewShell* mpViewShell; + sal_Int32 mnIndex; + bool mbHeader; + std::vector< rtl::Reference<ScAccessiblePageHeaderArea> > + maAreas; + sal_Int32 mnChildCount; + + bool IsDefunc( + const css::uno::Reference<css::accessibility::XAccessibleStateSet>& rxParentStates); + + void AddChild(const EditTextObject* pArea, sal_uInt32 nIndex, SvxAdjust eAdjust); +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/AccessiblePageHeaderArea.hxx b/sc/source/ui/inc/AccessiblePageHeaderArea.hxx new file mode 100644 index 000000000..572100c5a --- /dev/null +++ b/sc/source/ui/inc/AccessiblePageHeaderArea.hxx @@ -0,0 +1,116 @@ +/* -*- 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_SC_SOURCE_UI_INC_ACCESSIBLEPAGEHEADERAREA_HXX +#define INCLUDED_SC_SOURCE_UI_INC_ACCESSIBLEPAGEHEADERAREA_HXX + +#include "AccessibleContextBase.hxx" +#include <editeng/svxenum.hxx> + +class EditTextObject; +namespace accessibility +{ + class AccessibleTextHelper; +} +class ScPreviewShell; + +class ScAccessiblePageHeaderArea + : public ScAccessibleContextBase +{ +public: + //===== internal ======================================================== + ScAccessiblePageHeaderArea( + const css::uno::Reference<css::accessibility::XAccessible>& rxParent, + ScPreviewShell* pViewShell, + const EditTextObject* pEditObj, + SvxAdjust eAdjust); +protected: + virtual ~ScAccessiblePageHeaderArea() override; +public: + const EditTextObject* GetEditTextObject() const { return mpEditObj.get(); } + + using ScAccessibleContextBase::disposing; + virtual void SAL_CALL disposing() override; + + ///===== SfxListener ===================================================== + + virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override; + + ///===== XAccessibleComponent ============================================ + + virtual css::uno::Reference< css::accessibility::XAccessible > + SAL_CALL getAccessibleAtPoint( + const css::awt::Point& rPoint ) override; + + ///===== XAccessibleContext ============================================== + + /// Return the number of currently visible children. + /// override to calculate this on demand + virtual sal_Int32 SAL_CALL + getAccessibleChildCount() override; + + /// Return the specified child or NULL if index is invalid. + /// override to calculate this on demand + virtual css::uno::Reference< css::accessibility::XAccessible> SAL_CALL + getAccessibleChild(sal_Int32 nIndex) override; + + /// Return the set of current states. + virtual css::uno::Reference< + css::accessibility::XAccessibleStateSet> SAL_CALL + getAccessibleStateSet() override; + + ///===== XServiceInfo ==================================================== + + /** Returns an identifier for the implementation of this object. + */ + virtual OUString SAL_CALL + getImplementationName() override; + + /** Returns a list of all supported services. In this case that is just + the AccessibleContext and Accessible service. + */ + virtual css::uno::Sequence< OUString> SAL_CALL + getSupportedServiceNames() override; + + ///===== XTypeProvider =================================================== + + /** Returns an implementation id. + */ + virtual css::uno::Sequence<sal_Int8> SAL_CALL + getImplementationId() override; + +protected: + virtual OUString createAccessibleDescription() override; + virtual OUString createAccessibleName() override; + + virtual tools::Rectangle GetBoundingBoxOnScreen() const override; + virtual tools::Rectangle GetBoundingBox() const override; + +private: + std::unique_ptr<EditTextObject> mpEditObj; + std::unique_ptr<accessibility::AccessibleTextHelper> mpTextHelper; + ScPreviewShell* mpViewShell; + SvxAdjust meAdjust; + + void CreateTextHelper(); +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/AccessiblePreviewCell.hxx b/sc/source/ui/inc/AccessiblePreviewCell.hxx new file mode 100644 index 000000000..08b72ba04 --- /dev/null +++ b/sc/source/ui/inc/AccessiblePreviewCell.hxx @@ -0,0 +1,102 @@ +/* -*- 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_SC_SOURCE_UI_INC_ACCESSIBLEPREVIEWCELL_HXX +#define INCLUDED_SC_SOURCE_UI_INC_ACCESSIBLEPREVIEWCELL_HXX + +#include "AccessibleCellBase.hxx" + +class ScPreviewShell; + +namespace accessibility +{ + class AccessibleTextHelper; +} + +class ScAccessiblePreviewCell : public ScAccessibleCellBase +{ +public: + //===== internal ======================================================== + ScAccessiblePreviewCell( + const css::uno::Reference<css::accessibility::XAccessible>& rxParent, + ScPreviewShell* pViewShell, const ScAddress& rCellAddress, sal_Int32 nIndex ); + +protected: + virtual ~ScAccessiblePreviewCell() override; + + using ScAccessibleCellBase::IsDefunc; + +public: + using ScAccessibleCellBase::disposing; + virtual void SAL_CALL disposing() override; + + ///===== SfxListener ===================================================== + + virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override; + + //===== XAccessibleComponent ============================================ + + virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL + getAccessibleAtPoint( const css::awt::Point& aPoint ) override; + virtual void SAL_CALL grabFocus() override; + + //===== XAccessibleContext ============================================== + + // override to calculate this on demand + 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::XAccessibleStateSet > SAL_CALL + getAccessibleStateSet() override; + + //===== XServiceInfo ==================================================== + + virtual OUString SAL_CALL getImplementationName() override; + virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override; + + ///===== XTypeProvider =================================================== + + /** Returns an implementation id. + */ + virtual css::uno::Sequence<sal_Int8> SAL_CALL + getImplementationId() override; + +protected: + virtual tools::Rectangle GetBoundingBoxOnScreen() const override; + virtual tools::Rectangle GetBoundingBox() const override; + +private: + ScPreviewShell* mpViewShell; + + std::unique_ptr<accessibility::AccessibleTextHelper> mpTextHelper; + + bool IsDefunc( + const css::uno::Reference<css::accessibility::XAccessibleStateSet>& rxParentStates); + virtual bool IsEditable( + const css::uno::Reference<css::accessibility::XAccessibleStateSet>& rxParentStates) override; + bool IsOpaque() const; + + void CreateTextHelper(); + +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/AccessiblePreviewHeaderCell.hxx b/sc/source/ui/inc/AccessiblePreviewHeaderCell.hxx new file mode 100644 index 000000000..7af796fb6 --- /dev/null +++ b/sc/source/ui/inc/AccessiblePreviewHeaderCell.hxx @@ -0,0 +1,132 @@ +/* -*- 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_SC_SOURCE_UI_INC_ACCESSIBLEPREVIEWHEADERCELL_HXX +#define INCLUDED_SC_SOURCE_UI_INC_ACCESSIBLEPREVIEWHEADERCELL_HXX + +#include "AccessibleContextBase.hxx" +#include <com/sun/star/accessibility/XAccessibleValue.hpp> +#include <tools/gen.hxx> +#include <address.hxx> +#include <cppuhelper/implbase1.hxx> + +class ScPreviewShell; +class ScPreviewTableInfo; +namespace accessibility { + class AccessibleTextHelper; +} + +typedef cppu::ImplHelper1< css::accessibility::XAccessibleValue> + ScAccessiblePreviewHeaderCellImpl; + +class ScAccessiblePreviewHeaderCell : + public ScAccessibleContextBase, + public ScAccessiblePreviewHeaderCellImpl +{ +public: + ScAccessiblePreviewHeaderCell( const css::uno::Reference<css::accessibility::XAccessible>& rxParent, + ScPreviewShell* pViewShell, + const ScAddress& rCellPos, bool bIsColHdr, bool bIsRowHdr, + sal_Int32 nIndex ); + +protected: + virtual ~ScAccessiblePreviewHeaderCell() override; + + using ScAccessibleContextBase::IsDefunc; + +public: + using ScAccessibleContextBase::disposing; + virtual void SAL_CALL disposing() override; + + //===== SfxListener ===================================================== + + virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override; + + ///===== XInterface ===================================================== + + virtual css::uno::Any SAL_CALL queryInterface( + css::uno::Type const & rType ) override; + + virtual void SAL_CALL acquire() throw () override; + + virtual void SAL_CALL release() throw () 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; + + //===== XAccessibleComponent ============================================ + + virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL + getAccessibleAtPoint( const css::awt::Point& aPoint ) override; + virtual void SAL_CALL grabFocus() override; + + //===== XAccessibleContext ============================================== + + virtual sal_Int32 SAL_CALL getAccessibleChildCount() override; + virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL + getAccessibleChild( sal_Int32 i ) override; + virtual sal_Int32 SAL_CALL getAccessibleIndexInParent() override; + virtual css::uno::Reference< css::accessibility::XAccessibleStateSet > SAL_CALL + getAccessibleStateSet() override; + + //===== XServiceInfo ==================================================== + + virtual OUString SAL_CALL getImplementationName() override; + virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override; + + ///===== XTypeProvider =================================================== + + virtual css::uno::Sequence< css::uno::Type > SAL_CALL + getTypes() override; + + /** Returns an implementation id. + */ + virtual css::uno::Sequence<sal_Int8> SAL_CALL + getImplementationId() override; + +protected: + virtual OUString createAccessibleDescription() override; + virtual OUString createAccessibleName() override; + + virtual tools::Rectangle GetBoundingBoxOnScreen() const override; + virtual tools::Rectangle GetBoundingBox() const override; + +private: + ScPreviewShell* mpViewShell; + accessibility::AccessibleTextHelper* mpTextHelper; + sal_Int32 mnIndex; + ScAddress maCellPos; + bool mbColumnHeader; + bool mbRowHeader; + mutable std::unique_ptr<ScPreviewTableInfo> mpTableInfo; + + bool IsDefunc( + const css::uno::Reference<css::accessibility::XAccessibleStateSet>& rxParentStates); + + void CreateTextHelper(); + void FillTableInfo() const; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/AccessiblePreviewTable.hxx b/sc/source/ui/inc/AccessiblePreviewTable.hxx new file mode 100644 index 000000000..54d7b92f8 --- /dev/null +++ b/sc/source/ui/inc/AccessiblePreviewTable.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_SC_SOURCE_UI_INC_ACCESSIBLEPREVIEWTABLE_HXX +#define INCLUDED_SC_SOURCE_UI_INC_ACCESSIBLEPREVIEWTABLE_HXX + +#include "AccessibleContextBase.hxx" +#include <com/sun/star/accessibility/XAccessibleTable.hpp> +#include <cppuhelper/implbase1.hxx> + +class ScPreviewShell; +class ScPreviewTableInfo; + +typedef cppu::ImplHelper1< css::accessibility::XAccessibleTable> + ScAccessiblePreviewTableImpl; + +class ScAccessiblePreviewTable : + public ScAccessibleContextBase, + public ScAccessiblePreviewTableImpl +{ +public: + ScAccessiblePreviewTable( const css::uno::Reference<css::accessibility::XAccessible>& rxParent, + ScPreviewShell* pViewShell, sal_Int32 nIndex ); + +protected: + virtual ~ScAccessiblePreviewTable() override; + + using ScAccessibleContextBase::IsDefunc; + +public: + using ScAccessibleContextBase::disposing; + virtual void SAL_CALL disposing() override; + + //===== SfxListener ===================================================== + + virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override; + + ///===== XInterface ===================================================== + + virtual css::uno::Any SAL_CALL queryInterface( + css::uno::Type const & rType ) override; + + virtual void SAL_CALL acquire() throw () override; + + virtual void SAL_CALL release() throw () 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; + + //===== XAccessibleComponent ============================================ + + virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL + getAccessibleAtPoint( const css::awt::Point& aPoint ) override; + virtual void SAL_CALL grabFocus() override; + + //===== XAccessibleContext ============================================== + + virtual sal_Int32 SAL_CALL getAccessibleChildCount() override; + virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL + getAccessibleChild( sal_Int32 i ) override; + virtual sal_Int32 SAL_CALL getAccessibleIndexInParent() override; + virtual css::uno::Reference< css::accessibility::XAccessibleStateSet > SAL_CALL + getAccessibleStateSet() override; + + //===== XServiceInfo ==================================================== + + virtual OUString SAL_CALL getImplementationName() override; + virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override; + + //===== XTypeProvider =================================================== + + virtual css::uno::Sequence< css::uno::Type > SAL_CALL + getTypes() override; + + virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override; + +protected: + virtual OUString createAccessibleDescription() override; + virtual OUString createAccessibleName() override; + + virtual tools::Rectangle GetBoundingBoxOnScreen() const override; + virtual tools::Rectangle GetBoundingBox() const override; + +private: + ScPreviewShell* mpViewShell; + sal_Int32 mnIndex; + mutable std::unique_ptr<ScPreviewTableInfo> mpTableInfo; + + bool IsDefunc( + const css::uno::Reference<css::accessibility::XAccessibleStateSet>& rxParentStates); + + void FillTableInfo() const; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/AccessibleSpreadsheet.hxx b/sc/source/ui/inc/AccessibleSpreadsheet.hxx new file mode 100644 index 000000000..f2ecf9842 --- /dev/null +++ b/sc/source/ui/inc/AccessibleSpreadsheet.hxx @@ -0,0 +1,280 @@ +/* -*- 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_SC_SOURCE_UI_INC_ACCESSIBLESPREADSHEET_HXX +#define INCLUDED_SC_SOURCE_UI_INC_ACCESSIBLESPREADSHEET_HXX + +#include <sal/config.h> + +#include <rtl/ref.hxx> + +#include "AccessibleTableBase.hxx" +#include "viewdata.hxx" + +#include <vector> + +#include <rangelst.hxx> +#include <map> + +class ScMyAddress : public ScAddress +{ +public: + ScMyAddress(SCCOL nColP, SCROW nRowP, SCTAB nTabP) : ScAddress(nColP, nRowP, nTabP) {} + ScMyAddress(const ScAddress& rAddress) : ScAddress(rAddress) {} + + bool operator< ( const ScMyAddress& rAddress ) const + { + if( Row() != rAddress.Row() ) + return (Row() < rAddress.Row()); + else + return (Col() < rAddress.Col()); + } +}; + +class ScTabViewShell; +class ScAccessibleDocument; +class ScAccessibleCell; + +/** @descr + This base class provides an implementation of the + <code>AccessibleTable</code> service. +*/ +class ScAccessibleSpreadsheet final : public ScAccessibleTableBase +{ +public: + ScAccessibleSpreadsheet( + ScAccessibleDocument* pAccDoc, + ScTabViewShell* pViewShell, + SCTAB nTab, + ScSplitPos eSplitPos); + + using ScAccessibleTableBase::disposing; + + virtual void SAL_CALL disposing() override; + + void CompleteSelectionChanged(bool bNewState); + + void LostFocus(); + void GotFocus(); + + void BoundingBoxChanged(); + void VisAreaChanged(); + void FireFirstCellFocus(); + + css::uno::Reference < css::accessibility::XAccessible > GetActiveCell(); + bool IsScAddrFormulaSel (const ScAddress &addr) const; + bool IsFormulaMode(); + ScMyAddress CalcScAddressFromRangeList(ScRangeList *pMarkedRanges,sal_Int32 nSelectedChildIndex); + static bool CalcScRangeDifferenceMax(const ScRange & rSrc, const ScRange & rDest,int nMax,std::vector<ScMyAddress> &vecRet,int &nSize); + static bool CalcScRangeListDifferenceMax(ScRangeList *pSrc,ScRangeList *pDest,int nMax,std::vector<ScMyAddress> &vecRet); + +private: + ScAccessibleSpreadsheet( + ScAccessibleSpreadsheet& rParent, + const ScRange& rRange ); + + virtual ~ScAccessibleSpreadsheet() override; + + void ConstructScAccessibleSpreadsheet( + ScAccessibleDocument* pAccDoc, + ScTabViewShell* pViewShell, + SCTAB nTab, + ScSplitPos eSplitPos); + + using ScAccessibleTableBase::IsDefunc; + + ///===== SfxListener ===================================================== + virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override; + + ///===== XAccessibleTable ================================================ + + /// Returns the row headers as an AccessibleTable. + virtual css::uno::Reference< css::accessibility::XAccessibleTable > SAL_CALL + getAccessibleRowHeaders( ) override; + + /// Returns the column headers as an AccessibleTable. + virtual css::uno::Reference< css::accessibility::XAccessibleTable > SAL_CALL + getAccessibleColumnHeaders( ) override; + + /// Returns the selected rows in a table. + virtual css::uno::Sequence< sal_Int32 > SAL_CALL + getSelectedAccessibleRows( ) override; + + /// Returns the selected columns in a table. + virtual css::uno::Sequence< sal_Int32 > SAL_CALL + getSelectedAccessibleColumns( ) override; + + /// Returns a boolean value indicating whether the specified row is selected. + virtual sal_Bool SAL_CALL + isAccessibleRowSelected( sal_Int32 nRow ) override; + + /// Returns a boolean value indicating whether the specified column is selected. + virtual sal_Bool SAL_CALL + isAccessibleColumnSelected( sal_Int32 nColumn ) override; + + /// Returns the Accessible at a specified row and column in the table. + virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL + getAccessibleCellAt( sal_Int32 nRow, sal_Int32 nColumn ) override; + + rtl::Reference<ScAccessibleCell> GetAccessibleCellAt(sal_Int32 nRow, sal_Int32 nColumn); + + /// Returns a boolean value indicating whether the accessible at a specified row and column is selected. + virtual sal_Bool SAL_CALL + isAccessibleSelected( sal_Int32 nRow, sal_Int32 nColumn ) override; + + ///===== XAccessibleComponent ============================================ + + virtual css::uno::Reference< css::accessibility::XAccessible > + SAL_CALL getAccessibleAtPoint( + const css::awt::Point& rPoint ) override; + + virtual void SAL_CALL grabFocus( ) override; + + virtual sal_Int32 SAL_CALL getForeground( ) override; + + virtual sal_Int32 SAL_CALL getBackground( ) override; + + ///===== XAccessibleContext ============================================== + + /// Return NULL to indicate that an empty relation set. + virtual css::uno::Reference<css::accessibility::XAccessibleRelationSet> SAL_CALL + getAccessibleRelationSet() override; + + /// Return the set of current states. + virtual css::uno::Reference<css::accessibility::XAccessibleStateSet> SAL_CALL + getAccessibleStateSet() override; + + ///===== XAccessibleSelection =========================================== + + virtual void SAL_CALL + selectAccessibleChild( 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 nChildIndex ) override; + + ///===== XServiceInfo ==================================================== + + /** Returns an identifier for the implementation of this object. + */ + virtual OUString SAL_CALL + getImplementationName() override; + + /** Returns a list of all supported services. + */ + virtual css::uno::Sequence< OUString> SAL_CALL + getSupportedServiceNames() override; + + ///===== XTypeProvider =================================================== + + /** Returns an implementation id. + */ + virtual css::uno::Sequence<sal_Int8> SAL_CALL + getImplementationId() override; + + ///===== XAccessibleEventBroadcaster ===================================== + + /** Add listener that is informed of future changes of name, + description and so on events. + */ + virtual void SAL_CALL + addAccessibleEventListener( + const css::uno::Reference<css::accessibility::XAccessibleEventListener>& xListener) override; + + //===== XAccessibleTableSelection ============================================ + + virtual sal_Bool SAL_CALL selectRow( sal_Int32 row ) override; + virtual sal_Bool SAL_CALL selectColumn( sal_Int32 column ) override; + virtual sal_Bool SAL_CALL unselectRow( sal_Int32 row ) override; + virtual sal_Bool SAL_CALL unselectColumn( sal_Int32 column ) override; + + /// Return the object's current bounding box relative to the desktop. + virtual tools::Rectangle GetBoundingBoxOnScreen() const override; + + /// Return the object's current bounding box relative to the parent object. + virtual tools::Rectangle GetBoundingBox() const override; + + bool IsDefunc( + const css::uno::Reference<css::accessibility::XAccessibleStateSet>& rxParentStates); + bool IsEditable(); + bool IsFocused(); + bool IsCompleteSheetSelected(); + + void SelectCell(sal_Int32 nRow, sal_Int32 nCol, bool bDeselect); + + static ScDocument* GetDocument(ScTabViewShell* pViewShell); + + void RemoveSelection(const ScMarkData &refScMarkData); + void CommitFocusCell(const ScAddress &aNewCell); + + sal_Int32 GetRowAll() const { return m_nMaxY - m_nMinY + 1 ; } + sal_uInt16 GetColAll() const { return m_nMaxX - m_nMinX + 1; } + void NotifyRefMode(); + void RemoveFormulaSelection(bool bRemoveAll = false); + bool CheckChildIndex(sal_Int32) const; + ScAddress GetChildIndexAddress(sal_Int32) const; + sal_Int32 GetAccessibleIndexFormula( sal_Int32 nRow, sal_Int32 nColumn ); + bool GetFormulaCurrentFocusCell(ScAddress &addr); + + ScTabViewShell* mpViewShell; + std::unique_ptr<ScRangeList> mpMarkedRanges; + ScAccessibleDocument* mpAccDoc; + rtl::Reference<ScAccessibleCell> mpAccCell; + ScSplitPos meSplitPos; + ScAddress maActiveCell; + SCTAB mnTab; + bool mbIsSpreadsheet; + bool mbDelIns; + bool mbIsFocusSend; + typedef std::map<ScMyAddress,css::uno::Reference< css::accessibility::XAccessible > > + MAP_ADDR_XACC; + MAP_ADDR_XACC m_mapSelectionSend; + bool m_bFormulaMode; + bool m_bFormulaLastMode; + ScAddress m_aFormulaActiveCell; + MAP_ADDR_XACC m_mapFormulaSelectionSend; + std::vector<ScMyAddress> m_vecFormulaLastMyAddr; + rtl::Reference<ScAccessibleCell> m_pAccFormulaCell; + sal_uInt16 m_nMinX; + sal_uInt16 m_nMaxX; + sal_Int32 m_nMinY; + sal_Int32 m_nMaxY; + ScRange m_aLastWithInMarkRange; + OUString m_strCurCellValue; + ScRangeList m_LastMarkedRanges; + std::vector<ScRange> m_vecTempRange; + typedef std::pair<sal_uInt16,sal_uInt16> PAIR_COL; + std::vector<PAIR_COL> m_vecTempCol; + OUString m_strOldTabName; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/AccessibleTableBase.hxx b/sc/source/ui/inc/AccessibleTableBase.hxx new file mode 100644 index 000000000..067057f10 --- /dev/null +++ b/sc/source/ui/inc/AccessibleTableBase.hxx @@ -0,0 +1,237 @@ +/* -*- 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_SC_SOURCE_UI_INC_ACCESSIBLETABLEBASE_HXX +#define INCLUDED_SC_SOURCE_UI_INC_ACCESSIBLETABLEBASE_HXX + +#include "AccessibleContextBase.hxx" +#include <address.hxx> +#include <com/sun/star/accessibility/XAccessibleTable.hpp> +#include <com/sun/star/accessibility/XAccessibleSelection.hpp> +#include <com/sun/star/accessibility/XAccessibleTableSelection.hpp> +#include <cppuhelper/implbase2.hxx> + +/** @descr + This base class provides an implementation of the + <code>AccessibleTable</code> service. +*/ + +typedef cppu::ImplHelper2< css::accessibility::XAccessibleTable, + css::accessibility::XAccessibleSelection> + ScAccessibleTableBaseImpl; + +class ScAccessibleTableBase : + public ScAccessibleContextBase, + public css::accessibility::XAccessibleTableSelection, + public ScAccessibleTableBaseImpl +{ +public: + //===== internal ======================================================== + ScAccessibleTableBase( + const css::uno::Reference<css::accessibility::XAccessible>& rxParent, + ScDocument* pDoc, + const ScRange& rRange); +protected: + virtual ~ScAccessibleTableBase() override; +public: + + using ScAccessibleContextBase::disposing; + virtual void SAL_CALL disposing() override; + + ///===== XInterface ===================================================== + + virtual css::uno::Any SAL_CALL queryInterface( + css::uno::Type const & rType ) override; + + virtual void SAL_CALL acquire() throw () override; + + virtual void SAL_CALL release() throw () override; + + ///===== XAccessibleTable ================================================ + + /// Returns the number of rows in the table. + virtual sal_Int32 SAL_CALL + getAccessibleRowCount( ) override; + + /// Returns the number of columns in the table. + virtual sal_Int32 SAL_CALL + getAccessibleColumnCount( ) override; + + /// Returns the description of the specified row in the table. + virtual OUString SAL_CALL + getAccessibleRowDescription( sal_Int32 nRow ) override; + + /// Returns the description text of the specified column in the table. + virtual OUString SAL_CALL + getAccessibleColumnDescription( sal_Int32 nColumn ) override; + + /** Returns the number of rows occupied by the Accessible at a specified row and column in the table. + Returns 1 if it is only a cell and the number of rows the cell is merged if the cell is a merged cell. + */ + virtual sal_Int32 SAL_CALL + getAccessibleRowExtentAt( sal_Int32 nRow, sal_Int32 nColumn ) override; + + /** Returns the number of columns occupied by the Accessible at a specified row and column in the table. + Returns 1 if it is only a cell and the number of columns the cell is merged if the cell is a merged cell. + */ + virtual sal_Int32 SAL_CALL + getAccessibleColumnExtentAt( sal_Int32 nRow, sal_Int32 nColumn ) override; + + /// Returns the row headers as an AccessibleTable. + virtual css::uno::Reference< css::accessibility::XAccessibleTable > SAL_CALL + getAccessibleRowHeaders( ) override; + + /// Returns the column headers as an AccessibleTable. + virtual css::uno::Reference< css::accessibility::XAccessibleTable > SAL_CALL + getAccessibleColumnHeaders( ) override; + + /// Returns the selected rows in a table. + virtual css::uno::Sequence< sal_Int32 > SAL_CALL + getSelectedAccessibleRows( ) override; + + /// Returns the selected columns in a table. + virtual css::uno::Sequence< sal_Int32 > SAL_CALL + getSelectedAccessibleColumns( ) override; + + /// Returns a boolean value indicating whether the specified row is selected. + virtual sal_Bool SAL_CALL + isAccessibleRowSelected( sal_Int32 nRow ) override; + + /// Returns a boolean value indicating whether the specified column is selected. + virtual sal_Bool SAL_CALL + isAccessibleColumnSelected( sal_Int32 nColumn ) override; + + /// Returns the Accessible at a specified row and column in the table. + virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL + getAccessibleCellAt( sal_Int32 nRow, sal_Int32 nColumn ) override; + + /// Returns the caption for the table. + virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL + getAccessibleCaption( ) override; + + /// Returns the summary description of the table. + virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL + getAccessibleSummary( ) override; + + /// Returns a boolean value indicating whether the accessible at a specified row and column is selected. + virtual sal_Bool SAL_CALL + isAccessibleSelected( sal_Int32 nRow, sal_Int32 nColumn ) override; + + ///===== XAccessibleExtendedTable ======================================== + + /// Returns the index of the cell on the given position. + virtual sal_Int32 SAL_CALL + getAccessibleIndex( sal_Int32 nRow, sal_Int32 nColumn ) override; + + /// Returns the row number of an index in the table. + virtual sal_Int32 SAL_CALL + getAccessibleRow( sal_Int32 nChildIndex ) override; + + /// Returns the column number of an index in the table. + virtual sal_Int32 SAL_CALL + getAccessibleColumn( sal_Int32 nChildIndex ) override; + + //===== XAccessibleContext ============================================== + + /// Return the number of currently visible children. + /// override to calculate this on demand + virtual sal_Int32 SAL_CALL + getAccessibleChildCount() override; + + /// Return the specified child or NULL if index is invalid. + /// override to calculate this on demand + virtual css::uno::Reference< css::accessibility::XAccessible> SAL_CALL + getAccessibleChild(sal_Int32 nIndex) override; + virtual sal_Bool SAL_CALL selectRow( sal_Int32 row ) override; + virtual sal_Bool SAL_CALL selectColumn( sal_Int32 column ) override; + virtual sal_Bool SAL_CALL unselectRow( sal_Int32 row ) override; + virtual sal_Bool SAL_CALL unselectColumn( sal_Int32 column ) override; + +protected: + /// Return this object's description. + virtual OUString + createAccessibleDescription() override; + + /// Return the object's current name. + virtual OUString + createAccessibleName() override; + +public: + /// Return NULL to indicate that an empty relation set. + virtual css::uno::Reference<css::accessibility::XAccessibleRelationSet> SAL_CALL + getAccessibleRelationSet() override; + + /// Return the set of current states. + // perhaps sometimes to be implemented + virtual css::uno::Reference<css::accessibility::XAccessibleStateSet> SAL_CALL + getAccessibleStateSet() 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; + + ///===== XServiceInfo =================================================== + + /** Returns an identifier for the implementation of this object. + */ + virtual OUString SAL_CALL + getImplementationName() override; + + ///===== XTypeProvider =================================================== + + /// returns the possible types + virtual css::uno::Sequence< css::uno::Type > SAL_CALL + getTypes() override; + + /** Returns an implementation id. + */ + virtual css::uno::Sequence<sal_Int8> SAL_CALL + getImplementationId() override; + +protected: + /// contains the range of the table, because it could be a subrange of the complete table + ScRange maRange; + + ScDocument* mpDoc; + + void CommitTableModelChange(sal_Int32 nStartRow, sal_Int32 nStartCol, sal_Int32 nEndRow, sal_Int32 nEndCol, sal_uInt16 nId); +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/AccessibleText.hxx b/sc/source/ui/inc/AccessibleText.hxx new file mode 100644 index 000000000..974d4c089 --- /dev/null +++ b/sc/source/ui/inc/AccessibleText.hxx @@ -0,0 +1,289 @@ +/* -*- 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_SC_SOURCE_UI_INC_ACCESSIBLETEXT_HXX +#define INCLUDED_SC_SOURCE_UI_INC_ACCESSIBLETEXT_HXX + +#include <textuno.hxx> +#include <address.hxx> +#include "viewdata.hxx" +#include <editeng/svxenum.hxx> +#include <svl/SfxBroadcaster.hxx> + +#include <memory> + +class ScDocShell; +class ScViewForwarder; +class ScEditObjectViewForwarder; +class ScPreviewViewForwarder; +class ScEditViewForwarder; +class ScPreviewShell; +class EditTextObject; +class ScCsvViewForwarder; +class ScAccessibleCell; + +class ScAccessibleTextData : public SfxListener +{ +public: + ScAccessibleTextData() {} + + virtual ScAccessibleTextData* Clone() const = 0; + + virtual void Notify( SfxBroadcaster& /* rBC */, const SfxHint& /* rHint */ ) override {} + + virtual SvxTextForwarder* GetTextForwarder() = 0; + virtual SvxViewForwarder* GetViewForwarder() = 0; + virtual SvxEditViewForwarder* GetEditViewForwarder( bool bCreate ) = 0; + SfxBroadcaster& GetBroadcaster() const { return maBroadcaster; } + + virtual void UpdateData() = 0; + DECL_LINK( NotifyHdl, EENotify&, void ); + +private: + mutable SfxBroadcaster maBroadcaster; + +}; + +class ScAccessibleCellBaseTextData : public ScAccessibleTextData, + public ScCellTextData +{ +public: + ScAccessibleCellBaseTextData(ScDocShell* pDocShellP, + const ScAddress& rP) + : ScCellTextData(pDocShellP, rP) {} + virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override { ScCellTextData::Notify(rBC, rHint); } + + virtual void UpdateData() override { ScCellTextData::UpdateData(); } +}; + +// ScAccessibleCellTextData: shared data between sub objects of an accessible cell text object + +class ScAccessibleCellTextData : public ScAccessibleCellBaseTextData +{ +public: + ScAccessibleCellTextData(ScTabViewShell* pViewShell, + const ScAddress& rP, ScSplitPos eSplitPos, ScAccessibleCell* pAccCell); + virtual ~ScAccessibleCellTextData() override; + + virtual ScAccessibleTextData* Clone() const override; + + virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override; + + virtual SvxTextForwarder* GetTextForwarder() override; + virtual SvxViewForwarder* GetViewForwarder() override; + virtual SvxEditViewForwarder* GetEditViewForwarder( bool bCreate ) override; + +private: + std::unique_ptr<ScViewForwarder> mpViewForwarder; + ScTabViewShell* mpViewShell; + ScSplitPos meSplitPos; + ScAccessibleCell* mpAccessibleCell; + + using ScAccessibleCellBaseTextData::GetDocShell; + static ScDocShell* GetDocShell(ScTabViewShell* pViewShell); +}; + +class ScAccessibleEditObjectTextData : public ScAccessibleTextData +{ +public: + // Add a para to indicate whether the object is cloned + ScAccessibleEditObjectTextData(EditView* pEditView, OutputDevice* pWin, bool isClone = false); + virtual ~ScAccessibleEditObjectTextData() override; + + virtual ScAccessibleTextData* Clone() const override; + + virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override; + + virtual SvxTextForwarder* GetTextForwarder() override; + virtual SvxViewForwarder* GetViewForwarder() override; + virtual SvxEditViewForwarder* GetEditViewForwarder( bool bCreate ) override; + + virtual void UpdateData() override { } + + DECL_LINK( NotifyHdl, EENotify&, void ); +protected: + std::unique_ptr<ScEditObjectViewForwarder> mpViewForwarder; + std::unique_ptr<ScEditViewForwarder> mpEditViewForwarder; + EditView* mpEditView; + EditEngine* mpEditEngine; + std::unique_ptr<SvxEditEngineForwarder> mpForwarder; + VclPtr<OutputDevice> mpWindow; + bool mbIsCloned; +}; + +class ScAccessibleEditLineTextData : public ScAccessibleEditObjectTextData +{ +public: + ScAccessibleEditLineTextData(EditView* pEditView, OutputDevice* pWin); + virtual ~ScAccessibleEditLineTextData() override; + + virtual ScAccessibleTextData* Clone() const override; + + virtual SvxTextForwarder* GetTextForwarder() override; + virtual SvxEditViewForwarder* GetEditViewForwarder( bool bCreate ) override; + + void Dispose(); + void TextChanged(); + void StartEdit(); + void EndEdit(); +private: + void ResetEditMode(); + + bool mbEditEngineCreated; +}; + +class ScAccessiblePreviewCellTextData : public ScAccessibleCellBaseTextData +{ +public: + ScAccessiblePreviewCellTextData(ScPreviewShell* pViewShell, + const ScAddress& rP); + virtual ~ScAccessiblePreviewCellTextData() override; + + virtual ScAccessibleTextData* Clone() const override; + + virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override; + + virtual SvxTextForwarder* GetTextForwarder() override; + virtual SvxViewForwarder* GetViewForwarder() override; + virtual SvxEditViewForwarder* GetEditViewForwarder( bool /* bCreate */ ) override { return nullptr; } + +private: + std::unique_ptr<ScPreviewViewForwarder> mpViewForwarder; + ScPreviewShell* mpViewShell; + + using ScAccessibleCellBaseTextData::GetDocShell; + static ScDocShell* GetDocShell(ScPreviewShell* pViewShell); +}; + +class ScAccessiblePreviewHeaderCellTextData : public ScAccessibleCellBaseTextData +{ +public: + ScAccessiblePreviewHeaderCellTextData(ScPreviewShell* pViewShell, + const OUString& rText, const ScAddress& rP, bool bColHeader, bool bRowHeader); + virtual ~ScAccessiblePreviewHeaderCellTextData() override; + + virtual ScAccessibleTextData* Clone() const override; + + virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override; + + virtual SvxTextForwarder* GetTextForwarder() override; + virtual SvxViewForwarder* GetViewForwarder() override; + virtual SvxEditViewForwarder* GetEditViewForwarder( bool /* bCreate */ ) override { return nullptr; } + +private: + std::unique_ptr<ScPreviewViewForwarder> mpViewForwarder; + ScPreviewShell* mpViewShell; + OUString maText; + bool mbColHeader; + bool mbRowHeader; + + using ScAccessibleCellBaseTextData::GetDocShell; + static ScDocShell* GetDocShell(ScPreviewShell* pViewShell); +}; + +class ScAccessibleHeaderTextData : public ScAccessibleTextData +{ +public: + ScAccessibleHeaderTextData(ScPreviewShell* pViewShell, + const EditTextObject* pEditObj, SvxAdjust eAdjust); + virtual ~ScAccessibleHeaderTextData() override; + + virtual ScAccessibleTextData* Clone() const override; + + virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override; + + virtual SvxTextForwarder* GetTextForwarder() override; + virtual SvxViewForwarder* GetViewForwarder() override; + virtual SvxEditViewForwarder* GetEditViewForwarder( bool /* bCreate */ ) override { return nullptr; } + + virtual void UpdateData() override { } +private: + ScPreviewViewForwarder* mpViewForwarder; + ScPreviewShell* mpViewShell; + std::unique_ptr<ScEditEngineDefaulter> mpEditEngine; + std::unique_ptr<SvxEditEngineForwarder> mpForwarder; + ScDocShell* mpDocSh; + const EditTextObject* mpEditObj; + bool mbDataValid; + SvxAdjust meAdjust; +}; + +class ScAccessibleNoteTextData : public ScAccessibleTextData +{ +public: + ScAccessibleNoteTextData(ScPreviewShell* pViewShell, + const OUString& sText, const ScAddress& aCellPos, bool bMarkNote); + virtual ~ScAccessibleNoteTextData() override; + + virtual ScAccessibleTextData* Clone() const override; + + virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override; + + virtual SvxTextForwarder* GetTextForwarder() override; + virtual SvxViewForwarder* GetViewForwarder() override; + virtual SvxEditViewForwarder* GetEditViewForwarder( bool /* bCreate */ ) override { return nullptr; } + + virtual void UpdateData() override { } +private: + ScPreviewViewForwarder* mpViewForwarder; + ScPreviewShell* mpViewShell; + std::unique_ptr<ScEditEngineDefaulter> mpEditEngine; + std::unique_ptr<SvxEditEngineForwarder> mpForwarder; + ScDocShell* mpDocSh; + OUString msText; + ScAddress maCellPos; + bool mbMarkNote; + bool mbDataValid; +}; + +class ScAccessibleCsvTextData : public ScAccessibleTextData +{ +private: + typedef ::std::unique_ptr< SvxTextForwarder > TextForwarderPtr; + typedef ::std::unique_ptr< ScCsvViewForwarder > ViewForwarderPtr; + + VclPtr<OutputDevice> mpWindow; + EditEngine* mpEditEngine; + TextForwarderPtr mpTextForwarder; + ViewForwarderPtr mpViewForwarder; + OUString maCellText; + Size maCellSize; + +public: + explicit ScAccessibleCsvTextData( + OutputDevice* pWindow, + EditEngine* pEditEngine, + const OUString& rCellText, + const Size& rCellSize ); + virtual ~ScAccessibleCsvTextData() override; + + virtual ScAccessibleTextData* Clone() const override; + + virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override; + + virtual SvxTextForwarder* GetTextForwarder() override; + virtual SvxViewForwarder* GetViewForwarder() override; + virtual SvxEditViewForwarder* GetEditViewForwarder( bool bCreate ) override; + + virtual void UpdateData() override {} +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/AnalysisOfVarianceDialog.hxx b/sc/source/ui/inc/AnalysisOfVarianceDialog.hxx new file mode 100644 index 000000000..a4c0bad4d --- /dev/null +++ b/sc/source/ui/inc/AnalysisOfVarianceDialog.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/. + * + */ + +#ifndef INCLUDED_SC_SOURCE_UI_INC_ANALYSISOFVARIANCEDIALOG_HXX +#define INCLUDED_SC_SOURCE_UI_INC_ANALYSISOFVARIANCEDIALOG_HXX + +#include <address.hxx> +#include "viewdata.hxx" + +#include "StatisticsInputOutputDialog.hxx" + +class FormulaTemplate; +class AddressWalkerWriter; + +class ScAnalysisOfVarianceDialog : public ScStatisticsInputOutputDialog +{ +private: + enum AnovaFactor + { + SINGLE_FACTOR, + TWO_FACTOR + }; + + DECL_LINK(FactorChanged, weld::ToggleButton&, void); + void FactorChanged(); + + AnovaFactor meFactor; + + std::unique_ptr<weld::SpinButton> mxAlphaField; + std::unique_ptr<weld::RadioButton> mxSingleFactorRadio; + std::unique_ptr<weld::RadioButton> mxTwoFactorRadio; + std::unique_ptr<weld::SpinButton> mxRowsPerSampleField; + + static void RowColumn(ScRangeList& rRangeList, AddressWalkerWriter& aOutput, + FormulaTemplate& aTemplate, const OUString& sFormula, + GroupedBy aGroupedBy, ScRange* pResultRange); + + void AnovaSingleFactor(AddressWalkerWriter& output, FormulaTemplate& aTemplate); + void AnovaTwoFactor(AddressWalkerWriter& output, FormulaTemplate& aTemplate); + +public: + ScAnalysisOfVarianceDialog( + SfxBindings* pB, SfxChildWindow* pCW, + weld::Window* pParent, ScViewData* pViewData ); + + virtual ~ScAnalysisOfVarianceDialog() override; + + virtual void Close() override; + +protected: + virtual const char* GetUndoNameId() override; + virtual ScRange ApplyOutput(ScDocShell* pDocShell) override; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/ChartRangeSelectionListener.hxx b/sc/source/ui/inc/ChartRangeSelectionListener.hxx new file mode 100644 index 000000000..cdba0dbb0 --- /dev/null +++ b/sc/source/ui/inc/ChartRangeSelectionListener.hxx @@ -0,0 +1,68 @@ +/* -*- 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_SC_SOURCE_UI_INC_CHARTRANGESELECTIONLISTENER_HXX +#define INCLUDED_SC_SOURCE_UI_INC_CHARTRANGESELECTIONLISTENER_HXX + +#include <cppuhelper/compbase.hxx> +#include <cppuhelper/basemutex.hxx> +#include <com/sun/star/view/XSelectionChangeListener.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> + +class ScTabViewShell; + +typedef ::cppu::WeakComponentImplHelper< + css::view::XSelectionChangeListener, + css::lang::XServiceInfo > + ScChartRangeSelectionListener_Base; + +class ScChartRangeSelectionListener : + public cppu::BaseMutex, + public ScChartRangeSelectionListener_Base +{ +public: + explicit ScChartRangeSelectionListener( ScTabViewShell * pViewShell ); + virtual ~ScChartRangeSelectionListener() override; + +protected: + // ____ XSelectionChangeListener ____ + virtual void SAL_CALL selectionChanged( + const css::lang::EventObject& aEvent ) override; + + // ____ XEventListener (base of XSelectionChangeListener) ____ + virtual void SAL_CALL disposing( + const css::lang::EventObject& Source ) override; + + // ____ WeakComponentImplHelperBase ____ + // is called when dispose() is called at this component + virtual void SAL_CALL disposing() override; + + // ____ XServiceInfo ____ + virtual OUString SAL_CALL getImplementationName() override; + virtual sal_Bool SAL_CALL supportsService( + const OUString& ServiceName ) override; + virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override; + +private: + ScTabViewShell * m_pViewShell; +}; + +// INCLUDED_SC_SOURCE_UI_INC_CHARTRANGESELECTIONLISTENER_HXX +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/ChiSquareTestDialog.hxx b/sc/source/ui/inc/ChiSquareTestDialog.hxx new file mode 100644 index 000000000..28c642c15 --- /dev/null +++ b/sc/source/ui/inc/ChiSquareTestDialog.hxx @@ -0,0 +1,34 @@ +/* -*- 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_SC_SOURCE_UI_INC_CHISQUARETESTDIALOG_HXX +#define INCLUDED_SC_SOURCE_UI_INC_CHISQUARETESTDIALOG_HXX + +#include "StatisticsInputOutputDialog.hxx" + +class ScChiSquareTestDialog : public ScStatisticsInputOutputDialog +{ +public: + ScChiSquareTestDialog( + SfxBindings* pB, SfxChildWindow* pCW, + weld::Window* pParent, ScViewData* pViewData ); + + virtual ~ScChiSquareTestDialog() override; + + virtual void Close() override; + +protected: + virtual const char* GetUndoNameId() override; + virtual ScRange ApplyOutput(ScDocShell* pDocShell) override; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/ChildWindowWrapper.hxx b/sc/source/ui/inc/ChildWindowWrapper.hxx new file mode 100644 index 000000000..dad043e22 --- /dev/null +++ b/sc/source/ui/inc/ChildWindowWrapper.hxx @@ -0,0 +1,84 @@ +/* -*- 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_SC_SOURCE_UI_INC_CHILDWINDOWWRAPPER_HXX +#define INCLUDED_SC_SOURCE_UI_INC_CHILDWINDOWWRAPPER_HXX + +#include <sfx2/basedlgs.hxx> +#include <sfx2/dispatch.hxx> +#include <sfx2/viewfrm.hxx> +#include <sfx2/childwin.hxx> + +#include "tabvwsh.hxx" + +template <sal_Int16 WindowID> +class ChildControllerWrapper : public SfxChildWindow +{ +public: + ChildControllerWrapper(vcl::Window* pParentP, sal_uInt16 nId, + SfxBindings* pBindings, const SfxChildWinInfo* pInfo) + : SfxChildWindow(pParentP, nId) + { + ScTabViewShell* pViewShell = getTabViewShell( pBindings ); + if (!pViewShell) + pViewShell = dynamic_cast< ScTabViewShell *>( SfxViewShell::Current() ); + OSL_ENSURE(pViewShell, "Missing view shell!"); + + if (pViewShell) + SetController(pViewShell->CreateRefDialogController(pBindings, this, pInfo, pParentP->GetFrameWeld(), WindowID)); + + if (pViewShell && !GetController()) + pViewShell->GetViewFrame()->SetChildWindow( nId, false ); + } + + static std::unique_ptr<SfxChildWindow> CreateImpl( + vcl::Window *pParent, sal_uInt16 nId, + SfxBindings *pBindings, SfxChildWinInfo* pInfo ) + { + return std::make_unique<ChildControllerWrapper>(pParent, nId, pBindings, pInfo); + } + + static void RegisterChildWindow ( + bool bVisible = false, + SfxModule* pModule = nullptr, + SfxChildWindowFlags nFlags = SfxChildWindowFlags::NONE) + { + auto pFactory = std::make_unique<SfxChildWinFactory>(ChildControllerWrapper::CreateImpl, WindowID, CHILDWIN_NOPOS ); + pFactory->aInfo.nFlags |= nFlags; + pFactory->aInfo.bVisible = bVisible; + SfxChildWindow::RegisterChildWindow(pModule, std::move(pFactory)); + } + + static sal_uInt16 GetChildWindowId() + { + return WindowID; + } + +private: + static ScTabViewShell* getTabViewShell( const SfxBindings *pBindings ) + { + if( !pBindings ) + return nullptr; + SfxDispatcher* pDispacher = pBindings ->GetDispatcher(); + if( !pDispacher ) + return nullptr; + SfxViewFrame* pFrame = pDispacher->GetFrame(); + if( !pFrame ) + return nullptr; + SfxViewShell* pViewShell = pFrame->GetViewShell(); + if( !pViewShell ) + return nullptr; + return dynamic_cast<ScTabViewShell*>( pViewShell ); + } +}; + +#endif // INCLUDED_SC_SOURCE_UI_INC_CHILDWINDOWWRAPPER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/CorrelationDialog.hxx b/sc/source/ui/inc/CorrelationDialog.hxx new file mode 100644 index 000000000..a1444c67a --- /dev/null +++ b/sc/source/ui/inc/CorrelationDialog.hxx @@ -0,0 +1,32 @@ +/* -*- 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_SC_SOURCE_UI_INC_CORRELATIONDIALOG_HXX +#define INCLUDED_SC_SOURCE_UI_INC_CORRELATIONDIALOG_HXX + +#include "MatrixComparisonGenerator.hxx" + +class ScCorrelationDialog : public ScMatrixComparisonGenerator +{ +public: + ScCorrelationDialog( + SfxBindings* pSfxBindings, SfxChildWindow* pChildWindow, + weld::Window* pParent, ScViewData* pViewData); + + virtual void Close() override; + +protected: + virtual OUString getLabel() override; + virtual OUString getTemplate() override; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/CovarianceDialog.hxx b/sc/source/ui/inc/CovarianceDialog.hxx new file mode 100644 index 000000000..382dc7edf --- /dev/null +++ b/sc/source/ui/inc/CovarianceDialog.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/. + * + */ + +#ifndef INCLUDED_SC_SOURCE_UI_INC_COVARIANCEDIALOG_HXX +#define INCLUDED_SC_SOURCE_UI_INC_COVARIANCEDIALOG_HXX + +#include "MatrixComparisonGenerator.hxx" + +class ScCovarianceDialog : public ScMatrixComparisonGenerator +{ +public: + ScCovarianceDialog( + SfxBindings* pSfxBindings, SfxChildWindow* pChildWindow, + weld::Window* pParent, ScViewData* pViewData); + + virtual void Close() override; + +protected: + virtual OUString getLabel() override; + virtual OUString getTemplate() override; + virtual const char* GetUndoNameId() override; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/DescriptiveStatisticsDialog.hxx b/sc/source/ui/inc/DescriptiveStatisticsDialog.hxx new file mode 100644 index 000000000..afac816da --- /dev/null +++ b/sc/source/ui/inc/DescriptiveStatisticsDialog.hxx @@ -0,0 +1,34 @@ +/* -*- 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_SC_SOURCE_UI_INC_DESCRIPTIVESTATISTICSDIALOG_HXX +#define INCLUDED_SC_SOURCE_UI_INC_DESCRIPTIVESTATISTICSDIALOG_HXX + +#include "StatisticsInputOutputDialog.hxx" + +class ScDescriptiveStatisticsDialog : public ScStatisticsInputOutputDialog +{ +public: + ScDescriptiveStatisticsDialog( + SfxBindings* pB, SfxChildWindow* pCW, + weld::Window* pParent, ScViewData* pViewData ); + + virtual ~ScDescriptiveStatisticsDialog() override; + + virtual void Close() override; + +protected: + virtual const char* GetUndoNameId() override; + virtual ScRange ApplyOutput(ScDocShell* pDocShell) override; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/DrawModelBroadcaster.hxx b/sc/source/ui/inc/DrawModelBroadcaster.hxx new file mode 100644 index 000000000..0d5966b86 --- /dev/null +++ b/sc/source/ui/inc/DrawModelBroadcaster.hxx @@ -0,0 +1,57 @@ +/* -*- 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_SC_SOURCE_UI_INC_DRAWMODELBROADCASTER_HXX +#define INCLUDED_SC_SOURCE_UI_INC_DRAWMODELBROADCASTER_HXX + +#include <svl/lstner.hxx> +#include <comphelper/interfacecontainer3.hxx> +#include <cppuhelper/implbase.hxx> +#include <com/sun/star/document/XEventBroadcaster.hpp> +#include <com/sun/star/document/XShapeEventBroadcaster.hpp> +#include <unordered_map> + +class SdrModel; + +class ScDrawModelBroadcaster : public SfxListener, + public ::cppu::WeakImplHelper< css::document::XShapeEventBroadcaster > +{ + mutable ::osl::Mutex maListenerMutex; + ::comphelper::OInterfaceContainerHelper3<css::document::XEventListener> maEventListeners; + std::unordered_map<css::uno::Reference< css::drawing::XShape >, css::uno::Reference< css::document::XShapeEventListener >> maShapeListeners; + SdrModel *mpDrawModel; + +public: + + ScDrawModelBroadcaster( SdrModel *pDrawModel ); + virtual ~ScDrawModelBroadcaster() override; + + // css::document::XEventBroadcaster + virtual void SAL_CALL addEventListener( const css::uno::Reference< css::document::XEventListener >& xListener ) override; + virtual void SAL_CALL removeEventListener( const css::uno::Reference< css::document::XEventListener >& xListener ) override; + // css::document::XShapeEventBroadcaster + virtual void SAL_CALL addShapeEventListener( const css::uno::Reference< css::drawing::XShape >& xShape, const css::uno::Reference< css::document::XShapeEventListener >& xListener ) override; + virtual void SAL_CALL removeShapeEventListener( const css::uno::Reference< css::drawing::XShape >& xShape, const css::uno::Reference< css::document::XShapeEventListener >& xListener ) override; + + virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/ExponentialSmoothingDialog.hxx b/sc/source/ui/inc/ExponentialSmoothingDialog.hxx new file mode 100644 index 000000000..fee6bd20b --- /dev/null +++ b/sc/source/ui/inc/ExponentialSmoothingDialog.hxx @@ -0,0 +1,40 @@ +/* -*- 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_SC_SOURCE_UI_INC_EXPONENTIALSMOOTHINGDIALOG_HXX +#define INCLUDED_SC_SOURCE_UI_INC_EXPONENTIALSMOOTHINGDIALOG_HXX + +#include <address.hxx> +#include "viewdata.hxx" + +#include "StatisticsInputOutputDialog.hxx" + +class ScExponentialSmoothingDialog : public ScStatisticsInputOutputDialog +{ +private: + std::unique_ptr<weld::SpinButton> mxSmoothingFactor; + +public: + ScExponentialSmoothingDialog( + SfxBindings* pB, SfxChildWindow* pCW, + weld::Window* pParent, ScViewData* pViewData ); + + virtual ~ScExponentialSmoothingDialog() override; + + virtual void Close() override; + +protected: + virtual const char* GetUndoNameId() override; + virtual ScRange ApplyOutput(ScDocShell* pDocShell) override; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/FTestDialog.hxx b/sc/source/ui/inc/FTestDialog.hxx new file mode 100644 index 000000000..77d5b4102 --- /dev/null +++ b/sc/source/ui/inc/FTestDialog.hxx @@ -0,0 +1,34 @@ +/* -*- 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_SC_SOURCE_UI_INC_FTESTDIALOG_HXX +#define INCLUDED_SC_SOURCE_UI_INC_FTESTDIALOG_HXX + +#include "StatisticsTwoVariableDialog.hxx" + +class ScFTestDialog : public ScStatisticsTwoVariableDialog +{ +public: + ScFTestDialog( + SfxBindings* pB, SfxChildWindow* pCW, + weld::Window* pParent, ScViewData* pViewData ); + + virtual ~ScFTestDialog() override; + + virtual void Close() override; + +protected: + virtual const char* GetUndoNameId() override; + virtual ScRange ApplyOutput(ScDocShell* pDocShell) override; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/FourierAnalysisDialog.hxx b/sc/source/ui/inc/FourierAnalysisDialog.hxx new file mode 100644 index 000000000..5cd98ae77 --- /dev/null +++ b/sc/source/ui/inc/FourierAnalysisDialog.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/. + * + */ + +#ifndef INCLUDED_SC_SOURCE_UI_INC_FOURIERANALYSISDIALOG_HXX +#define INCLUDED_SC_SOURCE_UI_INC_FOURIERANALYSISDIALOG_HXX + +#include "StatisticsInputOutputDialog.hxx" + +class ScFourierAnalysisDialog : public ScStatisticsInputOutputDialog +{ + ScAddress maLabelAddr; + ScRange maActualInputRange; + SCSIZE mnLen; + + double mfMinMag; + + bool mbUse3DAddresses : 1; + bool mbGroupedByColumn : 1; + bool mbWithLabels : 1; + bool mbInverse : 1; + bool mbPolar : 1; + + std::unique_ptr<weld::CheckButton> mxWithLabelsCheckBox; + std::unique_ptr<weld::CheckButton> mxInverseCheckBox; + std::unique_ptr<weld::CheckButton> mxPolarCheckBox; + std::unique_ptr<weld::SpinButton> mxMinMagnitudeField; + std::unique_ptr<weld::Label> mxErrorMessage; + +public: + ScFourierAnalysisDialog(SfxBindings* pB, SfxChildWindow* pCW, weld::Window* pParent, + ScViewData* pViewData); + + virtual ~ScFourierAnalysisDialog() override; + + virtual void Close() override; + +protected: + virtual const char* GetUndoNameId() override; + virtual ScRange ApplyOutput(ScDocShell* pDocShell) override; + virtual bool InputRangesValid() override; + +private: + void getOptions(); + void getDataLabel(OUString& rLabel); + void genFormula(OUString& rFormula); + + DECL_LINK(CheckBoxHdl, weld::ToggleButton&, void); +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/IAnyRefDialog.hxx b/sc/source/ui/inc/IAnyRefDialog.hxx new file mode 100644 index 000000000..57d6004c8 --- /dev/null +++ b/sc/source/ui/inc/IAnyRefDialog.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_SC_SOURCE_UI_INC_IANYREFDIALOG_HXX +#define INCLUDED_SC_SOURCE_UI_INC_IANYREFDIALOG_HXX + +#include <formula/IControlReferenceHandler.hxx> + +class ScRange; +class ScDocument; +class SfxObjectShell; +namespace formula +{ + class RefEdit; + class RefButton; +} +class SAL_NO_VTABLE IAnyRefDialog : public formula::IControlReferenceHandler +{ +public: + virtual ~IAnyRefDialog() COVERITY_NOEXCEPT_FALSE {} + + virtual void SetReference( const ScRange& rRef, ScDocument& rDoc ) = 0; + virtual void RefInputStart( formula::RefEdit* pEdit, formula::RefButton* pButton = nullptr ) = 0; + virtual void RefInputDone( bool bForced = false ) = 0; + virtual bool IsTableLocked() const = 0; + virtual bool IsRefInputMode() const = 0; + + virtual bool IsDocAllowed( SfxObjectShell* pDocSh ) const = 0; + virtual void AddRefEntry() = 0; + virtual void SetActive() = 0; + virtual void ViewShellChanged() = 0; +}; + +#endif // INCLUDED_SC_SOURCE_UI_INC_IANYREFDIALOG_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/MatrixComparisonGenerator.hxx b/sc/source/ui/inc/MatrixComparisonGenerator.hxx new file mode 100644 index 000000000..47fdb3bb9 --- /dev/null +++ b/sc/source/ui/inc/MatrixComparisonGenerator.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/. + * + */ + +#ifndef INCLUDED_SC_SOURCE_UI_INC_MATRIXCOMPARISONGENERATOR_HXX +#define INCLUDED_SC_SOURCE_UI_INC_MATRIXCOMPARISONGENERATOR_HXX + +#include <address.hxx> +#include "viewdata.hxx" + +#include "StatisticsInputOutputDialog.hxx" + +class ScMatrixComparisonGenerator : public ScStatisticsInputOutputDialog +{ +public: + ScMatrixComparisonGenerator( + SfxBindings* pSfxBindings, SfxChildWindow* pChildWindow, + weld::Window* pParent, ScViewData* pViewData, + const OUString& rUiXmlDescription, const OString& rID); + + virtual ~ScMatrixComparisonGenerator() override; + +protected: + virtual const char* GetUndoNameId() override; + virtual ScRange ApplyOutput(ScDocShell* pDocShell) override; + + virtual OUString getLabel() = 0; + virtual OUString getTemplate() = 0; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/MovingAverageDialog.hxx b/sc/source/ui/inc/MovingAverageDialog.hxx new file mode 100644 index 000000000..5b373e563 --- /dev/null +++ b/sc/source/ui/inc/MovingAverageDialog.hxx @@ -0,0 +1,41 @@ +/* -*- 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_SC_SOURCE_UI_INC_MOVINGAVERAGEDIALOG_HXX +#define INCLUDED_SC_SOURCE_UI_INC_MOVINGAVERAGEDIALOG_HXX + +#include <address.hxx> +#include "viewdata.hxx" + +#include "StatisticsInputOutputDialog.hxx" + +class ScMovingAverageDialog : public ScStatisticsInputOutputDialog +{ +private: + std::unique_ptr<weld::CheckButton> mxTrimRangeCheck; + std::unique_ptr<weld::SpinButton> mxIntervalSpin; + +public: + ScMovingAverageDialog( + SfxBindings* pB, SfxChildWindow* pCW, + weld::Window* pParent, ScViewData* pViewData ); + + virtual ~ScMovingAverageDialog() override; + + virtual void Close() override; + +protected: + virtual const char* GetUndoNameId() override; + virtual ScRange ApplyOutput(ScDocShell* pDocShell) override; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/PivotLayoutDialog.hxx b/sc/source/ui/inc/PivotLayoutDialog.hxx new file mode 100644 index 000000000..99f727273 --- /dev/null +++ b/sc/source/ui/inc/PivotLayoutDialog.hxx @@ -0,0 +1,142 @@ +/* -*- 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_SC_SOURCE_UI_INC_PIVOTLAYOUTDIALOG_HXX +#define INCLUDED_SC_SOURCE_UI_INC_PIVOTLAYOUTDIALOG_HXX + +#include "anyrefdg.hxx" +#include <dpobject.hxx> +#include "viewdata.hxx" + +#include "PivotLayoutTreeList.hxx" +#include "PivotLayoutTreeListData.hxx" +#include "PivotLayoutTreeListLabel.hxx" + +class ScItemValue final +{ +public: + OUString maName; + ScPivotFuncData maFunctionData; + ScItemValue* mpOriginalItemValue; + + ScItemValue(OUString const & aName, SCCOL nColumn, PivotFunc nFunctionMask); + ScItemValue(const ScItemValue* pInputItemValue); + + ~ScItemValue(); +}; + +class ScPivotLayoutDialog : public ScAnyRefDlgController +{ +public: + ScDPObject maPivotTableObject; + + ScPivotLayoutTreeListBase* mpPreviouslyFocusedListBox; + +private: + ScViewData* mpViewData; + ScDocument& mrDocument; + + bool mbNewPivotTable; + + ScAddress::Details maAddressDetails; + bool mbDialogLostFocus; + + formula::RefEdit* mpActiveEdit; + std::unique_ptr<ScPivotLayoutTreeListLabel> mxListBoxField; + std::unique_ptr<ScPivotLayoutTreeList> mxListBoxPage; + std::unique_ptr<ScPivotLayoutTreeList> mxListBoxColumn; + std::unique_ptr<ScPivotLayoutTreeList> mxListBoxRow; + std::unique_ptr<ScPivotLayoutTreeListData> mxListBoxData; + + std::unique_ptr<weld::CheckButton> mxCheckIgnoreEmptyRows; + std::unique_ptr<weld::CheckButton> mxCheckTotalColumns; + std::unique_ptr<weld::CheckButton> mxCheckAddFilter; + std::unique_ptr<weld::CheckButton> mxCheckIdentifyCategories; + std::unique_ptr<weld::CheckButton> mxCheckTotalRows; + std::unique_ptr<weld::CheckButton> mxCheckDrillToDetail; + + std::unique_ptr<weld::RadioButton> mxSourceRadioNamedRange; + std::unique_ptr<weld::RadioButton> mxSourceRadioSelection; + + std::unique_ptr<weld::ComboBox> mxSourceListBox; + std::unique_ptr<formula::RefEdit> mxSourceEdit; + std::unique_ptr<formula::RefButton> mxSourceButton; + + std::unique_ptr<weld::RadioButton> mxDestinationRadioNewSheet; + std::unique_ptr<weld::RadioButton> mxDestinationRadioNamedRange; + std::unique_ptr<weld::RadioButton> mxDestinationRadioSelection; + + std::unique_ptr<weld::ComboBox> mxDestinationListBox; + std::unique_ptr<formula::RefEdit> mxDestinationEdit; + std::unique_ptr<formula::RefButton> mxDestinationButton; + + std::unique_ptr<weld::Button> mxBtnOK; + std::unique_ptr<weld::Button> mxBtnCancel; + + std::unique_ptr<weld::Frame> mxSourceFrame; + std::unique_ptr<weld::Label> mxSourceLabel; + std::unique_ptr<weld::Frame> mxDestFrame; + std::unique_ptr<weld::Label> mxDestLabel; + + std::unique_ptr<weld::Expander> mxOptions; + std::unique_ptr<weld::Expander> mxMore; + + DECL_LINK(CancelClicked, weld::Button&, void); + DECL_LINK(OKClicked, weld::Button&, void); + DECL_LINK(GetEditFocusHandler, formula::RefEdit&, void); + DECL_LINK(GetButtonFocusHandler, formula::RefButton&, void); + DECL_LINK(LoseEditFocusHandler, formula::RefEdit&, void); + DECL_LINK(LoseButtonFocusHandler, formula::RefButton&, void); + DECL_LINK(ToggleSource, weld::ToggleButton&, void); + DECL_LINK(ToggleDestination, weld::ToggleButton&, void); + DECL_LINK(SourceListSelected, weld::ComboBox&, void); + DECL_LINK(SourceEditModified, formula::RefEdit&, void); + void ToggleSource(); + void ToggleDestination(); + virtual void Close() override; + + ScPivotParam maPivotParameters; + + // UI + void SetupSource(); + void SetupDestination(); + void FillValuesToListBoxes(); + + // Other + bool GetDestination(ScRange& aDestinationRange, bool& bToNewSheet); + +public: + ScPivotLayoutDialog(SfxBindings* pSfxBindings, SfxChildWindow* pChildWindow, weld::Window* pParent, + ScViewData* pViewData, const ScDPObject* pPivotTableObject, bool bCreateNewPivotTable); + virtual ~ScPivotLayoutDialog() override; + + virtual void SetReference(const ScRange& rReferenceRange, ScDocument& rDocument) override; + virtual void SetActive() override; + virtual bool IsRefInputMode() const override; + + void ItemInserted(const ScItemValue* pItemValue, ScPivotLayoutTreeList::SvPivotTreeListType eType); + + void UpdateSourceRange(); + + void ApplyChanges(); + void ApplySaveData(ScDPSaveData& rSaveData); + void ApplyLabelData(const ScDPSaveData& rSaveData); + + ScItemValue* GetItem(SCCOL nColumn); + bool IsDataElement(SCCOL nColumn); + + ScDPLabelData& GetLabelData(SCCOL nColumn); + ScDPLabelDataVector& GetLabelDataVector() { return maPivotParameters.maLabelArray;} + void PushDataFieldNames(std::vector<ScDPName>& rDataFieldNames); +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ + +#endif diff --git a/sc/source/ui/inc/PivotLayoutTreeList.hxx b/sc/source/ui/inc/PivotLayoutTreeList.hxx new file mode 100644 index 000000000..ab1ce9c93 --- /dev/null +++ b/sc/source/ui/inc/PivotLayoutTreeList.hxx @@ -0,0 +1,41 @@ +/* -*- 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_SC_SOURCE_UI_INC_PIVOTLAYOUTTREELIST_HXX +#define INCLUDED_SC_SOURCE_UI_INC_PIVOTLAYOUTTREELIST_HXX + +#include <memory> +#include <tools/solar.h> +#include "PivotLayoutTreeListBase.hxx" + +class ScPivotLayoutTreeList : public ScPivotLayoutTreeListBase +{ +private: + std::vector<std::unique_ptr<ScItemValue>> maItemValues; + + DECL_LINK(KeyInputHdl, const KeyEvent&, bool); + DECL_LINK(DoubleClickHdl, weld::TreeView&, bool); + +public: + ScPivotLayoutTreeList(std::unique_ptr<weld::TreeView> xControl); + virtual ~ScPivotLayoutTreeList() override; + + void Setup(ScPivotLayoutDialog* pParent, SvPivotTreeListType eType); + void FillFields(ScPivotFieldVector& rFieldVector); + + virtual void InsertEntryForSourceTarget(weld::TreeView& rSource, int nTarget) override; + +protected: + void InsertEntryForItem(const ScItemValue* pItemValue, int nPosition); +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ + +#endif diff --git a/sc/source/ui/inc/PivotLayoutTreeListBase.hxx b/sc/source/ui/inc/PivotLayoutTreeListBase.hxx new file mode 100644 index 000000000..fbb026330 --- /dev/null +++ b/sc/source/ui/inc/PivotLayoutTreeListBase.hxx @@ -0,0 +1,72 @@ +/* -*- 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_SC_SOURCE_UI_INC_PIVOTLAYOUTTREELISTBASE_HXX +#define INCLUDED_SC_SOURCE_UI_INC_PIVOTLAYOUTTREELISTBASE_HXX + +#include <vcl/transfer.hxx> +#include <vcl/weld.hxx> +#include <pivot.hxx> + +class ScPivotLayoutDialog; +class ScPivotLayoutTreeListBase; +class ScItemValue; + +class ScPivotLayoutTreeDropTarget : public DropTargetHelper +{ +private: + ScPivotLayoutTreeListBase& m_rTreeView; + + virtual sal_Int8 AcceptDrop( const AcceptDropEvent& rEvt ) override; + virtual sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt ) override; + +public: + ScPivotLayoutTreeDropTarget(ScPivotLayoutTreeListBase& rTreeView); +}; + +class ScPivotLayoutTreeListBase +{ +public: + enum SvPivotTreeListType + { + UNDEFINED, + LABEL_LIST, + PAGE_LIST, + ROW_LIST, + COLUMN_LIST + }; + +protected: + std::unique_ptr<weld::TreeView> mxControl; + ScPivotLayoutTreeDropTarget maDropTargetHelper; + SvPivotTreeListType meType; + ScPivotLayoutDialog* mpParent; + + DECL_LINK(GetFocusHdl, weld::Widget&, void); + DECL_LINK(MnemonicActivateHdl, weld::Widget&, bool); + DECL_LINK(LoseFocusHdl, weld::Widget&, void); + +public: + void Setup(ScPivotLayoutDialog* pParent); + + ScPivotLayoutTreeListBase(std::unique_ptr<weld::TreeView> xControl, SvPivotTreeListType eType = UNDEFINED); + weld::TreeView& get_widget() { return *mxControl; } + virtual ~ScPivotLayoutTreeListBase(); + + void PushEntriesToPivotFieldVector(ScPivotFieldVector& rVector); + + void RemoveEntryForItem(const ScItemValue* pItemValue); + + virtual void InsertEntryForSourceTarget(weld::TreeView& rSource, int nTarget); +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ + +#endif diff --git a/sc/source/ui/inc/PivotLayoutTreeListData.hxx b/sc/source/ui/inc/PivotLayoutTreeListData.hxx new file mode 100644 index 000000000..5041ff12b --- /dev/null +++ b/sc/source/ui/inc/PivotLayoutTreeListData.hxx @@ -0,0 +1,43 @@ +/* -*- 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_SC_SOURCE_UI_INC_PIVOTLAYOUTTREELISTDATA_HXX +#define INCLUDED_SC_SOURCE_UI_INC_PIVOTLAYOUTTREELISTDATA_HXX + +#include "PivotLayoutTreeListBase.hxx" +#include <tools/solar.h> +#include <vector> +#include <memory> + +class ScPivotLayoutTreeListData final : public ScPivotLayoutTreeListBase +{ +private: + DECL_LINK(KeyInputHdl, const KeyEvent&, bool); + DECL_LINK(DoubleClickHdl, weld::TreeView&, bool); + +public: + ScPivotLayoutTreeListData(std::unique_ptr<weld::TreeView> xControl); + virtual ~ScPivotLayoutTreeListData() override; + + void FillDataField(ScPivotFieldVector& rDataFields); + void PushDataFieldNames(std::vector<ScDPName>& rDataFieldNames); + virtual void InsertEntryForSourceTarget(weld::TreeView& rSource, int nTarget) override; + +private: + void InsertEntryForItem(ScItemValue* pItemValue, int nPosition); + + void AdjustDuplicateCount(ScItemValue* pInputItemValue); + + std::vector<std::unique_ptr<ScItemValue>> maDataItemValues; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ + +#endif diff --git a/sc/source/ui/inc/PivotLayoutTreeListLabel.hxx b/sc/source/ui/inc/PivotLayoutTreeListLabel.hxx new file mode 100644 index 000000000..ac2ccc0b1 --- /dev/null +++ b/sc/source/ui/inc/PivotLayoutTreeListLabel.hxx @@ -0,0 +1,36 @@ +/* -*- 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_SC_SOURCE_UI_INC_PIVOTLAYOUTTREELISTLABEL_HXX +#define INCLUDED_SC_SOURCE_UI_INC_PIVOTLAYOUTTREELISTLABEL_HXX + +#include "PivotLayoutTreeListBase.hxx" +#include <vector> +#include <memory> + +class ScPivotLayoutTreeListLabel : public ScPivotLayoutTreeListBase +{ +private: + std::vector<std::unique_ptr<ScItemValue> > maItemValues; + SCCOL maDataItem; + + DECL_LINK(KeyInputHdl, const KeyEvent&, bool); +public: + ScPivotLayoutTreeListLabel(std::unique_ptr<weld::TreeView> xControl); + virtual ~ScPivotLayoutTreeListLabel() override; + void FillLabelFields(ScDPLabelDataVector& rLabelVector); + ScItemValue* GetItem(SCCOL nColumn); + bool IsDataElement(SCCOL nColumn); + virtual void InsertEntryForSourceTarget(weld::TreeView& rSource, int nTarget) override; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ + +#endif diff --git a/sc/source/ui/inc/RandomNumberGeneratorDialog.hxx b/sc/source/ui/inc/RandomNumberGeneratorDialog.hxx new file mode 100644 index 000000000..4e6607f9c --- /dev/null +++ b/sc/source/ui/inc/RandomNumberGeneratorDialog.hxx @@ -0,0 +1,88 @@ +/* -*- 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_SC_SOURCE_UI_INC_RANDOMNUMBERGENERATORDIALOG_HXX +#define INCLUDED_SC_SOURCE_UI_INC_RANDOMNUMBERGENERATORDIALOG_HXX + +#include <sal/config.h> + +#include <optional> + +#include <address.hxx> +#include "anyrefdg.hxx" +#include "viewdata.hxx" + +class ScRandomNumberGeneratorDialog : public ScAnyRefDlgController +{ +public: + ScRandomNumberGeneratorDialog( + SfxBindings* pB, SfxChildWindow* pCW, + weld::Window* pParent, ScViewData* pViewData ); + + virtual ~ScRandomNumberGeneratorDialog() override; + + virtual void SetReference( const ScRange& rRef, ScDocument& rDoc ) override; + virtual void SetActive() override; + virtual void Close() override; + +private: + // Data + ScViewData* mpViewData; + const ScDocument& mrDoc; + + ScRange maInputRange; + + bool mbDialogLostFocus; + + // Widgets + std::unique_ptr<weld::Label> mxInputRangeText; + std::unique_ptr<formula::RefEdit> mxInputRangeEdit; + std::unique_ptr<formula::RefButton> mxInputRangeButton; + std::unique_ptr<weld::ComboBox> mxDistributionCombo; + std::unique_ptr<weld::Label> mxParameter1Text; + std::unique_ptr<weld::SpinButton> mxParameter1Value; + std::unique_ptr<weld::Label> mxParameter2Text; + std::unique_ptr<weld::SpinButton> mxParameter2Value; + std::unique_ptr<weld::SpinButton> mxSeed; + std::unique_ptr<weld::CheckButton> mxEnableSeed; + std::unique_ptr<weld::SpinButton> mxDecimalPlaces; + std::unique_ptr<weld::CheckButton> mxEnableRounding; + std::unique_ptr<weld::Button> mxButtonApply; + std::unique_ptr<weld::Button> mxButtonOk; + std::unique_ptr<weld::Button> mxButtonClose; + + void Init(); + void GetRangeFromSelection(); + + template<class RNG> + + void GenerateNumbers(RNG& randomGenerator, const char* pDistributionStringId, const std::optional<sal_Int8> aDecimalPlaces); + + void SelectGeneratorAndGenerateNumbers(); + + DECL_LINK( OkClicked, weld::Button&, void ); + DECL_LINK( CloseClicked, weld::Button&, void ); + DECL_LINK( ApplyClicked, weld::Button&, void ); + DECL_LINK( GetEditFocusHandler, formula::RefEdit&, void ); + DECL_LINK( GetButtonFocusHandler, formula::RefButton&, void ); + DECL_LINK( LoseEditFocusHandler, formula::RefEdit&, void ); + DECL_LINK( LoseButtonFocusHandler, formula::RefButton&, void ); + + DECL_LINK( InputRangeModified, formula::RefEdit&, void ); + DECL_LINK( Parameter1ValueModified, weld::SpinButton&, void ); + DECL_LINK( Parameter2ValueModified, weld::SpinButton&, void ); + DECL_LINK( DistributionChanged, weld::ComboBox&, void ); + DECL_LINK( CheckChanged, weld::ToggleButton&, void ); + +}; + +#endif // INCLUDED_SC_SOURCE_UI_INC_RANDOMNUMBERGENERATORDIALOG_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/RegressionDialog.hxx b/sc/source/ui/inc/RegressionDialog.hxx new file mode 100644 index 000000000..c5359520f --- /dev/null +++ b/sc/source/ui/inc/RegressionDialog.hxx @@ -0,0 +1,84 @@ +/* -*- 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_SC_SOURCE_UI_INC_REGRESSIONDIALOG_HXX +#define INCLUDED_SC_SOURCE_UI_INC_REGRESSIONDIALOG_HXX + +#include "StatisticsTwoVariableDialog.hxx" + +class ScRegressionDialog : public ScStatisticsTwoVariableDialog +{ + bool mbUnivariate; + size_t mnNumIndependentVars; + size_t mnNumObservations; + bool mbUse3DAddresses; + bool mbCalcIntercept; + + std::unique_ptr<weld::CheckButton> mxWithLabelsCheckBox; + std::unique_ptr<weld::RadioButton> mxLinearRadioButton; + std::unique_ptr<weld::RadioButton> mxLogarithmicRadioButton; + std::unique_ptr<weld::RadioButton> mxPowerRadioButton; + std::unique_ptr<weld::Label> mxErrorMessage; + std::unique_ptr<weld::SpinButton> mxConfidenceLevelField; + std::unique_ptr<weld::CheckButton> mxCalcResidualsCheckBox; + std::unique_ptr<weld::CheckButton> mxNoInterceptCheckBox; + +public: + ScRegressionDialog( + SfxBindings* pB, SfxChildWindow* pCW, + weld::Window* pParent, ScViewData* pViewData ); + + virtual ~ScRegressionDialog() override; + + virtual void Close() override; + +protected: + virtual const char* GetUndoNameId() override; + virtual ScRange ApplyOutput(ScDocShell* pDocShell) override; + virtual bool InputRangesValid() override; + +private: + + using CellValueGetter = const OUString&(size_t, size_t); + using CellWriter = void(const OUString&, size_t, size_t); + + size_t GetRegressionTypeIndex() const; + ScRange GetDataRange(const ScRange& rRange); + OUString GetVariableNameFormula(bool bXVar, size_t nIndex, bool bWithLog); + OUString GetXVariableNameFormula(size_t nIndex, bool bWithLog); + OUString GetYVariableNameFormula(bool bWithLog); + + // Helper methods for writing different parts of regression results. + void WriteRawRegressionResults(AddressWalkerWriter& rOutput, + FormulaTemplate& rTemplate, + size_t nRegressionIndex); + void WriteRegressionStatistics(AddressWalkerWriter& rOutput, + FormulaTemplate& rTemplate); + void WriteRegressionANOVAResults(AddressWalkerWriter& rOutput, + FormulaTemplate& rTemplate); + void WriteRegressionEstimatesWithCI(AddressWalkerWriter& rOutput, + FormulaTemplate& rTemplate, + bool bTakeLogX); + void WritePredictionsWithResiduals(AddressWalkerWriter& rOutput, + FormulaTemplate& rTemplate, + size_t nRegressionIndex); + // Generic table writer + static void WriteTable(const std::function<CellValueGetter>& rCellGetter, size_t nRowsInTable, + size_t nColsInTable, AddressWalkerWriter& rOutput, + const std::function<CellWriter>& rFunc); + + DECL_LINK( CheckBoxHdl, weld::ToggleButton&, void ); + DECL_LINK( NumericFieldHdl, weld::SpinButton&, void ); +}; + + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/SamplingDialog.hxx b/sc/source/ui/inc/SamplingDialog.hxx new file mode 100644 index 000000000..29aaa8087 --- /dev/null +++ b/sc/source/ui/inc/SamplingDialog.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/. + * + */ + +#ifndef INCLUDED_SC_SOURCE_UI_INC_SAMPLINGDIALOG_HXX +#define INCLUDED_SC_SOURCE_UI_INC_SAMPLINGDIALOG_HXX + +#include <address.hxx> +#include "anyrefdg.hxx" +#include "viewdata.hxx" + +class ScSamplingDialog : public ScAnyRefDlgController +{ +public: + ScSamplingDialog( + SfxBindings* pB, SfxChildWindow* pCW, + weld::Window* pParent, ScViewData* pViewData ); + + virtual ~ScSamplingDialog() override; + + virtual void SetReference( const ScRange& rRef, ScDocument& rDoc ) override; + virtual void SetActive() override; + virtual void Close() override; + +private: + formula::RefEdit* mpActiveEdit; + + // Data + ScViewData* mViewData; + const ScDocument& mDocument; + + ScRange mInputRange; + ScAddress::Details mAddressDetails; + ScAddress mOutputAddress; + + ScAddress mCurrentAddress; + + sal_Int64 mnLastSampleSizeValue; + sal_Int64 mnLastPeriodValue; + + bool mDialogLostFocus; + + // Widgets + std::unique_ptr<weld::Label> mxInputRangeLabel; + std::unique_ptr<formula::RefEdit> mxInputRangeEdit; + std::unique_ptr<formula::RefButton> mxInputRangeButton; + + std::unique_ptr<weld::Label> mxOutputRangeLabel; + std::unique_ptr<formula::RefEdit> mxOutputRangeEdit; + std::unique_ptr<formula::RefButton> mxOutputRangeButton; + + std::unique_ptr<weld::SpinButton> mxSampleSize; + std::unique_ptr<weld::SpinButton> mxPeriod; + + std::unique_ptr<weld::RadioButton> mxRandomMethodRadio; + std::unique_ptr<weld::CheckButton> mxWithReplacement; + std::unique_ptr<weld::CheckButton> mxKeepOrder; + std::unique_ptr<weld::RadioButton> mxPeriodicMethodRadio; + + std::unique_ptr<weld::Button> mxButtonOk; + + void Init(); + void GetRangeFromSelection(); + void PerformSampling(); + sal_Int64 GetPopulationSize() const; + void LimitSampleSizeAndPeriod(); + + ScRange PerformRandomSampling(ScDocShell* pDocShell); + ScRange PerformRandomSamplingKeepOrder(ScDocShell* pDocShell); + ScRange PerformPeriodicSampling(ScDocShell* pDocShell); + + DECL_LINK( OkClicked, weld::Button&, void ); + DECL_LINK( GetEditFocusHandler, formula::RefEdit&, void ); + DECL_LINK( GetButtonFocusHandler, formula::RefButton&, void ); + DECL_LINK( LoseEditFocusHandler, formula::RefEdit&, void ); + DECL_LINK( LoseButtonFocusHandler, formula::RefButton&, void ); + DECL_LINK( SamplingSizeValueModified, weld::SpinButton&, void ); + DECL_LINK( PeriodValueModified, weld::SpinButton&, void ); + DECL_LINK( ToggleSamplingMethod, weld::ToggleButton&, void ); + DECL_LINK( RefInputModifyHandler, formula::RefEdit&, void ); + DECL_LINK( CheckHdl, weld::Button&, void ); + void ToggleSamplingMethod(); +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/StatisticsInputOutputDialog.hxx b/sc/source/ui/inc/StatisticsInputOutputDialog.hxx new file mode 100644 index 000000000..a3be27b1a --- /dev/null +++ b/sc/source/ui/inc/StatisticsInputOutputDialog.hxx @@ -0,0 +1,92 @@ +/* -*- 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_SC_SOURCE_UI_INC_STATISTICSINPUTOUTPUTDIALOG_HXX +#define INCLUDED_SC_SOURCE_UI_INC_STATISTICSINPUTOUTPUTDIALOG_HXX + +#include <address.hxx> +#include "anyrefdg.hxx" +#include "viewdata.hxx" + +class ScStatisticsInputOutputDialog : public ScAnyRefDlgController +{ +public: + enum GroupedBy { + BY_COLUMN, + BY_ROW + }; + + ScStatisticsInputOutputDialog( + SfxBindings* pB, SfxChildWindow* pCW, + weld::Window* pParent, ScViewData* pViewData, + const OUString& rUIXMLDescription, + const OString& rID); + + virtual ~ScStatisticsInputOutputDialog() override; + + virtual void SetReference( const ScRange& rRef, ScDocument& rDoc ) override; + virtual void SetActive() override; + +protected: + void CalculateInputAndWriteToOutput(); + + virtual ScRange ApplyOutput(ScDocShell* pDocShell) = 0; + virtual const char* GetUndoNameId() = 0; + virtual bool InputRangesValid(); + void ValidateDialogInput(); + + // Widgets + std::unique_ptr<weld::Label> mxInputRangeLabel; + std::unique_ptr<formula::RefEdit> mxInputRangeEdit; + std::unique_ptr<formula::RefButton> mxInputRangeButton; + + std::unique_ptr<weld::Label> mxOutputRangeLabel; + std::unique_ptr<formula::RefEdit> mxOutputRangeEdit; + std::unique_ptr<formula::RefButton> mxOutputRangeButton; + + std::unique_ptr<weld::RadioButton> mxGroupByColumnsRadio; + std::unique_ptr<weld::RadioButton> mxGroupByRowsRadio; + + // Data + ScViewData* mViewData; + ScDocument& mDocument; + + ScRange mInputRange; + ScAddress::Details mAddressDetails; + ScAddress mOutputAddress; + GroupedBy mGroupedBy; + + static ScRangeList MakeColumnRangeList(SCTAB aTab, ScAddress const & aStart, ScAddress const & aEnd); + static ScRangeList MakeRowRangeList(SCTAB aTab, ScAddress const & aStart, ScAddress const & aEnd); + +private: + // Widgets + std::unique_ptr<weld::Button> mxButtonOk; + + formula::RefEdit* mpActiveEdit; + ScAddress mCurrentAddress; + bool mDialogLostFocus; + + void Init(); + void GetRangeFromSelection(); + + DECL_LINK( GroupByChanged, weld::ToggleButton&, void ); + DECL_LINK( OkClicked, weld::Button&, void ); + DECL_LINK( GetEditFocusHandler, formula::RefEdit&, void ); + DECL_LINK( GetButtonFocusHandler, formula::RefButton&, void ); + DECL_LINK( LoseEditFocusHandler, formula::RefEdit&, void ); + DECL_LINK( LoseButtonFocusHandler, formula::RefButton&, void ); + DECL_LINK( RefInputModifyHandler, formula::RefEdit&, void ); +}; + + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/StatisticsTwoVariableDialog.hxx b/sc/source/ui/inc/StatisticsTwoVariableDialog.hxx new file mode 100644 index 000000000..8b870642e --- /dev/null +++ b/sc/source/ui/inc/StatisticsTwoVariableDialog.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/. + * + */ + +#ifndef INCLUDED_SC_SOURCE_UI_INC_STATISTICSTWOVARIABLEDIALOG_HXX +#define INCLUDED_SC_SOURCE_UI_INC_STATISTICSTWOVARIABLEDIALOG_HXX + +#include <address.hxx> +#include "anyrefdg.hxx" +#include "viewdata.hxx" + +class ScStatisticsTwoVariableDialog : public ScAnyRefDlgController +{ +public: + enum GroupedBy { + BY_COLUMN, + BY_ROW + }; + + ScStatisticsTwoVariableDialog( + SfxBindings* pB, SfxChildWindow* pCW, + weld::Window* pParent, ScViewData* pViewData, + const OUString& rUIXMLDescription, const OString& rID); + + virtual ~ScStatisticsTwoVariableDialog() override; + + virtual void SetReference( const ScRange& rRef, ScDocument& rDoc ) override; + virtual void SetActive() override; + +protected: + void CalculateInputAndWriteToOutput(); + + virtual ScRange ApplyOutput(ScDocShell* pDocShell) = 0; + virtual const char* GetUndoNameId() = 0; + virtual bool InputRangesValid(); + void ValidateDialogInput(); + + // Widgets + std::unique_ptr<weld::Label> mxVariable1RangeLabel; + std::unique_ptr<formula::RefEdit> mxVariable1RangeEdit; + std::unique_ptr<formula::RefButton> mxVariable1RangeButton; + + std::unique_ptr<weld::Label> mxVariable2RangeLabel; + std::unique_ptr<formula::RefEdit> mxVariable2RangeEdit; + std::unique_ptr<formula::RefButton> mxVariable2RangeButton; + + std::unique_ptr<weld::Label> mxOutputRangeLabel; + std::unique_ptr<formula::RefEdit> mxOutputRangeEdit; + std::unique_ptr<formula::RefButton> mxOutputRangeButton; + + // Data + ScViewData* mViewData; + ScDocument& mDocument; + + ScRange mVariable1Range; + ScRange mVariable2Range; + + ScAddress::Details const mAddressDetails; + ScAddress mOutputAddress; + GroupedBy mGroupedBy; + +private: + // Widgets + std::unique_ptr<weld::Button> mxButtonOk; + + std::unique_ptr<weld::RadioButton> mxGroupByColumnsRadio; + std::unique_ptr<weld::RadioButton> mxGroupByRowsRadio; + + formula::RefEdit* mpActiveEdit; + ScAddress mCurrentAddress; + bool mDialogLostFocus; + + void Init(); + void GetRangeFromSelection(); + + DECL_LINK( GroupByChanged, weld::ToggleButton&, void ); + DECL_LINK( OkClicked, weld::Button&, void ); + DECL_LINK( GetEditFocusHandler, formula::RefEdit&, void ); + DECL_LINK( GetButtonFocusHandler, formula::RefButton&, void ); + DECL_LINK( LoseEditFocusHandler, formula::RefEdit&, void ); + DECL_LINK( LoseButtonFocusHandler, formula::RefButton&, void ); + DECL_LINK( RefInputModifyHandler, formula::RefEdit&, void ); +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/TTestDialog.hxx b/sc/source/ui/inc/TTestDialog.hxx new file mode 100644 index 000000000..cea829c70 --- /dev/null +++ b/sc/source/ui/inc/TTestDialog.hxx @@ -0,0 +1,34 @@ +/* -*- 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_SC_SOURCE_UI_INC_TTESTDIALOG_HXX +#define INCLUDED_SC_SOURCE_UI_INC_TTESTDIALOG_HXX + +#include "StatisticsTwoVariableDialog.hxx" + +class ScTTestDialog : public ScStatisticsTwoVariableDialog +{ +public: + ScTTestDialog( + SfxBindings* pB, SfxChildWindow* pCW, + weld::Window* pParent, ScViewData* pViewData ); + + virtual ~ScTTestDialog() override; + + virtual void Close() override; + +protected: + virtual const char* GetUndoNameId() override; + virtual ScRange ApplyOutput(ScDocShell* pDocShell) override; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/TableFillingAndNavigationTools.hxx b/sc/source/ui/inc/TableFillingAndNavigationTools.hxx new file mode 100644 index 000000000..9d4e82956 --- /dev/null +++ b/sc/source/ui/inc/TableFillingAndNavigationTools.hxx @@ -0,0 +1,162 @@ +/* -*- 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_SC_SOURCE_UI_INC_TABLEFILLINGANDNAVIGATIONTOOLS_HXX +#define INCLUDED_SC_SOURCE_UI_INC_TABLEFILLINGANDNAVIGATIONTOOLS_HXX + +#include <address.hxx> +#include <rangelst.hxx> + +#include <vector> + +class FormulaTemplate +{ +private: + OUString mTemplate; + ScDocument* mpDoc; + bool mbUse3D; + + typedef std::map<OUString, ScRange> RangeReplacementMap; + typedef std::map<OUString, ScAddress> AddressReplacementMap; + + AddressReplacementMap mAddressReplacementMap; + RangeReplacementMap mRangeReplacementMap; + +public: + FormulaTemplate(ScDocument* pDoc); + + void setTemplate(const OUString& aTemplate); + void setTemplate(const char* aTemplate); + const OUString& getTemplate(); + + void autoReplaceRange(const OUString& aVariable, const ScRange& rRange); + void autoReplaceAddress(const OUString& aVariable, ScAddress const & aAddress); + void autoReplaceUses3D(bool bUse3D) { mbUse3D = bUse3D; } + + void applyRange(const OUString& aVariable, const ScRange& aRange, bool b3D = true); + void applyRangeList(const OUString& aVariable, const ScRangeList& aRangeList, sal_Unicode cDelimiter ); + void applyAddress(const OUString& aVariable, const ScAddress& aAddress, bool b3D = true); + void applyString(const OUString& aVariable, const OUString& aValue); + void applyNumber(const OUString& aVariable, sal_Int32 aValue); +}; + +class AddressWalker +{ +public: + std::vector<ScAddress> mAddressStack; + + ScAddress mCurrentAddress; + ScAddress mMinimumAddress; + ScAddress mMaximumAddress; + + AddressWalker(const ScAddress& aInitialAddress); + + ScAddress current(SCCOL aRelativeCol = 0, SCROW aRelativeRow = 0, SCTAB aRelativeTab = 0); + + void reset(); + void resetColumn(); + void resetRow(); + void nextColumn(); + void nextRow(); + void newLine(); + void push(SCCOL aRelativeCol = 0, SCROW aRelativeRow = 0, SCTAB aRelativeTab = 0); +}; + +class AddressWalkerWriter : public AddressWalker +{ +public: + ScDocShell* mpDocShell; + ScDocument* mpDocument; + formula::FormulaGrammar::Grammar meGrammar; + + AddressWalkerWriter(const ScAddress& aInitialAddress, ScDocShell* pDocShell, ScDocument* pDocument, + formula::FormulaGrammar::Grammar eGrammar ); + + void writeFormula(const OUString& aFormula); + void writeFormulas(const std::vector<OUString>& rFormulas); + void writeMatrixFormula(const OUString& aFormula, SCCOL nCols = 1, SCROW nRows = 1); + void writeString(const OUString& aString); + void writeString(const char* aCharArray); + void writeBoldString(const OUString& aString); + void writeValue(double aValue); +}; + +class DataCellIterator final +{ +private: + ScRange mInputRange; + bool mByColumn; + SCCOL mCol; + SCROW mRow; + +public: + DataCellIterator(const ScRange& aInputRange, bool aByColumn); + ~DataCellIterator(); + + bool hasNext() const; + ScAddress get(); + void next(); + ScAddress getRelative(int aDelta); +}; + +class DataRangeIterator +{ +protected: + ScRange mInputRange; + sal_Int32 mIndex; + +public: + DataRangeIterator(const ScRange& aInputRange); + virtual ~DataRangeIterator(); + + virtual bool hasNext() = 0; + virtual ScRange get() = 0; + virtual size_t size() = 0; + virtual void next() = 0; + virtual void reset() = 0; + + sal_Int32 index(); + + virtual DataCellIterator iterateCells() = 0; +}; + +class DataRangeByColumnIterator final : public DataRangeIterator +{ + SCCOL mCol; + +public: + DataRangeByColumnIterator(const ScRange& aInputRange); + + virtual bool hasNext() override; + virtual void next() override; + virtual ScRange get() override; + virtual size_t size() override; + virtual void reset() override; + virtual DataCellIterator iterateCells() override; +}; + +class DataRangeByRowIterator final : public DataRangeIterator +{ + SCROW mRow; + +public: + DataRangeByRowIterator(const ScRange& aInputRange); + + virtual bool hasNext() override; + virtual void next() override; + virtual ScRange get() override; + virtual size_t size() override; + virtual void reset() override; + virtual DataCellIterator iterateCells() override; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/ZTestDialog.hxx b/sc/source/ui/inc/ZTestDialog.hxx new file mode 100644 index 000000000..ae60b8341 --- /dev/null +++ b/sc/source/ui/inc/ZTestDialog.hxx @@ -0,0 +1,34 @@ +/* -*- 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_SC_SOURCE_UI_INC_ZTESTDIALOG_HXX +#define INCLUDED_SC_SOURCE_UI_INC_ZTESTDIALOG_HXX + +#include "StatisticsTwoVariableDialog.hxx" + +class ScZTestDialog : public ScStatisticsTwoVariableDialog +{ +public: + ScZTestDialog( + SfxBindings* pB, SfxChildWindow* pCW, + weld::Window* pParent, ScViewData* pViewData ); + + virtual ~ScZTestDialog() override; + + virtual void Close() override; + +protected: + virtual const char* GetUndoNameId() override; + virtual ScRange ApplyOutput(ScDocShell* pDocShell) override; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/acredlin.hxx b/sc/source/ui/inc/acredlin.hxx new file mode 100644 index 000000000..a8d18b185 --- /dev/null +++ b/sc/source/ui/inc/acredlin.hxx @@ -0,0 +1,164 @@ +/* -*- 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_SC_SOURCE_UI_INC_ACREDLIN_HXX +#define INCLUDED_SC_SOURCE_UI_INC_ACREDLIN_HXX + +#include <svx/ctredlin.hxx> +#include <chgtrack.hxx> +#include <chgviset.hxx> +#include <vcl/idle.hxx> + +class ScViewData; +class ScDocument; + +struct SfxChildWinInfo; + +class ScRedlinData : public RedlinData +{ +public: + ScRedlinData(); + virtual ~ScRedlinData() override; + SCTAB nTable; + SCCOL nCol; + SCROW nRow; + sal_uLong nActionNo; + sal_uLong nInfo; + bool bIsRejectable; + bool bIsAcceptable; +}; + +class ScAcceptChgDlg final : public SfxModelessDialogController +{ + Idle aSelectionIdle; + Idle aReOpenIdle; + ScViewData* pViewData; + ScDocument* pDoc; + ScRangeList aRangeList; + ScChangeViewSettings aChangeViewSet; + OUString aStrInsertCols; + OUString aStrInsertRows; + OUString aStrInsertTabs; + OUString aStrDeleteCols; + OUString aStrDeleteRows; + OUString aStrDeleteTabs; + OUString aStrMove; + OUString aStrContent; + OUString aStrReject; + OUString aStrAllAccepted; + OUString aStrAllRejected; + OUString aStrNoEntry; + OUString aStrContentWithChild; + OUString aStrChildContent; + OUString aStrChildOrgContent; + OUString aStrEmpty; + OUString aUnknown; + sal_uLong nAcceptCount; + sal_uLong nRejectCount; + bool bIgnoreMsg:1; + bool bNoSelection:1; + bool bHasFilterEntry:1; + bool bUseColor:1; + + SvxTPFilter* pTPFilter; + SvxTPView* pTPView; + SvxRedlinTable* pTheView; // #i48648 now SvHeaderTabListBox + + std::unique_ptr<weld::Container> m_xContentArea; + std::unique_ptr<weld::Menu> m_xPopup; + std::unique_ptr<SvxAcceptChgCtr> m_xAcceptChgCtr; + + void Init(); + + DECL_LINK( FilterHandle, SvxTPFilter*, void ); + DECL_LINK( RefHandle, SvxTPFilter*, void ); + DECL_LINK( RejectHandle, SvxTPView*, void ); + DECL_LINK( AcceptHandle, SvxTPView*, void ); + DECL_LINK( RejectAllHandle, SvxTPView*, void ); + DECL_LINK( AcceptAllHandle, SvxTPView*, void ); + DECL_LINK( ExpandingHandle, const weld::TreeIter&, bool ); + DECL_LINK( SelectHandle, weld::TreeView&, void ); + DECL_LINK( RefInfoHandle, const OUString*, void ); + + DECL_LINK( UpdateSelectionHdl, Timer*, void ); + DECL_LINK( ChgTrackModHdl, ScChangeTrack&, void ); + DECL_LINK( CommandHdl, const CommandEvent&, bool ); + DECL_LINK( ReOpenTimerHdl, Timer*, void ); + + int ColCompareHdl(const weld::TreeIter& rLeft, const weld::TreeIter& rRight) const; + + void RejectFiltered(); + void AcceptFiltered(); + + bool IsValidAction(const ScChangeAction* pScChangeAction); + + OUString* MakeTypeString(ScChangeActionType eType); + + std::unique_ptr<weld::TreeIter> AppendChangeAction( + const ScChangeAction* pScChangeAction, bool bCreateOnDemand, + const weld::TreeIter* pParent = nullptr, bool bDelMaster = false, + bool bDisabled = false); + + std::unique_ptr<weld::TreeIter> AppendFilteredAction( + const ScChangeAction* pScChangeAction,ScChangeActionState eState, + bool bCreateOnDemand, + const weld::TreeIter* pParent = nullptr, bool bDelMaster = false, + bool bDisabled = false); + + std::unique_ptr<weld::TreeIter> InsertChangeActionContent(const ScChangeActionContent* pScChangeAction, + const weld::TreeIter& rParent, sal_uLong nSpecial); + + void GetDependents(const ScChangeAction* pScChangeAction, + ScChangeActionMap& aActionMap, + const weld::TreeIter& rEntry); + + bool InsertContentChildren(ScChangeActionMap* pActionMap, const weld::TreeIter& rParent); + + bool InsertAcceptedORejected(const weld::TreeIter& rParent); + + bool InsertDeletedChildren(const ScChangeAction* pChangeAction, ScChangeActionMap* pActionMap, + const weld::TreeIter& rParent); + + bool InsertChildren(ScChangeActionMap* pActionMap, const weld::TreeIter& rParent); + + void AppendChanges(const ScChangeTrack* pChanges,sal_uLong nStartAction, sal_uLong nEndAction); + + void RemoveEntries(sal_uLong nStartAction,sal_uLong nEndAction); + void UpdateEntries(const ScChangeTrack* pChgTrack, sal_uLong nStartAction,sal_uLong nEndAction); + + void UpdateView(); + void ClearView(); + + bool Expand(const ScChangeTrack* pChanges,const ScChangeAction* pScChangeAction, + const weld::TreeIter& rEntry, bool bFilter = false); + +public: + ScAcceptChgDlg(SfxBindings* pB, SfxChildWindow* pCW, weld::Window* pParent, + ScViewData* ptrViewData); + virtual ~ScAcceptChgDlg() override; + + void ReInit(ScViewData* ptrViewData); + + void Initialize (SfxChildWinInfo* pInfo); + virtual void FillInfo(SfxChildWinInfo&) const override; +}; + +#endif // INCLUDED_SC_SOURCE_UI_INC_ACREDLIN_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/anyrefdg.hxx b/sc/source/ui/inc/anyrefdg.hxx new file mode 100644 index 000000000..699725f71 --- /dev/null +++ b/sc/source/ui/inc/anyrefdg.hxx @@ -0,0 +1,170 @@ +/* -*- 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_SC_SOURCE_UI_INC_ANYREFDG_HXX +#define INCLUDED_SC_SOURCE_UI_INC_ANYREFDG_HXX + +#include <sfx2/basedlgs.hxx> +#include <address.hxx> +#include <formula/funcutl.hxx> +#include <vcl/accel.hxx> +#include "IAnyRefDialog.hxx" +#include <scmod.hxx> + +#include <memory> + +class SfxObjectShell; +class ScDocument; +class ScRangeList; +class ScCompiler; + +class ScFormulaReferenceHelper +{ + IAnyRefDialog* m_pDlg; + ::std::unique_ptr<ScCompiler> m_pRefComp; + formula::RefEdit* m_pRefEdit; // active input field + formula::RefButton* m_pRefBtn; // associated button + weld::Dialog* m_pDialog; + SfxBindings* m_pBindings; + SCTAB m_nRefTab; // used for ShowReference + + OUString m_sOldDialogText; // Original title of the dialog window + + bool m_bEnableColorRef; + bool m_bHighlightRef; + + DECL_LINK( ActivateHdl, weld::Widget&, bool ); + +public: + ScFormulaReferenceHelper(IAnyRefDialog* _pDlg, SfxBindings* _pBindings); + ~ScFormulaReferenceHelper() COVERITY_NOEXCEPT_FALSE; + void dispose(); + + void ShowSimpleReference(const OUString& rStr); + void ShowFormulaReference(const OUString& rStr); + bool ParseWithNames( ScRangeList& rRanges, const OUString& rStr, const ScDocument& rDoc ); + void Init(); + + void ShowReference(const OUString& rStr); + void ReleaseFocus( formula::RefEdit* pEdit ); + void HideReference( bool bDoneRefMode = true ); + void RefInputStart( formula::RefEdit* pEdit, formula::RefButton* pButton ); + void RefInputDone( bool bForced ); + void ToggleCollapsed( formula::RefEdit* pEdit, formula::RefButton* pButton ); + + void SetDialog(weld::Dialog* pDialog) { m_pDialog = pDialog; } + void DoClose( sal_uInt16 nId ); + void SetDispatcherLock( bool bLock ); + static void EnableSpreadsheets( bool bFlag = true ); + static void ViewShellChanged(); + + static void enableInput(bool _bInput); + +public: + static bool CanInputStart( const formula::RefEdit *pEdit ){ return !!pEdit; } + bool CanInputDone(bool bForced) { return m_pRefEdit && (bForced || !m_pRefBtn); } +}; + +class ScRefHandler : public IAnyRefDialog +{ + weld::DialogController* m_pController; + bool m_bInRefMode; + +private: + ScFormulaReferenceHelper + m_aHelper; + SfxBindings* m_pMyBindings; + + OUString m_aDocName; // document on which the dialog was opened + +protected: + void disposeRefHandler(); + bool DoClose( sal_uInt16 nId ); + + void SetDispatcherLock( bool bLock ); + + virtual void RefInputStart( formula::RefEdit* pEdit, formula::RefButton* pButton = nullptr ) override; + virtual void RefInputDone( bool bForced = false ) override; + + bool ParseWithNames( ScRangeList& rRanges, const OUString& rStr, const ScDocument& pDoc ); + +public: + ScRefHandler(SfxDialogController &rController, SfxBindings* pB, bool bBindRef); + virtual ~ScRefHandler() COVERITY_NOEXCEPT_FALSE override; + + virtual void SetReference( const ScRange& rRef, ScDocument& rDoc ) override = 0; + virtual void AddRefEntry() override; + + virtual bool IsRefInputMode() const override; + virtual bool IsTableLocked() const override; + virtual bool IsDocAllowed( SfxObjectShell* pDocSh ) const override; + + virtual void ShowReference(const OUString& rStr) override; + virtual void HideReference( bool bDoneRefMode = true ) override; + + virtual void ToggleCollapsed( formula::RefEdit* pEdit, formula::RefButton* pButton ) override; + virtual void ReleaseFocus( formula::RefEdit* pEdit ) override; + + virtual void ViewShellChanged() override; + void SwitchToDocument(); + + virtual void SetActive() override = 0; + +public: + bool EnterRefMode(); + bool LeaveRefMode(); + static bool CanInputStart( const formula::RefEdit *pEdit ) + { + return ScFormulaReferenceHelper::CanInputStart( pEdit ); + } + bool CanInputDone( bool bForced ) + { + return m_aHelper.CanInputDone( bForced ); + } +}; + +template<class TBase, bool bBindRef = true> +struct ScRefHdlrControllerImpl : public TBase, public ScRefHandler +{ + enum { UNKNOWN_SLOTID = 0U, SLOTID = UNKNOWN_SLOTID }; + + ScRefHdlrControllerImpl(weld::Window* pParent, const OUString& rUIXMLDescription, const OString& rID, const SfxItemSet* pArg, SfxBindings *pB) + : TBase(pParent, rUIXMLDescription, rID, pArg) + , ScRefHandler(*static_cast<TBase*>(this), pB, bBindRef) + { + } + + ScRefHdlrControllerImpl(SfxBindings* pB, SfxChildWindow* pCW, weld::Window* pParent, const OUString& rUIXMLDescription, const OString& rID) + : TBase(pB, pCW, pParent, rUIXMLDescription, rID) + , ScRefHandler(*static_cast<TBase*>(this), pB, bBindRef) + { + } +}; + +struct ScAnyRefDlgController : ScRefHdlrControllerImpl<SfxModelessDialogController> +{ + ScAnyRefDlgController(SfxBindings* rt1, SfxChildWindow* rt2, weld::Window* rt3, const OUString& rt4, const OString& rt5) + : ScRefHdlrControllerImpl<SfxModelessDialogController>(rt1, rt2, rt3, rt4, rt5) + { + } +}; + +#endif // INCLUDED_SC_SOURCE_UI_INC_ANYREFDG_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/areasave.hxx b/sc/source/ui/inc/areasave.hxx new file mode 100644 index 000000000..345331c44 --- /dev/null +++ b/sc/source/ui/inc/areasave.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_SC_SOURCE_UI_INC_AREASAVE_HXX +#define INCLUDED_SC_SOURCE_UI_INC_AREASAVE_HXX + +#include <address.hxx> +#include <tools/solar.h> + +#include <vector> + +class ScDocument; +class ScAreaLink; + +class ScAreaLinkSaver +{ +private: + OUString aFileName; + OUString aFilterName; + OUString aOptions; + OUString aSourceArea; + ScRange aDestArea; + sal_uLong nRefresh; + +public: + ScAreaLinkSaver( const ScAreaLink& rSource ); + + bool IsEqual( const ScAreaLink& rCompare ) const; + bool IsEqualSource( const ScAreaLink& rCompare ) const; + + void WriteToLink( ScAreaLink& rLink ) const; + void InsertNewLink( ScDocument* pDoc ); +}; + +class ScAreaLinkSaveCollection +{ + typedef ::std::vector<ScAreaLinkSaver> DataType; + DataType maData; +public: + ScAreaLinkSaveCollection(); + ~ScAreaLinkSaveCollection(); + + bool IsEqual( const ScDocument* pDoc ) const; + void Restore( ScDocument* pDoc ); + + // returns NULL if empty + static std::unique_ptr<ScAreaLinkSaveCollection> CreateFromDoc( const ScDocument* pDoc ); + + ScAreaLinkSaver& operator[](size_t nIndex); + const ScAreaLinkSaver& operator[](size_t nIndex) const; + size_t size() const; + void push_back(const ScAreaLinkSaver&); +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/areasdlg.hxx b/sc/source/ui/inc/areasdlg.hxx new file mode 100644 index 000000000..33d8f8997 --- /dev/null +++ b/sc/source/ui/inc/areasdlg.hxx @@ -0,0 +1,91 @@ +/* + * 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_SC_SOURCE_UI_INC_AREASDLG_HXX +#define INCLUDED_SC_SOURCE_UI_INC_AREASDLG_HXX + +#include <address.hxx> + +#include "anyrefdg.hxx" + +class ScDocument; +class ScViewData; +class SfxStringItem; + +class ScPrintAreasDlg : public ScAnyRefDlgController +{ +public: + ScPrintAreasDlg(SfxBindings* pB, SfxChildWindow* pCW, weld::Window* pParent); + virtual ~ScPrintAreasDlg() override; + + virtual void SetReference( const ScRange& rRef, ScDocument& rDoc ) override; + virtual void AddRefEntry() override; + + virtual bool IsTableLocked() const override; + + virtual void SetActive() override; + virtual void Deactivate() override; + virtual void Close() override; + +private: + bool bDlgLostFocus; + ScDocument* pDoc; + ScViewData* pViewData; + SCTAB nCurTab; + + formula::RefEdit* m_pRefInputEdit; + + std::unique_ptr<weld::ComboBox> m_xLbPrintArea; + std::unique_ptr<formula::RefEdit> m_xEdPrintArea; + std::unique_ptr<formula::RefButton> m_xRbPrintArea; + + std::unique_ptr<weld::ComboBox> m_xLbRepeatRow; + std::unique_ptr<formula::RefEdit> m_xEdRepeatRow; + std::unique_ptr<formula::RefButton> m_xRbRepeatRow; + + std::unique_ptr<weld::ComboBox> m_xLbRepeatCol; + std::unique_ptr<formula::RefEdit> m_xEdRepeatCol; + std::unique_ptr<formula::RefButton> m_xRbRepeatCol; + + std::unique_ptr<weld::Button> m_xBtnOk; + std::unique_ptr<weld::Button> m_xBtnCancel; + + std::unique_ptr<weld::Frame> m_xPrintFrame; + std::unique_ptr<weld::Frame> m_xRowFrame; + std::unique_ptr<weld::Frame> m_xColFrame; + + std::unique_ptr<weld::Label> m_xPrintFrameFT; + std::unique_ptr<weld::Label> m_xRowFrameFT; + std::unique_ptr<weld::Label> m_xColFrameFT; + + void Impl_Reset(); + bool Impl_CheckRefStrings(); + void Impl_FillLists(); + bool Impl_GetItem( const formula::RefEdit* pEd, SfxStringItem& rItem ); + + // Handler: + DECL_LINK( Impl_SelectHdl, weld::ComboBox&, void ); + DECL_LINK( Impl_ModifyHdl, formula::RefEdit&, void ); + DECL_LINK( Impl_BtnHdl, weld::Button&, void ); + DECL_LINK( Impl_GetEditFocusHdl, formula::RefEdit&, void ); + DECL_LINK( Impl_GetFocusHdl, weld::Widget&, void ); +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/asciiopt.hxx b/sc/source/ui/inc/asciiopt.hxx new file mode 100644 index 000000000..3c73ee253 --- /dev/null +++ b/sc/source/ui/inc/asciiopt.hxx @@ -0,0 +1,108 @@ +/* -*- 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_SC_SOURCE_UI_INC_ASCIIOPT_HXX +#define INCLUDED_SC_SOURCE_UI_INC_ASCIIOPT_HXX + +#include <rtl/ustring.hxx> +#include <i18nlangtag/lang.h> + +#include "csvcontrol.hxx" + +class ScAsciiOptions +{ +private: + bool bFixedLen; + OUString aFieldSeps; + bool bMergeFieldSeps; + bool bRemoveSpace; + bool bQuotedFieldAsText; + bool bDetectSpecialNumber; + bool bSkipEmptyCells; + bool bSaveAsShown; + bool bSaveFormulas; + sal_Unicode cTextSep; + rtl_TextEncoding eCharSet; + LanguageType eLang; + bool bCharSetSystem; + long nStartRow; + std::vector<sal_Int32> mvColStart; + std::vector<sal_uInt8> mvColFormat; + +public: + ScAsciiOptions(); + + static const sal_Unicode cDefaultTextSep = '"'; + + void ReadFromString( const OUString& rString ); + OUString WriteToString() const; + + rtl_TextEncoding GetCharSet() const { return eCharSet; } + const OUString& GetFieldSeps() const { return aFieldSeps; } + bool IsMergeSeps() const { return bMergeFieldSeps; } + bool IsRemoveSpace() const { return bRemoveSpace; } + bool IsQuotedAsText() const { return bQuotedFieldAsText; } + bool IsDetectSpecialNumber() const { return bDetectSpecialNumber; } + bool IsSkipEmptyCells() const { return bSkipEmptyCells; } + sal_Unicode GetTextSep() const { return cTextSep; } + bool IsFixedLen() const { return bFixedLen; } + sal_uInt16 GetInfoCount() const { return mvColStart.size(); } + const sal_Int32* GetColStart() const { return mvColStart.data(); } + const sal_uInt8* GetColFormat() const { return mvColFormat.data(); } + long GetStartRow() const { return nStartRow; } + LanguageType GetLanguage() const { return eLang; } + + void SetCharSet( rtl_TextEncoding eNew ) { eCharSet = eNew; } + void SetCharSetSystem( bool bSet ) { bCharSetSystem = bSet; } + void SetFixedLen( bool bSet ) { bFixedLen = bSet; } + void SetFieldSeps( const OUString& rStr ) { aFieldSeps = rStr; } + void SetMergeSeps( bool bSet ) { bMergeFieldSeps = bSet; } + void SetRemoveSpace( bool bSet ) { bRemoveSpace = bSet; } + void SetQuotedAsText(bool bSet) { bQuotedFieldAsText = bSet; } + void SetDetectSpecialNumber(bool bSet) { bDetectSpecialNumber = bSet; } + void SetSkipEmptyCells(bool bSet) { bSkipEmptyCells = bSet; } + void SetTextSep( sal_Unicode c ) { cTextSep = c; } + void SetStartRow( long nRow) { nStartRow= nRow; } + void SetLanguage(LanguageType e) { eLang = e; } + + void SetColumnInfo( const ScCsvExpDataVec& rDataVec ); + + /** From the import field separators obtain the one most likely to be used + for export, if multiple separators weighted comma, tab, semicolon, + space and other. + + @param bDecodeNumbers + If TRUE, the separators are encoded as numbers and need to be + decoded before characters can be extracted, for example "59/44" + to ";,". + If FALSE, the string is taken as is and each character is + expected to be one separator. + */ + static sal_Unicode GetWeightedFieldSep( const OUString & rFieldSeps, bool bDecodeNumbers ); +}; + +/// How ScImportAsciiDlg is called +enum ScImportAsciiCall { + SC_IMPORTFILE, // with File > Open: Text - CSV + SC_PASTETEXT, // with Paste > Unformatted Text + SC_TEXTTOCOLUMNS }; // with Data > Text to Columns + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/attrdlg.hxx b/sc/source/ui/inc/attrdlg.hxx new file mode 100644 index 000000000..c8ad33d97 --- /dev/null +++ b/sc/source/ui/inc/attrdlg.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_SC_SOURCE_UI_INC_ATTRDLG_HXX +#define INCLUDED_SC_SOURCE_UI_INC_ATTRDLG_HXX + +#include <sfx2/tabdlg.hxx> + +namespace weld { class Window; } +class SfxItemSet; + +class ScAttrDlg : public SfxTabDialogController +{ +public: + ScAttrDlg(weld::Window* pParent, const SfxItemSet* pCellAttrs); + virtual ~ScAttrDlg() override; +protected: + virtual void PageCreated(const OString& rPageId, SfxTabPage& rTabPage) override; +}; + +#endif // INCLUDED_SC_SOURCE_UI_INC_ATTRDLG_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/auditsh.hxx b/sc/source/ui/inc/auditsh.hxx new file mode 100644 index 000000000..70c48efb5 --- /dev/null +++ b/sc/source/ui/inc/auditsh.hxx @@ -0,0 +1,52 @@ +/* -*- 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_SC_SOURCE_UI_INC_AUDITSH_HXX +#define INCLUDED_SC_SOURCE_UI_INC_AUDITSH_HXX + +#include <sfx2/shell.hxx> + +#include <shellids.hxx> + +class ScViewData; + +class ScAuditingShell : public SfxShell +{ +private: + ScViewData* pViewData; + sal_uInt16 nFunction; + +public: + SFX_DECL_INTERFACE(SCID_AUDITING_SHELL) + +private: + /// SfxInterface initializer. + static void InitInterface_Impl(); + +public: + ScAuditingShell(ScViewData* pData); + virtual ~ScAuditingShell() override; + + void Execute(const SfxRequest& rReq); + void GetState(SfxItemSet& rSet); +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/autofmt.hxx b/sc/source/ui/inc/autofmt.hxx new file mode 100644 index 000000000..682aa019f --- /dev/null +++ b/sc/source/ui/inc/autofmt.hxx @@ -0,0 +1,94 @@ +/* -*- 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_SC_SOURCE_UI_INC_AUTOFMT_HXX +#define INCLUDED_SC_SOURCE_UI_INC_AUTOFMT_HXX + +#include <svx/framelinkarray.hxx> +#include <scdllapi.h> +#include <vcl/customweld.hxx> + +namespace com::sun::star::i18n { class XBreakIterator; } + +class ScAutoFormatData; +class SvxBoxItem; +class SvxLineItem; +class SvNumberFormatter; +class VirtualDevice; +class ScViewData; + +class SC_DLLPUBLIC ScAutoFmtPreview : public weld::CustomWidgetController +{ +public: + ScAutoFmtPreview(); + void DetectRTL(const ScViewData *pViewData); + virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override; + virtual ~ScAutoFmtPreview() override; + + void NotifyChange( ScAutoFormatData* pNewData ); + +protected: + virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) override; + virtual void Resize() override; + +private: + ScAutoFormatData* pCurData; + ScopedVclPtrInstance<VirtualDevice> aVD; + css::uno::Reference<css::i18n::XBreakIterator> xBreakIter; + bool bFitWidth; + svx::frame::Array maArray; /// Implementation to draw the frame borders. + bool mbRTL; + Size aPrvSize; + long mnLabelColWidth; + long mnDataColWidth1; + long mnDataColWidth2; + long mnRowHeight; + const OUString aStrJan; + const OUString aStrFeb; + const OUString aStrMar; + const OUString aStrNorth; + const OUString aStrMid; + const OUString aStrSouth; + const OUString aStrSum; + std::unique_ptr<SvNumberFormatter> pNumFmt; + + SAL_DLLPRIVATE void Init(); + SAL_DLLPRIVATE void DoPaint(vcl::RenderContext& rRenderContext); + SAL_DLLPRIVATE void CalcCellArray(bool bFitWidth); + SAL_DLLPRIVATE void CalcLineMap(); + SAL_DLLPRIVATE void PaintCells(vcl::RenderContext& rRenderContext); + +/* Usage of type size_t instead of SCCOL/SCROW is correct here - used in + conjunction with class svx::frame::Array (svx/framelinkarray.hxx), which + expects size_t coordinates. */ + + SAL_DLLPRIVATE sal_uInt16 GetFormatIndex( size_t nCol, size_t nRow ) const; + SAL_DLLPRIVATE const SvxBoxItem& GetBoxItem( size_t nCol, size_t nRow ) const; + SAL_DLLPRIVATE const SvxLineItem& GetDiagItem( size_t nCol, size_t nRow, bool bTLBR ) const; + + SAL_DLLPRIVATE void DrawString(vcl::RenderContext& rRenderContext, size_t nCol, size_t nRow); + SAL_DLLPRIVATE void DrawBackground(vcl::RenderContext& rRenderContext); + + SAL_DLLPRIVATE void MakeFonts(vcl::RenderContext const& rRenderContext, sal_uInt16 nIndex, + vcl::Font& rFont, vcl::Font& rCJKFont, vcl::Font& rCTLFont); +}; + +#endif // INCLUDED_SC_SOURCE_UI_INC_AUTOFMT_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/autostyl.hxx b/sc/source/ui/inc/autostyl.hxx new file mode 100644 index 000000000..83078c378 --- /dev/null +++ b/sc/source/ui/inc/autostyl.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_SC_SOURCE_UI_INC_AUTOSTYL_HXX +#define INCLUDED_SC_SOURCE_UI_INC_AUTOSTYL_HXX + +#include <vector> +#include <rtl/ustring.hxx> +#include <tools/solar.h> +#include <vcl/timer.hxx> +#include <vcl/idle.hxx> + +class ScDocShell; +class ScRange; + +struct ScAutoStyleData +{ + sal_uLong nTimeout; + ScRange aRange; + OUString aStyle; + + ScAutoStyleData( sal_uLong nT, const ScRange& rR, const OUString& rT ) : + nTimeout(nT), aRange(rR), aStyle(rT) {} +}; +struct ScAutoStyleInitData +{ + ScRange aRange; + OUString aStyle1; + sal_uLong nTimeout; + OUString aStyle2; + + ScAutoStyleInitData( const ScRange& rR, const OUString& rSt1, sal_uLong nT, const OUString& rSt2 ) : + aRange(rR), aStyle1(rSt1), nTimeout(nT), aStyle2(rSt2) {} +}; + + +class ScAutoStyleList +{ +private: + + ScDocShell* pDocSh; + Timer aTimer; + Idle aInitIdle; + sal_uLong nTimerStart; + std::vector<ScAutoStyleData> aEntries; + std::vector<ScAutoStyleInitData> aInitials; + + void ExecuteEntries(); + void AdjustEntries(sal_uLong nDiff); + void StartTimer(sal_uLong nNow); + DECL_LINK( TimerHdl, Timer*, void ); + DECL_LINK( InitHdl, Timer*, void ); + +public: + ScAutoStyleList(ScDocShell* pShell); + ~ScAutoStyleList(); + + void AddInitial( const ScRange& rRange, const OUString& rStyle1, + sal_uLong nTimeout, const OUString& rStyle2 ); + void AddEntry( sal_uLong nTimeout, const ScRange& rRange, const OUString& rStyle ); + + void ExecuteAllNow(); +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/cbnumberformat.hxx b/sc/source/ui/inc/cbnumberformat.hxx new file mode 100644 index 000000000..f558811fe --- /dev/null +++ b/sc/source/ui/inc/cbnumberformat.hxx @@ -0,0 +1,45 @@ +/* -*- 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_SC_SOURCE_UI_INC_CBNUMBERFORMAT_HXX +#define INCLUDED_SC_SOURCE_UI_INC_CBNUMBERFORMAT_HXX + +#include <vcl/InterimItemWindow.hxx> + +class ScNumberFormat final : public InterimItemWindow +{ +public: + explicit ScNumberFormat(vcl::Window* pParent); + virtual void dispose() override; + virtual ~ScNumberFormat() override; + + virtual void GetFocus() override; + + void set_active(int nPos) { m_xWidget->set_active(nPos); } + +private: + std::unique_ptr<weld::ComboBox> m_xWidget; + + DECL_STATIC_LINK(ScNumberFormat, NumFormatSelectHdl, weld::ComboBox&, void); + DECL_LINK(KeyInputHdl, const KeyEvent&, bool); +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/cbutton.hxx b/sc/source/ui/inc/cbutton.hxx new file mode 100644 index 000000000..9deae846f --- /dev/null +++ b/sc/source/ui/inc/cbutton.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_SC_SOURCE_UI_INC_CBUTTON_HXX +#define INCLUDED_SC_SOURCE_UI_INC_CBUTTON_HXX + +#include <tools/gen.hxx> +#include <vcl/vclptr.hxx> + +class OutputDevice; + +class ScDDComboBoxButton final +{ +public: + ScDDComboBoxButton( OutputDevice* pOutputDevice ); + ~ScDDComboBoxButton(); + + void SetOutputDevice( OutputDevice* pOutputDevice ); + + void Draw( const Point& rAt, + const Size& rSize ); + void Draw() + { Draw( aBtnPos, aBtnSize ); } + + void SetOptSizePixel(); + + void SetPosPixel( const Point& rNewPos ) { aBtnPos = rNewPos; } + const Point& GetPosPixel() const { return aBtnPos; } + + void SetSizePixel( const Size& rNewSize ) { aBtnSize = rNewSize; } + const Size& GetSizePixel() const { return aBtnSize; } + +private: + void ImpDrawArrow( const tools::Rectangle& rRect ); + + VclPtr<OutputDevice> pOut; + Point aBtnPos; + Size aBtnSize; +}; + +#endif // INCLUDED_SC_SOURCE_UI_INC_CBUTTON_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/cellmergeoption.hxx b/sc/source/ui/inc/cellmergeoption.hxx new file mode 100644 index 000000000..ff4a7cbeb --- /dev/null +++ b/sc/source/ui/inc/cellmergeoption.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_SC_SOURCE_UI_INC_CELLMERGEOPTION_HXX +#define INCLUDED_SC_SOURCE_UI_INC_CELLMERGEOPTION_HXX + +#include <address.hxx> + +#include <set> + +struct ScCellMergeOption +{ + ::std::set<SCTAB> maTabs; + SCCOL mnStartCol; + SCROW mnStartRow; + SCCOL mnEndCol; + SCROW mnEndRow; + bool mbCenter; + + explicit ScCellMergeOption(const ScRange& rRange); + explicit ScCellMergeOption(SCCOL nStartCol, SCROW nStartRow, + SCCOL nEndCol, SCROW nEndRow, + bool bCenter = false); + + ScRange getSingleRange(SCTAB nTab) const; + ScRange getFirstSingleRange() const; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/cellsh.hxx b/sc/source/ui/inc/cellsh.hxx new file mode 100644 index 000000000..07702932d --- /dev/null +++ b/sc/source/ui/inc/cellsh.hxx @@ -0,0 +1,114 @@ +/* -*- 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_SC_SOURCE_UI_INC_CELLSH_HXX +#define INCLUDED_SC_SOURCE_UI_INC_CELLSH_HXX + +#include <sfx2/shell.hxx> +#include <shellids.hxx> +#include <unotools/caserotate.hxx> +#include <tools/link.hxx> +#include <memory> +#include "formatsh.hxx" +#include <rtl/ref.hxx> +#include <sot/formats.hxx> +#include <vcl/vclptr.hxx> +#include <tools/solar.h> + +class SvxClipboardFormatItem; +class TransferableDataHelper; +class TransferableClipboardListener; +class AbstractScLinkedAreaDlg; + +struct CellShell_Impl +{ + rtl::Reference<TransferableClipboardListener> + m_xClipEvtLstnr; + VclPtr<AbstractScLinkedAreaDlg> m_pLinkedDlg; + SfxRequest* m_pRequest; + + CellShell_Impl(); + ~CellShell_Impl(); +}; + +class ScCellShell: public ScFormatShell +{ +private: + std::unique_ptr<CellShell_Impl> pImpl; + bool bPastePossible; + + void GetPossibleClipboardFormats( SvxClipboardFormatItem& rFormats ); + bool HasClipboardFormat( SotClipboardFormatId nFormatId ); + void ExecuteExternalSource( + const OUString& _rFile, const OUString& _rFilter, const OUString& _rOptions, + const OUString& _rSource, sal_uLong _nRefresh, SfxRequest& _rRequest ); + + void ExecuteDataPilotDialog(); + void ExecuteXMLSourceDialog(); + void ExecuteSubtotals(SfxRequest& rReq); + + void ExecuteFillSingleEdit(); + + DECL_LINK( ClipboardChanged, TransferableDataHelper*, void ); + + RotateTransliteration m_aRotateCase; + + VclPtr<vcl::Window> pFrameWin; + +public: + SFX_DECL_INTERFACE(SCID_CELL_SHELL) + +private: + /// SfxInterface initializer. + static void InitInterface_Impl(); + +public: + ScCellShell( ScViewData* pData, const VclPtr<vcl::Window>& pFrameWin ); + virtual ~ScCellShell() override; + + void Execute(SfxRequest &); + void GetState(SfxItemSet &); + + void ExecuteEdit( SfxRequest& rReq ); + void ExecuteTrans( SfxRequest& rReq ); + void ExecuteRotateTrans( const SfxRequest& rReq ); + + void GetBlockState( SfxItemSet& rSet ); + void GetCellState( SfxItemSet& rSet ); + + void ExecuteDB( SfxRequest& rReq ); + void GetDBState( SfxItemSet& rSet ); + + void GetClipState( SfxItemSet& rSet ); + void GetHLinkState( SfxItemSet& rSet ); + + void ExecuteCursor( SfxRequest& rReq ); + void ExecuteCursorSel( SfxRequest& rReq ); + void ExecutePage( SfxRequest& rReq ); + void ExecutePageSel( SfxRequest& rReq ); + void ExecuteMove( SfxRequest& rReq ); + + const VclPtr<vcl::Window>& GetFrameWin() const; + + static void GetStateCursor( SfxItemSet& rSet ); +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/chartsh.hxx b/sc/source/ui/inc/chartsh.hxx new file mode 100644 index 000000000..caa5a89f1 --- /dev/null +++ b/sc/source/ui/inc/chartsh.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_SC_SOURCE_UI_INC_CHARTSH_HXX +#define INCLUDED_SC_SOURCE_UI_INC_CHARTSH_HXX + +#include <sfx2/shell.hxx> +#include <shellids.hxx> + +class ScViewData; + +#include "drawsh.hxx" + +class ScChartShell: public ScDrawShell +{ +public: + SFX_DECL_INTERFACE(SCID_CHART_SHELL) + +private: + /// SfxInterface initializer. + static void InitInterface_Impl(); + +public: + ScChartShell(ScViewData* pData); + virtual ~ScChartShell() override; + + void ExecuteExportAsGraphic(SfxRequest& rReq); + void GetExportAsGraphicState(SfxItemSet &rSet); + +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/checklistmenu.hxx b/sc/source/ui/inc/checklistmenu.hxx new file mode 100644 index 000000000..5e988e31e --- /dev/null +++ b/sc/source/ui/inc/checklistmenu.hxx @@ -0,0 +1,447 @@ +/* -*- 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_SC_SOURCE_UI_INC_CHECKLISTMENU_HXX +#define INCLUDED_SC_SOURCE_UI_INC_CHECKLISTMENU_HXX + +#include <vcl/popupmenuwindow.hxx> +#include <vcl/button.hxx> +#include <vcl/edit.hxx> +#include <vcl/timer.hxx> +#include <vcl/svlbitm.hxx> + +#include <memory> +#include <unordered_set> +#include <unordered_map> +#include <map> +#include <set> + +namespace com::sun::star { + namespace accessibility { + class XAccessible; + } +} + +class ScDocument; +class ScAccessibleFilterMenu; + +class ScMenuFloatingWindow : public PopupMenuFloatingWindow +{ +public: + static constexpr size_t MENU_NOT_SELECTED = 999; + + /** + * Action to perform when an event takes place. Create a sub-class of + * this to implement the desired action. + */ + class Action + { + public: + virtual ~Action() {} + virtual void execute() = 0; + }; + + explicit ScMenuFloatingWindow(vcl::Window* pParent, ScDocument* pDoc, sal_uInt16 nMenuStackLevel = 0); + virtual ~ScMenuFloatingWindow() override; + void dispose() override; + + virtual void PopupModeEnd() override; + virtual void MouseMove(const MouseEvent& rMEvt) override; + virtual void MouseButtonDown(const MouseEvent& rMEvt) override; + virtual void MouseButtonUp(const MouseEvent& rMEvt) override; + virtual void KeyInput(const KeyEvent& rKEvt) override; + virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) override; + virtual css::uno::Reference<css::accessibility::XAccessible> CreateAccessible() override; + + void addMenuItem(const OUString& rText, Action* pAction); + void addSeparator(); + + ScMenuFloatingWindow* addSubMenuItem(const OUString& rText, bool bEnabled); + void setSelectedMenuItem(size_t nPos, bool bSubMenuTimer, bool bEnsureSubMenu); + void selectMenuItem(size_t nPos, bool bSelected, bool bSubMenuTimer); + void clearSelectedMenuItem(); + ScMenuFloatingWindow* getSubMenuWindow(size_t nPos) const; + bool isMenuItemSelected(size_t nPos) const; + size_t getSelectedMenuItem() const { return mnSelectedMenu;} + + void setName(const OUString& rName); + const OUString& getName() const { return maName;} + + void executeMenuItem(size_t nPos); + void getMenuItemPosSize(size_t nPos, Point& rPos, Size& rSize) const; + ScMenuFloatingWindow* getParentMenuWindow() const { return mpParentMenu;} + +protected: + virtual void handlePopupEnd(); + + Size getMenuSize() const; + void drawMenuItem(vcl::RenderContext& rRenderContext, size_t nPos); + void drawSeparator(vcl::RenderContext& rRenderContext, size_t nPos); + void drawAllMenuItems(vcl::RenderContext& rRenderContext); + const vcl::Font& getLabelFont() const + { + return maLabelFont; + } + + void queueLaunchSubMenu(size_t nPos, ScMenuFloatingWindow* pMenu); + void queueCloseSubMenu(); + void launchSubMenu(bool bSetMenuPos); + void endSubMenu(ScMenuFloatingWindow* pSubMenu); + + void fillMenuItemsToAccessible(ScAccessibleFilterMenu* pAccMenu) const; + + ScDocument* getDoc() { return mpDoc;} + +protected: + css::uno::Reference<css::accessibility::XAccessible> mxAccessible; + +private: + struct SubMenuItemData; + void handleMenuTimeout(const SubMenuItemData* pTimer); + + void resizeToFitMenuItems(); + void highlightMenuItem(vcl::RenderContext& rRenderContext, size_t nPos, bool bSelected); + + size_t getEnclosingMenuItem(const Point& rPos) const; + size_t getSubMenuPos(const ScMenuFloatingWindow* pSubMenu); + + /** + * Fire a menu highlight event since the accessibility framework needs + * this to track focus on menu items. + */ + void fireMenuHighlightedEvent(); + + /** + * Make sure that the specified submenu is permanently up, the submenu + * close timer is not active, and the correct menu item associated with + * the submenu is highlighted. + */ + void setSubMenuFocused(const ScMenuFloatingWindow* pSubMenu); + + /** + * When a menu item of an invisible submenu is selected, we need to make + * sure that all its parent menu(s) are visible, with the right menu item + * highlighted in each of the parents. Calling this method ensures it. + */ + void ensureSubMenuVisible(ScMenuFloatingWindow* pSubMenu); + + /** + * Dismiss any visible child submenus when a menu item of a parent menu is + * selected. + */ + void ensureSubMenuNotVisible(); + + /** + * Dismiss all visible popup menus and set focus back to the application + * window. This method is called e.g. when a menu action is fired. + */ + void terminateAllPopupMenus(); + +private: + + struct MenuItemData + { + OUString maText; + bool mbEnabled:1; + bool mbSeparator:1; + + std::shared_ptr<Action> mpAction; + VclPtr<ScMenuFloatingWindow> mpSubMenuWin; + + MenuItemData(); + }; + + std::vector<MenuItemData> maMenuItems; + + struct SubMenuItemData + { + Timer maTimer; + VclPtr<ScMenuFloatingWindow> mpSubMenu; + size_t mnMenuPos; + + DECL_LINK( TimeoutHdl, Timer*, void ); + + SubMenuItemData(ScMenuFloatingWindow* pParent); + void reset(); + + private: + VclPtr<ScMenuFloatingWindow> mpParent; + }; + SubMenuItemData maOpenTimer; + SubMenuItemData maCloseTimer; + + vcl::Font maLabelFont; + + // Name of this menu window, taken from the menu item of the parent window + // that launches it (if this is a sub menu). If this is a top-level menu + // window, then this name can be anything. + OUString maName; + + size_t mnSelectedMenu; + size_t mnClickedMenu; + + ScDocument* mpDoc; + + VclPtr<ScMenuFloatingWindow> mpParentMenu; +}; + +class ScCheckListMenuWindow; + +template <class T> struct VclPtr_hash; +template <> struct VclPtr_hash< VclPtr<vcl::Window> > +{ + size_t operator()( const VclPtr<vcl::Window>& r ) const + { + return reinterpret_cast<size_t>(r.get()); + } +}; + +class ScTabStops +{ +private: + typedef std::unordered_map< VclPtr<vcl::Window>, size_t, VclPtr_hash<VclPtr<vcl::Window>> > ControlToPosMap; + VclPtr<ScCheckListMenuWindow> mpMenuWindow; + ControlToPosMap maControlToPos; + std::vector<VclPtr<vcl::Window>> maControls; + size_t mnCurTabStop; +public: + ScTabStops( ScCheckListMenuWindow* mpMenuWin ); + ~ScTabStops(); + void AddTabStop( vcl::Window* pWin ); + void SetTabStop( vcl::Window* pWin ); + void CycleFocus( bool bReverse = false ); + void clear(); +}; + +struct ScCheckListMember; + +class ScCheckListBox : public SvTreeListBox +{ + std::unique_ptr<SvLBoxButtonData> mpCheckButton; + ScTabStops* mpTabStops; + bool mbSeenMouseButtonDown; + void CountCheckedEntries( SvTreeListEntry* pParent, sal_uLong& nCount ) const; + void CheckAllChildren( SvTreeListEntry* pEntry, bool bCheck ); + + public: + + ScCheckListBox( vcl::Window* pParent ); + virtual ~ScCheckListBox() override { disposeOnce(); } + virtual void dispose() override { mpCheckButton.reset(); SvTreeListBox::dispose(); } + void Init(); + void CheckEntry( const OUString& sName, SvTreeListEntry* pParent, bool bCheck ); + void CheckEntry( SvTreeListEntry* pEntry, bool bCheck ); + SvTreeListEntry* ShowCheckEntry( const OUString& sName, ScCheckListMember& rMember, bool bShow = true, bool bCheck = true ); + void GetRecursiveChecked( SvTreeListEntry* pEntry, std::unordered_set<OUString>& vOut, OUString& rLabel ); + std::unordered_set<OUString> GetAllChecked(); + bool IsChecked( const OUString& sName, SvTreeListEntry* pParent ); + SvTreeListEntry* FindEntry( SvTreeListEntry* pParent, const OUString& sNode ); + sal_uInt16 GetCheckedEntryCount() const; + virtual void KeyInput( const KeyEvent& rKEvt ) override; + virtual void MouseButtonDown(const MouseEvent& rMEvt) override; + virtual void MouseButtonUp(const MouseEvent& rMEvt) override; + void SetTabStopsContainer( ScTabStops* pTabStops ) { mpTabStops = pTabStops; } +}; + +class ScSearchEdit : public Edit +{ +private: + ScTabStops* mpTabStops; +public: + ScSearchEdit(Window* pParent) + : Edit(pParent) + , mpTabStops(nullptr) + { + set_id("search_edit"); + } + + virtual void MouseButtonDown( const MouseEvent& rMEvt ) override; + void SetTabStopsContainer( ScTabStops* pTabStops ) { mpTabStops = pTabStops; } +}; + +struct ScCheckListMember +{ + enum DatePartType + { + YEAR, + MONTH, + DAY, + }; + + OUString maName; // node name + OUString maRealName; + bool mbVisible; + bool mbDate; + bool mbLeaf; + DatePartType meDatePartType; + // To store Year and Month if the member if DAY type + std::vector<OUString> maDateParts; + ScCheckListMember(); + SvTreeListEntry* mpParent; +}; + +/** + * This class implements a popup window for field button, for quick access + * of hide-item list, and possibly more stuff related to field options. + */ +class ScCheckListMenuWindow : public ScMenuFloatingWindow +{ +public: + struct ResultEntry + { + OUString aName; + bool bValid; + bool bDate; + + bool operator<(const ResultEntry& rhs) const + { + return aName < rhs.aName; + } + + bool operator == (const ResultEntry& rhs) const + { + return aName == rhs.aName && + bValid == rhs.bValid && + bDate == rhs.bDate; + } + }; + typedef std::set<ResultEntry> ResultType; + + /** + * Extended data that the client code may need to store. Create a + * sub-class of this and store data there. + */ + struct ExtendedData { + + virtual ~ExtendedData() {} + + }; + + /** + * Configuration options for this popup window. + */ + struct Config + { + bool mbAllowEmptySet; + bool mbRTL; + Config(); + }; + + explicit ScCheckListMenuWindow(vcl::Window* pParent, ScDocument* pDoc, int nWidth = -1); + virtual ~ScCheckListMenuWindow() override; + virtual void dispose() override; + + virtual void MouseMove(const MouseEvent& rMEvt) override; + virtual bool EventNotify(NotifyEvent& rNEvt) override; + virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) override; + virtual css::uno::Reference< css::accessibility::XAccessible > CreateAccessible() override; + + void setMemberSize(size_t n); + void setHasDates(bool bHasDates); + void addDateMember(const OUString& rName, double nVal, bool bVisible); + void addMember(const OUString& rName, bool bVisible); + size_t initMembers(); + void setConfig(const Config& rConfig); + + bool isAllSelected() const; + void getResult(ResultType& rResult); + void launch(const tools::Rectangle& rRect); + void close(bool bOK); + + /** + * Set auxiliary data that the client code might need. Note that this + * popup window class manages its life time; no explicit deletion of the + * instance is needed in the client code. + */ + void setExtendedData(std::unique_ptr<ExtendedData> p); + + /** + * Get the store auxiliary data, or NULL if no such data is stored. + */ + ExtendedData* getExtendedData(); + + void setOKAction(Action* p); + void setPopupEndAction(Action* p); + +protected: + virtual void handlePopupEnd() override; + +private: + + class CancelButton : public ::CancelButton + { + public: + CancelButton(ScCheckListMenuWindow* pParent); + virtual ~CancelButton() override; + virtual void dispose() override; + + virtual void Click() override; + + private: + VclPtr<ScCheckListMenuWindow> mpParent; + }; + + enum SectionType { + WHOLE, // entire window + LISTBOX_AREA_OUTER, // box enclosing the check box items. + LISTBOX_AREA_INNER, // box enclosing the check box items. + SINGLE_BTN_AREA, // box enclosing the single-action buttons. + CHECK_TOGGLE_ALL, // check box for toggling all items. + BTN_SINGLE_SELECT, + BTN_SINGLE_UNSELECT, + BTN_OK, // OK button + BTN_CANCEL, // Cancel button + EDIT_SEARCH, // Search box + }; + void getSectionPosSize(Point& rPos, Size& rSize, SectionType eType) const; + + /** + * Calculate the appropriate window size, the position and size of each + * control based on the menu items. + */ + void packWindow(); + void setAllMemberState(bool bSet); + void selectCurrentMemberOnly(bool bSet); + void updateMemberParents( const SvTreeListEntry* pLeaf, size_t nIdx ); + + DECL_LINK( ButtonHdl, Button*, void ); + DECL_LINK( TriStateHdl, Button*, void ); + DECL_LINK( CheckHdl, SvTreeListBox*, void ); + DECL_LINK( EdModifyHdl, Edit&, void ); + +private: + VclPtr<ScSearchEdit> maEdSearch; + VclPtr<ScCheckListBox> maChecks; + + VclPtr<CheckBox> maChkToggleAll; + VclPtr<ImageButton> maBtnSelectSingle; + VclPtr<ImageButton> maBtnUnselectSingle; + + VclPtr<OKButton> maBtnOk; + VclPtr<CancelButton> maBtnCancel; + + std::vector<ScCheckListMember> maMembers; + // For Dates + std::map<OUString, size_t> maYearMonthMap; + + std::unique_ptr<ExtendedData> mpExtendedData; + std::unique_ptr<Action> mpOKAction; + std::unique_ptr<Action> mpPopupEndAction; + + Config maConfig; + Size maWndSize; /// whole window size. + Size maMenuSize; /// size of all menu items combined. + TriState mePrevToggleAllState; + ScTabStops maTabStops; + bool mbHasDates; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/client.hxx b/sc/source/ui/inc/client.hxx new file mode 100644 index 000000000..38c02103e --- /dev/null +++ b/sc/source/ui/inc/client.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_SC_SOURCE_UI_INC_CLIENT_HXX +#define INCLUDED_SC_SOURCE_UI_INC_CLIENT_HXX + +#include <sfx2/ipclient.hxx> + +class ScTabViewShell; +class SdrOle2Obj; +class SdrModel; + +class ScClient : public SfxInPlaceClient +{ +private: + SdrModel* pModel; + + virtual void ObjectAreaChanged() override; + virtual void RequestNewObjectArea( tools::Rectangle& ) override; + virtual void ViewChanged() override; + +public: + ScClient( ScTabViewShell* pViewShell, vcl::Window* pDraw, SdrModel* pSdrModel, const SdrOle2Obj* pObj ); + virtual ~ScClient() override; + + SdrOle2Obj* GetDrawObj(); +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/cliputil.hxx b/sc/source/ui/inc/cliputil.hxx new file mode 100644 index 000000000..b938dfe44 --- /dev/null +++ b/sc/source/ui/inc/cliputil.hxx @@ -0,0 +1,32 @@ +/* -*- 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_SC_SOURCE_UI_INC_CLIPUTIL_HXX +#define INCLUDED_SC_SOURCE_UI_INC_CLIPUTIL_HXX + +#include <types.hxx> + +class ScViewData; +class ScTabViewShell; +class ScDocument; +class ScMarkData; +class ScRangeList; + +namespace ScClipUtil +{ + void PasteFromClipboard( ScViewData* pViewData, ScTabViewShell* pTabViewShell, bool bShowDialog ); + + bool CheckDestRanges( + const ScDocument* pDoc, SCCOL nSrcCols, SCROW nSrcRows, const ScMarkData& rMark, + const ScRangeList& rDest); +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/colorformat.hxx b/sc/source/ui/inc/colorformat.hxx new file mode 100644 index 000000000..bf887cc3a --- /dev/null +++ b/sc/source/ui/inc/colorformat.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/. + */ + +#ifndef INCLUDED_SC_SOURCE_UI_INC_COLORFORMAT_HXX +#define INCLUDED_SC_SOURCE_UI_INC_COLORFORMAT_HXX + +#include <vcl/weld.hxx> +#include <svx/colorbox.hxx> +#include <address.hxx> + +struct ScDataBarFormatData; +class ScDocument; +class SvNumberFormatter; + +class ScDataBarSettingsDlg : public weld::GenericDialogController +{ +private: + OUString maStrWarnSameValue; + SvNumberFormatter* mpNumberFormatter; + + ScDocument* mpDoc; + ScAddress maPos; + + std::unique_ptr<weld::Button> mxBtnOk; + std::unique_ptr<weld::Button> mxBtnCancel; + + std::unique_ptr<ColorListBox> mxLbPos; + std::unique_ptr<ColorListBox> mxLbNeg; + std::unique_ptr<ColorListBox> mxLbAxisCol; + + std::unique_ptr<weld::ComboBox> mxLbFillType; + std::unique_ptr<weld::ComboBox> mxLbTypeMin; + std::unique_ptr<weld::ComboBox> mxLbTypeMax; + std::unique_ptr<weld::ComboBox> mxLbAxisPos; + + std::unique_ptr<weld::Entry> mxEdMin; + std::unique_ptr<weld::Entry> mxEdMax; + std::unique_ptr<weld::Entry> mxLenMin; + std::unique_ptr<weld::Entry> mxLenMax; + + std::unique_ptr<weld::CheckButton> mxCbOnlyBar; + + std::unique_ptr<weld::Label> mxStrSameValueFT; + + DECL_LINK(OkBtnHdl, weld::Button&, void); + DECL_LINK(TypeSelectHdl, weld::ComboBox&, void); + DECL_LINK(PosSelectHdl, weld::ComboBox&, void); + + void Init(); + +public: + ScDataBarSettingsDlg(weld::Window* pParent, const ScDataBarFormatData& rData, ScDocument* pDoc, + const ScAddress& rPos); + virtual ~ScDataBarSettingsDlg() override; + + ScDataBarFormatData* GetData(); +}; + +#endif // INCLUDED_SC_SOURCE_UI_INC_COLORFORMAT_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/colrowba.hxx b/sc/source/ui/inc/colrowba.hxx new file mode 100644 index 000000000..bfbb5cb7b --- /dev/null +++ b/sc/source/ui/inc/colrowba.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_SC_SOURCE_UI_INC_COLROWBA_HXX +#define INCLUDED_SC_SOURCE_UI_INC_COLROWBA_HXX + +#include "hdrcont.hxx" +#include "viewdata.hxx" + +class ScHeaderFunctionSet; +class ScHeaderSelectionEngine; +class ScTabView; + +class ScColBar : public ScHeaderControl +{ + ScHSplitPos meWhich; + ScHeaderFunctionSet* mpFuncSet; + +public: + ScColBar( vcl::Window* pParent, ScHSplitPos eWhich, + ScHeaderFunctionSet* pFuncSet, ScHeaderSelectionEngine* pEng, + ScTabView* pTab ); + virtual ~ScColBar() override; + + virtual SCCOLROW GetPos() const override; + virtual sal_uInt16 GetEntrySize( SCCOLROW nEntryNo ) const override; + virtual OUString GetEntryText( SCCOLROW nEntryNo ) const override; + + virtual bool IsLayoutRTL() const override; + + virtual void SetEntrySize( SCCOLROW nPos, sal_uInt16 nNewSize ) override; + virtual void HideEntries( SCCOLROW nStart, SCCOLROW nEnd ) override; + + virtual void SetMarking( bool bSet ) override; + virtual void SelectWindow() override; + virtual bool IsDisabled() const override; + virtual bool ResizeAllowed() const override; + + virtual void DrawInvert( long nDragPos ) override; + + virtual OUString GetDragHelp( long nVal ) override; +}; + +class ScRowBar : public ScHeaderControl +{ + ScVSplitPos meWhich; + ScHeaderFunctionSet* mpFuncSet; + +public: + ScRowBar( vcl::Window* pParent, ScVSplitPos eWhich, + ScHeaderFunctionSet* pFuncSet, ScHeaderSelectionEngine* pEng, + ScTabView* pTab ); + virtual ~ScRowBar() override; + + virtual SCCOLROW GetPos() const override; + virtual sal_uInt16 GetEntrySize( SCCOLROW nEntryNo ) const override; + virtual OUString GetEntryText( SCCOLROW nEntryNo ) const override; + + virtual bool IsMirrored() const override; + virtual SCCOLROW GetHiddenCount( SCCOLROW nEntryNo ) const override; + + virtual void SetEntrySize( SCCOLROW nPos, sal_uInt16 nNewSize ) override; + virtual void HideEntries( SCCOLROW nStart, SCCOLROW nEnd ) override; + + virtual void SetMarking( bool bSet ) override; + virtual void SelectWindow() override; + virtual bool IsDisabled() const override; + virtual bool ResizeAllowed() const override; + + virtual void DrawInvert( long nDragPos ) override; + + virtual OUString GetDragHelp( long nVal ) override; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/condformatdlg.hxx b/sc/source/ui/inc/condformatdlg.hxx new file mode 100644 index 000000000..aedc4e702 --- /dev/null +++ b/sc/source/ui/inc/condformatdlg.hxx @@ -0,0 +1,133 @@ +/* -*- 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_SC_SOURCE_UI_INC_CONDFORMATDLG_HXX +#define INCLUDED_SC_SOURCE_UI_INC_CONDFORMATDLG_HXX + +#include <rangelst.hxx> +#include "condformatdlgitem.hxx" +#include "condformatdlgentry.hxx" + +#include "anyrefdg.hxx" + +#include <memory> + +#define DLG_RET_ADD 8 +#define DLG_RET_EDIT 16 + +class ScDocument; +class ScConditionalFormat; +class ScViewData; + +class ScCondFormatDlg; + +class ScCondFormatList +{ +private: + std::unique_ptr<weld::ScrolledWindow> mxScrollWindow; + std::unique_ptr<weld::Container> mxGrid; + + typedef std::vector<std::unique_ptr<ScCondFrmtEntry>> EntryContainer; + EntryContainer maEntries; + + bool mbFrozen; + bool mbNewEntry; + + ScDocument* mpDoc; + ScAddress maPos; + ScRangeList maRanges; + ScCondFormatDlg* mpDialogParent; + +public: + ScCondFormatList(ScCondFormatDlg* pParent, + std::unique_ptr<weld::ScrolledWindow> xWindow, + std::unique_ptr<weld::Container> xGrid); + weld::ScrolledWindow* GetWidget() { return mxScrollWindow.get(); } + weld::Container* GetContainer() { return mxGrid.get(); } + ~ScCondFormatList(); + + void init(ScDocument* pDoc, const ScConditionalFormat* pFormat, + const ScRangeList& rRanges, const ScAddress& rPos, + condformat::dialog::ScCondFormatDialogType eType); + + void SetRange(const ScRangeList& rRange); + + std::unique_ptr<ScConditionalFormat> GetConditionalFormat() const; + weld::Window* GetFrameWeld(); + void Freeze() { mbFrozen = true; } + void Thaw() { mbFrozen = false; } + void RecalcAll(); + + DECL_LINK( AddBtnHdl, weld::Button&, void ); + DECL_LINK( RemoveBtnHdl, weld::Button&, void ); + DECL_LINK( UpBtnHdl, weld::Button&, void ); + DECL_LINK( DownBtnHdl, weld::Button&, void ); + DECL_LINK( EntrySelectHdl, ScCondFrmtEntry&, void ); + + DECL_LINK( TypeListHdl, weld::ComboBox&, void ); + DECL_LINK( AfterTypeListHdl, void*, void ); + DECL_LINK( ColFormatTypeHdl, weld::ComboBox&, void ); + DECL_LINK( AfterColFormatTypeHdl, void*, void ); +}; + +class ScCondFormatDlg : public ScAnyRefDlgController +{ +private: + sal_Int32 mnKey; + + ScAddress maPos; + ScViewData* mpViewData; + + std::shared_ptr<ScCondFormatDlgItem> mpDlgItem; + + OUString msBaseTitle; + + formula::RefEdit* mpLastEdit; + std::unique_ptr<weld::Button> mxBtnOk; + std::unique_ptr<weld::Button> mxBtnAdd; + std::unique_ptr<weld::Button> mxBtnRemove; + std::unique_ptr<weld::Button> mxBtnUp; + std::unique_ptr<weld::Button> mxBtnDown; + std::unique_ptr<weld::Button> mxBtnCancel; + std::unique_ptr<weld::Label> mxFtRange; + std::unique_ptr<formula::RefEdit> mxEdRange; + std::unique_ptr<formula::RefButton> mxRbRange; + std::unique_ptr<ScCondFormatList> mxCondFormList; + + void updateTitle(); + DECL_LINK( EdRangeModifyHdl, formula::RefEdit&, void ); +protected: + + virtual void RefInputDone( bool bForced = false ) override; + void OkPressed(); + void CancelPressed(); + +public: + ScCondFormatDlg(SfxBindings* pB, SfxChildWindow* pCW, weld::Window* pWindow, + ScViewData* pViewData, const ScCondFormatDlgItem* pDlgItem); + virtual ~ScCondFormatDlg() override; + + std::unique_ptr<ScConditionalFormat> GetConditionalFormat() const; + + virtual void SetReference(const ScRange&, ScDocument&) override; + virtual bool IsRefInputMode() const override; + virtual void SetActive() override; + virtual bool IsTableLocked() const override; + virtual void Close() override; + + void InvalidateRefData(); + void OnSelectionChange(size_t nIndex, size_t nSize, bool bSelected = true); + + DECL_LINK( BtnPressedHdl, weld::Button&, void ); + DECL_LINK( RangeGetFocusHdl, formula::RefEdit&, void ); +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/condformatdlgentry.hxx b/sc/source/ui/inc/condformatdlgentry.hxx new file mode 100644 index 000000000..711011535 --- /dev/null +++ b/sc/source/ui/inc/condformatdlgentry.hxx @@ -0,0 +1,340 @@ +/* -*- 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_SC_SOURCE_UI_INC_CONDFORMATDLGENTRY_HXX +#define INCLUDED_SC_SOURCE_UI_INC_CONDFORMATDLGENTRY_HXX + +#include <conditio.hxx> +#include <formula/funcutl.hxx> +#include <vcl/weld.hxx> +#include <svl/lstner.hxx> +#include <svx/fntctrl.hxx> + +class ScIconSetFrmtDataEntry; +class ScCondFormatDlg; +class ScCondFormatList; +class ColorListBox; +class ScColorScaleFormat; +class ScDataBarFormat; +class ScIconSetFormat; +struct ScDataBarFormatData; + +namespace condformat { + +namespace entry { + +enum ScCondFrmtEntryType +{ + CONDITION, + FORMULA, + COLORSCALE2, + COLORSCALE3, + DATABAR, + ICONSET, + DATE +}; + +} + +} + +class ScCondFrmtEntry +{ +protected: + ScCondFormatList* mpParent; + std::unique_ptr<weld::Builder> mxBuilder; + +private: + //general ui elements + std::unique_ptr<weld::Widget> mxBorder; + std::unique_ptr<weld::Container> mxGrid; + std::unique_ptr<weld::Label> mxFtCondNr; + std::unique_ptr<weld::Label> mxFtCondition; + + bool mbActive; + OUString const maStrCondition; + Link<ScCondFrmtEntry&,void> maClickHdl; + + DECL_LINK( EntrySelectHdl, const MouseEvent&, bool ); + +protected: + std::unique_ptr<weld::ComboBox> mxLbType; + + ScDocument* mpDoc; + ScAddress maPos; + + virtual void Select(); + virtual void Deselect(); + + virtual OUString GetExpressionString() = 0; + +public: + ScCondFrmtEntry(ScCondFormatList* pParent, ScDocument* pDoc, const ScAddress& rPos); + virtual ~ScCondFrmtEntry(); + + void Show() { mxGrid->show(); } + + void set_grid_top_attach(int nAttach) { mxBorder->set_grid_top_attach(nAttach); } + int get_grid_top_attach() const { return mxBorder->get_grid_top_attach(); } + + Size get_preferred_size() const { return mxBorder->get_preferred_size(); } + + void SetPos(const ScAddress& rPos) { maPos = rPos; }; + bool IsSelected() const { return mbActive;} + void SetIndex(sal_Int32 nIndex); + + virtual ScFormatEntry* GetEntry() const = 0; + virtual void SetActive() = 0; + virtual void SetInactive() = 0; + + virtual condformat::entry::ScCondFrmtEntryType GetType() = 0; +}; + +class ScConditionFrmtEntry : public ScCondFrmtEntry, public SfxListener +{ + //cond format ui elements + SvxFontPrevWindow maWdPreview; + std::unique_ptr<weld::ComboBox> mxLbCondType; + std::unique_ptr<formula::RefEdit> mxEdVal1; + std::unique_ptr<formula::RefEdit> mxEdVal2; + std::unique_ptr<weld::Label> mxFtVal; + std::unique_ptr<weld::Label> mxFtStyle; + std::unique_ptr<weld::ComboBox> mxLbStyle; + std::unique_ptr<weld::Widget> mxWdPreviewWin; + std::unique_ptr<weld::CustomWeld> mxWdPreview; + bool mbIsInStyleCreate; + + static const sal_Int32 NUM_COND_ENTRIES = 24; + // Lookup table from positions in maLbCondType to the condition mode enum + static const ScConditionMode mpEntryToCond[NUM_COND_ENTRIES]; + + ScFormatEntry* createConditionEntry() const; + + virtual OUString GetExpressionString() override; + void Init(ScCondFormatDlg* pDialogParent); + DECL_LINK( StyleSelectHdl, weld::ComboBox&, void ); + DECL_LINK( ConditionTypeSelectHdl, weld::ComboBox&, void ); + DECL_LINK( OnEdChanged, formula::RefEdit&, void ); + + // Searches the lookup table for the entry position, given condition mode + static sal_Int32 ConditionModeToEntryPos( ScConditionMode eMode ); + // Accesses the lookup table for the condition mode, given entry position + static ScConditionMode EntryPosToConditionMode( sal_Int32 aEntryPos ); + // Returns the number of edit fields used for a given condition mode + static sal_Int32 GetNumberEditFields( ScConditionMode eMode ); + +protected: + virtual void Select() override; + virtual void Deselect() override; + +public: + ScConditionFrmtEntry(ScCondFormatList* pParent, ScDocument* pDoc, ScCondFormatDlg* pDialogParent, + const ScAddress& rPos, const ScCondFormatEntry* pFormatEntry = nullptr); + virtual ~ScConditionFrmtEntry() override; + + virtual ScFormatEntry* GetEntry() const override; + virtual void SetActive() override; + virtual void SetInactive() override; + + virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override; + + virtual condformat::entry::ScCondFrmtEntryType GetType() override { return condformat::entry::CONDITION; } +}; + +class ScFormulaFrmtEntry : public ScCondFrmtEntry +{ + SvxFontPrevWindow maWdPreview; + std::unique_ptr<weld::Label> mxFtStyle; + std::unique_ptr<weld::ComboBox> mxLbStyle; + std::unique_ptr<weld::Widget> mxWdPreviewWin; + std::unique_ptr<weld::CustomWeld> mxWdPreview; + std::unique_ptr<formula::RefEdit> mxEdFormula; + + ScFormatEntry* createFormulaEntry() const; + virtual OUString GetExpressionString() override; + void Init(ScCondFormatDlg* pDialogParent); + + DECL_LINK(StyleSelectHdl, weld::ComboBox&, void); + +public: + ScFormulaFrmtEntry(ScCondFormatList* pParent, ScDocument* PDoc, ScCondFormatDlg* pDialogParent, const ScAddress& rPos, const ScCondFormatEntry* pFormatEntry = nullptr); + virtual ~ScFormulaFrmtEntry() override; + + virtual ScFormatEntry* GetEntry() const override; + virtual void SetActive() override; + virtual void SetInactive() override; + virtual condformat::entry::ScCondFrmtEntryType GetType() override { return condformat::entry::FORMULA; } +}; + +class ScColorScale2FrmtEntry : public ScCondFrmtEntry +{ + + //color format ui elements + std::unique_ptr<weld::ComboBox> mxLbColorFormat; + + //color scale ui elements + std::unique_ptr<weld::ComboBox> mxLbEntryTypeMin; + std::unique_ptr<weld::ComboBox> mxLbEntryTypeMax; + + std::unique_ptr<weld::Entry> mxEdMin; + std::unique_ptr<weld::Entry> mxEdMax; + + std::unique_ptr<ColorListBox> mxLbColMin; + std::unique_ptr<ColorListBox> mxLbColMax; + + std::unique_ptr<weld::Label> mxFtMin; + std::unique_ptr<weld::Label> mxFtMax; + + ScFormatEntry* createColorscaleEntry() const; + + virtual OUString GetExpressionString() override; + void Init(); + + DECL_LINK( EntryTypeHdl, weld::ComboBox&, void ); +public: + ScColorScale2FrmtEntry(ScCondFormatList* pParent, ScDocument* pDoc, const ScAddress& rPos, const ScColorScaleFormat* pFormat = nullptr); + virtual ~ScColorScale2FrmtEntry() override; + virtual ScFormatEntry* GetEntry() const override; + virtual void SetActive() override; + virtual void SetInactive() override; + virtual condformat::entry::ScCondFrmtEntryType GetType() override { return condformat::entry::COLORSCALE2; } +}; + +class ScColorScale3FrmtEntry : public ScCondFrmtEntry +{ + + //color format ui elements + std::unique_ptr<weld::ComboBox> mxLbColorFormat; + + //color scale ui elements + std::unique_ptr<weld::ComboBox> mxLbEntryTypeMin; + std::unique_ptr<weld::ComboBox> mxLbEntryTypeMiddle; + std::unique_ptr<weld::ComboBox> mxLbEntryTypeMax; + + std::unique_ptr<weld::Entry> mxEdMin; + std::unique_ptr<weld::Entry> mxEdMiddle; + std::unique_ptr<weld::Entry> mxEdMax; + + std::unique_ptr<ColorListBox> mxLbColMin; + std::unique_ptr<ColorListBox> mxLbColMiddle; + std::unique_ptr<ColorListBox> mxLbColMax; + + std::unique_ptr<weld::Label> mxFtMin; + std::unique_ptr<weld::Label> mxFtMax; + + ScFormatEntry* createColorscaleEntry() const; + + virtual OUString GetExpressionString() override; + void Init(); + + DECL_LINK( EntryTypeHdl, weld::ComboBox&, void ); +public: + ScColorScale3FrmtEntry(ScCondFormatList* pParent, ScDocument* pDoc, const ScAddress& rPos, const ScColorScaleFormat* pFormat = nullptr); + virtual ~ScColorScale3FrmtEntry() override; + virtual ScFormatEntry* GetEntry() const override; + virtual void SetActive() override; + virtual void SetInactive() override; + virtual condformat::entry::ScCondFrmtEntryType GetType() override { return condformat::entry::COLORSCALE3; } +}; + +class ScDataBarFrmtEntry : public ScCondFrmtEntry +{ + //color format ui elements + std::unique_ptr<weld::ComboBox> mxLbColorFormat; + + //data bar ui elements + std::unique_ptr<weld::ComboBox> mxLbDataBarMinType; + std::unique_ptr<weld::ComboBox> mxLbDataBarMaxType; + std::unique_ptr<weld::Entry> mxEdDataBarMin; + std::unique_ptr<weld::Entry> mxEdDataBarMax; + std::unique_ptr<weld::Button> mxBtOptions; + + std::unique_ptr<weld::Label> mxFtMin; + std::unique_ptr<weld::Label> mxFtMax; + + std::unique_ptr<ScDataBarFormatData> mpDataBarData; + + ScFormatEntry* createDatabarEntry() const; + + virtual OUString GetExpressionString() override; + void Init(); + + DECL_LINK( OptionBtnHdl, weld::Button&, void ); + DECL_LINK( DataBarTypeSelectHdl, weld::ComboBox&, void ); +public: + ScDataBarFrmtEntry(ScCondFormatList* pParemt, ScDocument* pDoc, const ScAddress& rPos, const ScDataBarFormat* pFormat = nullptr); + virtual ~ScDataBarFrmtEntry() override; + virtual ScFormatEntry* GetEntry() const override; + virtual void SetActive() override; + virtual void SetInactive() override; + + virtual condformat::entry::ScCondFrmtEntryType GetType() override { return condformat::entry::DATABAR; } +}; + +class ScDateFrmtEntry : public ScCondFrmtEntry, public SfxListener +{ +public: + ScDateFrmtEntry(ScCondFormatList* pParent, ScDocument* pDoc, const ScCondDateFormatEntry* pFormat = nullptr); + virtual ~ScDateFrmtEntry() override; + virtual ScFormatEntry* GetEntry() const override; + virtual void SetActive() override; + virtual void SetInactive() override; + virtual condformat::entry::ScCondFrmtEntryType GetType() override { return condformat::entry::DATE; } + + virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override; + +protected: + virtual OUString GetExpressionString() override; + +private: + void Init(); + + DECL_LINK( StyleSelectHdl, weld::ComboBox&, void ); + + SvxFontPrevWindow maWdPreview; + std::unique_ptr<weld::ComboBox> mxLbDateEntry; + std::unique_ptr<weld::Label> mxFtStyle; + std::unique_ptr<weld::ComboBox> mxLbStyle; + std::unique_ptr<weld::Widget> mxWdPreviewWin; + std::unique_ptr<weld::CustomWeld> mxWdPreview; + + bool mbIsInStyleCreate; +}; + +class ScIconSetFrmtEntry : public ScCondFrmtEntry +{ + //color format ui elements + std::unique_ptr<weld::ComboBox> mxLbColorFormat; + + // icon set ui elements + std::unique_ptr<weld::ComboBox> mxLbIconSetType; + + std::unique_ptr<weld::Container> mxIconParent; + + typedef std::vector<std::unique_ptr<ScIconSetFrmtDataEntry>> ScIconSetFrmtDataEntriesType; + ScIconSetFrmtDataEntriesType maEntries; + + virtual OUString GetExpressionString() override; + + void Init(); + + DECL_LINK(IconSetTypeHdl, weld::ComboBox&, void); + +public: + ScIconSetFrmtEntry(ScCondFormatList* pParent, ScDocument* pDoc, const ScAddress& rPos, const ScIconSetFormat* pFormat = nullptr); + virtual ~ScIconSetFrmtEntry() override; + virtual ScFormatEntry* GetEntry() const override; + virtual void SetActive() override; + virtual void SetInactive() override; + virtual condformat::entry::ScCondFrmtEntryType GetType() override { return condformat::entry::ICONSET; } +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/condformatdlgitem.hxx b/sc/source/ui/inc/condformatdlgitem.hxx new file mode 100644 index 000000000..27df99ef9 --- /dev/null +++ b/sc/source/ui/inc/condformatdlgitem.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/. + */ + +#ifndef INCLUDED_SC_SOURCE_UI_INC_CONDFORMATDLGITEM_HXX +#define INCLUDED_SC_SOURCE_UI_INC_CONDFORMATDLGITEM_HXX + +#include <svl/poolitem.hxx> + +#include <memory> + +namespace condformat { + +namespace dialog { + +enum ScCondFormatDialogType +{ + NONE, + CONDITION, + COLORSCALE, + DATABAR, + ICONSET, + DATE +}; + +} + +} + +class ScConditionalFormatList; + +class ScCondFormatDlgItem : public SfxPoolItem +{ +public: + + ScCondFormatDlgItem(std::shared_ptr<ScConditionalFormatList> pCondFormats, sal_Int32 nItem, bool bManaged); + + virtual ~ScCondFormatDlgItem() override; + + ScCondFormatDlgItem(ScCondFormatDlgItem const &) = default; + ScCondFormatDlgItem(ScCondFormatDlgItem &&) = default; + ScCondFormatDlgItem & operator =(ScCondFormatDlgItem const &) = delete; // due to SfxPoolItem + ScCondFormatDlgItem & operator =(ScCondFormatDlgItem &&) = delete; // due to SfxPoolItem + + virtual bool operator==(const SfxPoolItem&) const override; + virtual ScCondFormatDlgItem* Clone(SfxItemPool* pPool = nullptr) const override; + + bool IsManaged() const; + condformat::dialog::ScCondFormatDialogType GetDialogType() const; + sal_Int32 GetIndex() const; + + void SetDialogType(condformat::dialog::ScCondFormatDialogType eType); + + ScConditionalFormatList* GetConditionalFormatList(); + +private: + + std::shared_ptr<ScConditionalFormatList> mpCondFormats; + sal_Int32 mnItem; + condformat::dialog::ScCondFormatDialogType meDialogType; + bool mbManaged; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/condformathelper.hxx b/sc/source/ui/inc/condformathelper.hxx new file mode 100644 index 000000000..79de9c7d6 --- /dev/null +++ b/sc/source/ui/inc/condformathelper.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/. + */ + +#ifndef INCLUDED_SC_SOURCE_UI_INC_CONDFORMATHELPER_HXX +#define INCLUDED_SC_SOURCE_UI_INC_CONDFORMATHELPER_HXX + +#include <rtl/ustring.hxx> +#include <address.hxx> + +class ScConditionalFormat; + +enum ScCondFormatEntryType +{ + CONDITION, + COLORSCALE, + DATABAR, + FORMULA, + ICONSET, + DATE +}; + +class ScCondFormatHelper +{ +public: + static SC_DLLPUBLIC OUString GetExpression(const ScConditionalFormat& rFormat, const ScAddress& rPos); + + static SC_DLLPUBLIC OUString GetExpression( ScCondFormatEntryType eType, sal_Int32 nIndex, + const OUString& aStr1 = OUString(), const OUString& aStr2 = OUString() ); +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/condformatmgr.hxx b/sc/source/ui/inc/condformatmgr.hxx new file mode 100644 index 000000000..f24f57952 --- /dev/null +++ b/sc/source/ui/inc/condformatmgr.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/. + */ + +#ifndef INCLUDED_SC_SOURCE_UI_INC_CONDFORMATMGR_HXX +#define INCLUDED_SC_SOURCE_UI_INC_CONDFORMATMGR_HXX + +#include <vcl/weld.hxx> + +#include <map> + +class ScDocument; +class ScConditionalFormat; +class ScConditionalFormatList; + +class ScCondFormatManagerWindow +{ +private: + void Init(); + void setColSizes(); + + weld::TreeView& mrTreeView; + ScDocument* mpDoc; + ScConditionalFormatList* mpFormatList; + +public: + ScCondFormatManagerWindow(weld::TreeView& rTreeView, ScDocument* pDoc, ScConditionalFormatList* pFormatList); + + void DeleteSelection(); + ScConditionalFormat* GetSelection(); +}; + +class ScCondFormatManagerDlg : public weld::GenericDialogController +{ +public: + ScCondFormatManagerDlg(weld::Window* pParent, ScDocument* pDoc, const ScConditionalFormatList* pFormatList); + virtual ~ScCondFormatManagerDlg() override; + + std::unique_ptr<ScConditionalFormatList> GetConditionalFormatList(); + + bool CondFormatsChanged() const; + void SetModified(); + + ScConditionalFormat* GetCondFormatSelected(); + +private: + bool m_bModified; + std::unique_ptr<ScConditionalFormatList> m_xFormatList; + + std::unique_ptr<weld::Button> m_xBtnAdd; + std::unique_ptr<weld::Button> m_xBtnRemove; + std::unique_ptr<weld::Button> m_xBtnEdit; + std::unique_ptr<weld::TreeView> m_xTreeView; + std::unique_ptr<ScCondFormatManagerWindow> m_xCtrlManager; + + void UpdateButtonSensitivity(); + + DECL_LINK(RemoveBtnHdl, weld::Button&, void); + DECL_LINK(EditBtnClickHdl, weld::Button&, void); + DECL_LINK(AddBtnHdl, weld::Button&, void); + DECL_LINK(EditBtnHdl, weld::TreeView&, bool); +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/condformatuno.hxx b/sc/source/ui/inc/condformatuno.hxx new file mode 100644 index 000000000..c342e78e4 --- /dev/null +++ b/sc/source/ui/inc/condformatuno.hxx @@ -0,0 +1,369 @@ +/* -*- 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_SC_SOURCE_UI_INC_CONDFORMATUNO_HXX +#define INCLUDED_SC_SOURCE_UI_INC_CONDFORMATUNO_HXX + +#include <types.hxx> + +#include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/sheet/XConditionalFormats.hpp> +#include <com/sun/star/sheet/XConditionalFormat.hpp> +#include <com/sun/star/sheet/XConditionEntry.hpp> +#include <com/sun/star/sheet/XColorScaleEntry.hpp> +#include <com/sun/star/sheet/XDataBarEntry.hpp> +#include <com/sun/star/sheet/XIconSetEntry.hpp> + +#include <cppuhelper/implbase.hxx> +#include <svl/itemprop.hxx> +#include <svl/lstner.hxx> +#include <rtl/ref.hxx> + +class ScDocShell; +class ScConditionalFormatList; +class ScConditionalFormat; +class ScIconSetFormat; +class ScDataBarFormat; +class ScColorScaleFormat; +class ScCondFormatEntry; +class ScColorScaleEntry; +class ScCondDateFormatEntry; + +using namespace com::sun::star; + +namespace com::sun::star::sheet { class XSheetCellRanges; } + +class ScCondFormatsObj : public cppu::WeakImplHelper<css::sheet::XConditionalFormats>, + public SfxListener +{ +public: + ScCondFormatsObj(ScDocShell* pDocShell, SCTAB nTab); + + virtual ~ScCondFormatsObj() override; + + virtual void Notify(SfxBroadcaster& rBC, const SfxHint& rHint) override; + + // XConditionalFormats + virtual sal_Int32 SAL_CALL createByRange(const uno::Reference<sheet::XSheetCellRanges>& xRanges) override; + + virtual void SAL_CALL removeByID( const sal_Int32 nID ) override; + + virtual uno::Sequence< uno::Reference< sheet::XConditionalFormat > > SAL_CALL getConditionalFormats() override; + + virtual sal_Int32 SAL_CALL getLength() override; + + ScConditionalFormatList* getCoreObject(); + +private: + SCTAB mnTab; + ScDocShell* mpDocShell; +}; + +class ScCondFormatObj : public cppu::WeakImplHelper<css::sheet::XConditionalFormat, + css::beans::XPropertySet> +{ +public: + ScCondFormatObj(ScDocShell* pDocShell, rtl::Reference<ScCondFormatsObj> const & xCondFormats, sal_Int32 nKey); + + virtual ~ScCondFormatObj() override; + + ScDocShell* getDocShell(); + + // XConditionalFormat + virtual void SAL_CALL createEntry(const sal_Int32 nType, const sal_Int32 nPos) override; + + virtual void SAL_CALL removeByIndex(const sal_Int32 nIndex) override; + + // XIndexAccess + + virtual uno::Type SAL_CALL getElementType() override; + + virtual sal_Bool SAL_CALL hasElements() override; + + virtual sal_Int32 SAL_CALL getCount() override; + + virtual uno::Any SAL_CALL getByIndex(sal_Int32 nIndex) 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; + + ScConditionalFormat* getCoreObject(); + +private: + rtl::Reference<ScCondFormatsObj> mxCondFormatList; + ScDocShell* mpDocShell; + SfxItemPropertySet maPropSet; + sal_Int32 mnKey; +}; + +class ScConditionEntryObj : public cppu::WeakImplHelper<css::beans::XPropertySet, + css::sheet::XConditionEntry> +{ +public: + + ScConditionEntryObj(rtl::Reference<ScCondFormatObj> const & xParent, + const ScCondFormatEntry* pFormat); + virtual ~ScConditionEntryObj() override; + + ScCondFormatEntry* getCoreObject(); + + // XConditionEntry + virtual sal_Int32 SAL_CALL getType() 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; + +private: + ScDocShell* mpDocShell; + rtl::Reference<ScCondFormatObj> mxParent; + SfxItemPropertySet maPropSet; + const ScCondFormatEntry* mpFormat; +}; + +class ScColorScaleFormatObj : public cppu::WeakImplHelper<css::beans::XPropertySet, + css::sheet::XConditionEntry> +{ +public: + + ScColorScaleFormatObj(rtl::Reference<ScCondFormatObj> const & xParent, const ScColorScaleFormat* pFormat); + virtual ~ScColorScaleFormatObj() override; + + // XConditionEntry + virtual sal_Int32 SAL_CALL getType() override; + + + ScColorScaleFormat* getCoreObject(); + + // 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; + +private: + rtl::Reference<ScCondFormatObj> mxParent; + SfxItemPropertySet maPropSet; + const ScColorScaleFormat* mpFormat; +}; + +class ScColorScaleEntryObj : public cppu::WeakImplHelper<css::sheet::XColorScaleEntry> +{ +public: + ScColorScaleEntryObj(rtl::Reference<ScColorScaleFormatObj> const & xParent, size_t nPos); + + virtual ~ScColorScaleEntryObj() override; + + virtual sal_Int32 SAL_CALL getColor() override; + + virtual void SAL_CALL setColor(sal_Int32 aColor) override; + + virtual sal_Int32 SAL_CALL getType() override; + + virtual void SAL_CALL setType(sal_Int32 nType) override; + + virtual OUString SAL_CALL getFormula() override; + + virtual void SAL_CALL setFormula(const OUString& rString) override; + +private: + ScColorScaleEntry* getCoreObject(); + + rtl::Reference<ScColorScaleFormatObj> mxParent; + size_t mnPos; +}; + +class ScDataBarFormatObj : public cppu::WeakImplHelper<css::beans::XPropertySet, + css::sheet::XConditionEntry> +{ +public: + ScDataBarFormatObj(rtl::Reference<ScCondFormatObj> const & xParent, + const ScDataBarFormat* pFormat); + virtual ~ScDataBarFormatObj() override; + + ScDataBarFormat* getCoreObject(); + + // XConditionEntry + virtual sal_Int32 SAL_CALL getType() 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; + +private: + rtl::Reference<ScCondFormatObj> mxParent; + SfxItemPropertySet maPropSet; + const ScDataBarFormat* mpFormat; +}; + +class ScDataBarEntryObj : public cppu::WeakImplHelper<css::sheet::XDataBarEntry> +{ +public: + ScDataBarEntryObj(rtl::Reference<ScDataBarFormatObj> const & xParent, size_t nPos); + + virtual ~ScDataBarEntryObj() override; + + virtual sal_Int32 SAL_CALL getType() override; + + virtual void SAL_CALL setType(sal_Int32 nType) override; + + virtual OUString SAL_CALL getFormula() override; + + virtual void SAL_CALL setFormula(const OUString& rString) override; + +private: + ScColorScaleEntry* getCoreObject(); + + rtl::Reference<ScDataBarFormatObj> mxParent; + size_t mnPos; +}; + +class ScIconSetFormatObj : public cppu::WeakImplHelper<css::beans::XPropertySet, + css::sheet::XConditionEntry> +{ +public: + ScIconSetFormatObj(rtl::Reference<ScCondFormatObj> const & xParent, + const ScIconSetFormat* pFormat); + virtual ~ScIconSetFormatObj() override; + + ScIconSetFormat* getCoreObject(); + + // XConditionEntry + virtual sal_Int32 SAL_CALL getType() 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; + +private: + rtl::Reference<ScCondFormatObj> mxParent; + SfxItemPropertySet maPropSet; + const ScIconSetFormat* mpFormat; +}; + +class ScIconSetEntryObj : public cppu::WeakImplHelper<css::sheet::XIconSetEntry> +{ +public: + ScIconSetEntryObj(rtl::Reference<ScIconSetFormatObj> const & xParent, size_t nPos); + + virtual ~ScIconSetEntryObj() override; + + virtual sal_Int32 SAL_CALL getType() override; + + virtual void SAL_CALL setType(sal_Int32 nType) override; + + virtual OUString SAL_CALL getFormula() override; + + virtual void SAL_CALL setFormula(const OUString& rString) override; + +private: + ScColorScaleEntry* getCoreObject(); + + rtl::Reference<ScIconSetFormatObj> mxParent; + size_t mnPos; +}; + +class ScCondDateFormatObj : public cppu::WeakImplHelper<css::beans::XPropertySet, + css::sheet::XConditionEntry> +{ +public: + ScCondDateFormatObj(rtl::Reference<ScCondFormatObj> const & xParent, + const ScCondDateFormatEntry* pFormat); + + virtual ~ScCondDateFormatObj() override; + + ScCondDateFormatEntry* getCoreObject(); + + // XConditionEntry + virtual sal_Int32 SAL_CALL getType() 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; + +private: + rtl::Reference<ScCondFormatObj> mxParent; + SfxItemPropertySet maPropSet; + const ScCondDateFormatEntry* mpFormat; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/conflictsdlg.hxx b/sc/source/ui/inc/conflictsdlg.hxx new file mode 100644 index 000000000..e8797a90b --- /dev/null +++ b/sc/source/ui/inc/conflictsdlg.hxx @@ -0,0 +1,153 @@ +/* -*- 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_SC_SOURCE_UI_INC_CONFLICTSDLG_HXX +#define INCLUDED_SC_SOURCE_UI_INC_CONFLICTSDLG_HXX + +#include <vcl/idle.hxx> +#include <svx/ctredlin.hxx> + +#include "docsh.hxx" + +class ScViewData; +class ScChangeTrack; +class ScChangeAction; + +enum ScConflictAction +{ + SC_CONFLICT_ACTION_NONE, + SC_CONFLICT_ACTION_KEEP_MINE, + SC_CONFLICT_ACTION_KEEP_OTHER +}; + +// struct ScConflictsListEntry + +struct ScConflictsListEntry +{ + ScConflictAction meConflictAction; + std::vector<sal_uLong> maSharedActions; + std::vector<sal_uLong> maOwnActions; + + bool HasSharedAction( sal_uLong nSharedAction ) const; + bool HasOwnAction( sal_uLong nOwnAction ) const; +}; + +typedef ::std::vector< ScConflictsListEntry > ScConflictsList; + + +class ScConflictsListHelper +{ +private: + static void Transform_Impl( std::vector<sal_uLong>& rActionList, ScChangeActionMergeMap* pMergeMap ); + +public: + static bool HasOwnAction( ScConflictsList& rConflictsList, sal_uLong nOwnAction ); + + static ScConflictsListEntry* GetSharedActionEntry( ScConflictsList& rConflictsList, sal_uLong nSharedAction ); + static ScConflictsListEntry* GetOwnActionEntry( ScConflictsList& rConflictsList, sal_uLong nOwnAction ); + + static void TransformConflictsList( ScConflictsList& rConflictsList, + ScChangeActionMergeMap* pSharedMap, ScChangeActionMergeMap* pOwnMap ); +}; + + +class ScConflictsFinder final +{ +private: + ScChangeTrack* mpTrack; + sal_uLong mnStartShared; + sal_uLong mnEndShared; + sal_uLong mnStartOwn; + sal_uLong mnEndOwn; + ScConflictsList& mrConflictsList; + + static bool DoActionsIntersect( const ScChangeAction* pAction1, const ScChangeAction* pAction2 ); + ScConflictsListEntry* GetIntersectingEntry( const ScChangeAction* pAction ) const; + ScConflictsListEntry& GetEntry(sal_uLong nSharedAction, const std::vector<sal_uLong>& rOwnActions); + +public: + ScConflictsFinder( ScChangeTrack* pTrack, sal_uLong nStartShared, sal_uLong nEndShared, + sal_uLong nStartOwn, sal_uLong nEndOwn, ScConflictsList& rConflictsList ); + ~ScConflictsFinder(); + + bool Find(); +}; + + +class ScConflictsResolver final +{ +private: + ScChangeTrack* mpTrack; + ScConflictsList& mrConflictsList; + +public: + ScConflictsResolver( ScChangeTrack* pTrack, ScConflictsList& rConflictsList ); + ~ScConflictsResolver(); + + void HandleAction( ScChangeAction* pAction, bool bIsSharedAction, + bool bHandleContentAction, bool bHandleNonContentAction ); +}; + + +class ScConflictsDlg : public weld::GenericDialogController +{ +private: + OUString maStrUnknownUser; + + ScViewData* const mpViewData; + ScDocument* mpOwnDoc; + ScChangeTrack* mpOwnTrack; + ScDocument* const mpSharedDoc; + ScChangeTrack* mpSharedTrack; + ScConflictsList& mrConflictsList; + + Idle maSelectionIdle; + bool mbInSelectHdl; + + std::unique_ptr<weld::Button> m_xBtnKeepMine; + std::unique_ptr<weld::Button> m_xBtnKeepOther; + std::unique_ptr<weld::Button> m_xBtnKeepAllMine; + std::unique_ptr<weld::Button> m_xBtnKeepAllOthers; + std::unique_ptr<SvxRedlinTable> m_xLbConflicts; + + OUString GetConflictString( const ScConflictsListEntry& rConflictEntry ); + void SetActionString(const ScChangeAction* pAction, ScDocument* pDoc, const weld::TreeIter& rEntry); + void HandleListBoxSelection(); + + void SetConflictAction(const weld::TreeIter& rRootEntry, ScConflictAction eConflictAction); + void KeepHandler( bool bMine ); + void KeepAllHandler( bool bMine ); + + DECL_LINK( SelectHandle, weld::TreeView&, void ); + DECL_LINK( UpdateSelectionHdl, Timer*, void ); + DECL_LINK( KeepMineHandle, weld::Button&, void ); + DECL_LINK( KeepOtherHandle, weld::Button&, void ); + DECL_LINK( KeepAllMineHandle, weld::Button&, void ); + DECL_LINK( KeepAllOthersHandle, weld::Button&, void ); + +public: + ScConflictsDlg(weld::Window* pParent, ScViewData* pViewData, ScDocument* pSharedDoc, ScConflictsList& rConflictsList); + virtual ~ScConflictsDlg() override; + + void UpdateView(); +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/consdlg.hxx b/sc/source/ui/inc/consdlg.hxx new file mode 100644 index 000000000..098c14242 --- /dev/null +++ b/sc/source/ui/inc/consdlg.hxx @@ -0,0 +1,102 @@ +/* -*- 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_SC_SOURCE_UI_INC_CONSDLG_HXX +#define INCLUDED_SC_SOURCE_UI_INC_CONSDLG_HXX + +#include <global.hxx> +#include "anyrefdg.hxx" + +class ScViewData; +class ScDocument; +class ScRangeUtil; +class ScAreaData; + +class ScConsolidateDlg : public ScAnyRefDlgController +{ +public: + ScConsolidateDlg(SfxBindings* pB, SfxChildWindow* pCW, weld::Window* pParent, + const SfxItemSet& rArgSet); + virtual ~ScConsolidateDlg() override; + + virtual void SetReference( const ScRange& rRef, ScDocument& rDoc ) override; + + virtual bool IsRefInputMode() const override { return true; } + virtual void SetActive() override; + + virtual void Close() override; + virtual void Deactivate() override; + +private: + OUString aStrUndefined; + + ScConsolidateParam theConsData; + ScViewData& rViewData; + ScDocument* pDoc; + std::unique_ptr<ScAreaData[]> pAreaData; + size_t nAreaDataCount; + sal_uInt16 nWhichCons; + bool bDlgLostFocus; + + formula::RefEdit* m_pRefInputEdit; + + std::unique_ptr<weld::ComboBox> m_xLbFunc; + std::unique_ptr<weld::TreeView> m_xLbConsAreas; + + std::unique_ptr<weld::ComboBox> m_xLbDataArea; + std::unique_ptr<formula::RefEdit> m_xEdDataArea; + std::unique_ptr<formula::RefButton> m_xRbDataArea; + + std::unique_ptr<weld::ComboBox> m_xLbDestArea; + std::unique_ptr<formula::RefEdit> m_xEdDestArea; + std::unique_ptr<formula::RefButton> m_xRbDestArea; + + std::unique_ptr<weld::Expander> m_xExpander; + std::unique_ptr<weld::CheckButton> m_xBtnByRow; + std::unique_ptr<weld::CheckButton> m_xBtnByCol; + + std::unique_ptr<weld::CheckButton> m_xBtnRefs; + + std::unique_ptr<weld::Button> m_xBtnOk; + std::unique_ptr<weld::Button> m_xBtnCancel; + std::unique_ptr<weld::Button> m_xBtnAdd; + std::unique_ptr<weld::Button> m_xBtnRemove; + + std::unique_ptr<weld::Label> m_xDataFT; + std::unique_ptr<weld::Label> m_xDestFT; + + void Init (); + void FillAreaLists (); + bool VerifyEdit(formula::RefEdit* pEd); + + DECL_LINK( OkHdl, weld::Button&, void ); + DECL_LINK( ClickHdl, weld::Button&, void ); + DECL_LINK( GetFocusHdl, weld::Widget&, void ); + DECL_LINK( GetEditFocusHdl, formula::RefEdit&, void ); + DECL_LINK( ModifyHdl, formula::RefEdit&, void ); + DECL_LINK( SelectTVHdl, weld::TreeView&, void ); + DECL_LINK( SelectCBHdl, weld::ComboBox&, void ); + + static ScSubTotalFunc LbPosToFunc( sal_Int32 nPos ); + static sal_Int32 FuncToLbPos( ScSubTotalFunc eFunc ); +}; + +#endif // INCLUDED_SC_SOURCE_UI_INC_CONSDLG_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/content.hxx b/sc/source/ui/inc/content.hxx new file mode 100644 index 000000000..7e0207812 --- /dev/null +++ b/sc/source/ui/inc/content.hxx @@ -0,0 +1,175 @@ +/* -*- 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_SC_SOURCE_UI_INC_CONTENT_HXX +#define INCLUDED_SC_SOURCE_UI_INC_CONTENT_HXX + +#include <vcl/weld.hxx> +#include <address.hxx> +#include <tools/solar.h> +#include <o3tl/enumarray.hxx> + +class ScAreaLink; +class ScLinkTransferObj; +class ScDocument; +class ScDocShell; +class ScNavigatorDlg; +struct ImplSVEvent; + +enum class ScContentId { + ROOT, TABLE, RANGENAME, DBAREA, + GRAPHIC, OLEOBJECT, NOTE, AREALINK, + DRAWING, LAST = DRAWING +}; + +const sal_uLong SC_CONTENT_NOCHILD = ~0UL; + +class ScContentTree +{ + std::unique_ptr<weld::TreeView> m_xTreeView; + std::unique_ptr<weld::TreeIter> m_xScratchIter; + rtl::Reference<ScLinkTransferObj> m_xTransferObj; + VclPtr<ScNavigatorDlg> pParentWindow; + o3tl::enumarray<ScContentId, std::unique_ptr<weld::TreeIter>> m_aRootNodes; + ScContentId nRootType; // set as Root + OUString aManualDoc; // Switched in Navigator (Title) + bool bHiddenDoc; // Hidden active? + OUString aHiddenName; // URL to load + OUString aHiddenTitle; // for display + ScDocument* pHiddenDocument; // temporary + bool bisInNavigatoeDlg; + bool m_bFreeze; + OUString sKeyString; + ImplSVEvent* m_nAsyncMouseReleaseId; + + o3tl::enumarray<ScContentId, sal_uInt16> pPosList; // for the sequence + + static bool bIsInDrag; // static, if the Navigator is deleted in ExecuteDrag + + ScDocShell* GetManualOrCurrent(); + + void InitRoot(ScContentId nType); + void ClearType(ScContentId nType); + void ClearAll(); + void InsertContent( ScContentId nType, const OUString& rValue ); + void GetDrawNames( ScContentId nType ); + + void GetTableNames(); + void GetAreaNames(); + void GetDbNames(); + void GetLinkNames(); + void GetGraphicNames(); + void GetOleNames(); + void GetDrawingNames(); + void GetNoteStrings(); + + static bool IsPartOfType( ScContentId nContentType, sal_uInt16 nObjIdentifier ); + + bool DrawNamesChanged( ScContentId nType ); + bool NoteStringsChanged(); + + ScAddress GetNotePos( sal_uLong nIndex ); + const ScAreaLink* GetLink( sal_uLong nIndex ); + + /** Returns the indexes of the specified listbox entry. + @param rnRootIndex Root index of specified entry is returned. + @param rnChildIndex Index of the entry inside its root is returned (or SC_CONTENT_NOCHILD if entry is root). + @param pEntry The entry to examine. */ + void GetEntryIndexes(ScContentId& rnRootIndex, sal_uLong& rnChildIndex, const weld::TreeIter* pEntry) const; + + /** Returns the child index of the specified listbox entry. + @param pEntry The entry to examine or NULL for the selected entry. + @return Index of the entry inside its root or SC_CONTENT_NOCHILD if entry is root. */ + sal_uLong GetChildIndex(const weld::TreeIter* pEntry) const; + + ScDocument* GetSourceDocument(); + + void freeze() + { + m_xTreeView->freeze(); + m_bFreeze = true; + } + + void thaw() + { + m_xTreeView->thaw(); + m_bFreeze = false; + } + + void LaunchAsyncStoreNavigatorSettings(); + + DECL_LINK(ContentDoubleClickHdl, weld::TreeView&, bool); + DECL_LINK(MouseReleaseHdl, const MouseEvent&, bool); + DECL_LINK(KeyInputHdl, const KeyEvent&, bool); + DECL_LINK(AsyncStoreNavigatorSettings, void*, void); + DECL_LINK(CommandHdl, const CommandEvent&, bool); + DECL_LINK(QueryTooltipHdl, const weld::TreeIter&, OUString); + DECL_LINK(DragBeginHdl, bool&, bool); + +public: + ScContentTree(std::unique_ptr<weld::TreeView> xTreeView, ScNavigatorDlg* pNavigatorDlg); + ~ScContentTree(); + + void ObjectFresh(ScContentId nType, const weld::TreeIter* pEntry = nullptr); + void SetNavigatorDlgFlag(bool isInNavigateDlg){ bisInNavigatoeDlg=isInNavigateDlg;}; + + void set_selection_mode(SelectionMode eMode) + { + m_xTreeView->set_selection_mode(eMode); + } + + void set_size_request(int nWidth, int nHeight) + { + m_xTreeView->set_size_request(nWidth, nHeight); + } + + void hide() + { + m_xTreeView->hide(); + } + + void show() + { + m_xTreeView->show(); + } + + void Refresh( ScContentId nType = ScContentId::ROOT ); + + void ToggleRoot(); + void SetRootType( ScContentId nNew ); + ScContentId GetRootType() const { return nRootType; } + + void ActiveDocChanged(); + void ResetManualDoc(); + void SetManualDoc(const OUString& rName); + void LoadFile(const OUString& rUrl); + void SelectDoc(const OUString& rName); + void SelectEntryByName(const ScContentId nRoot, const OUString& rName); + + const OUString& GetHiddenTitle() const { return aHiddenTitle; } + + /** Applies the navigator settings to the listbox. */ + void ApplyNavigatorSettings(bool bRestoreScrollPos = false, int nScrollPos = 0); + /** Stores the current listbox state in the navigator settings. */ + void StoreNavigatorSettings() const; +}; + +#endif // INCLUDED_SC_SOURCE_UI_INC_CONTENT_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/corodlg.hxx b/sc/source/ui/inc/corodlg.hxx new file mode 100644 index 000000000..0c8280e3d --- /dev/null +++ b/sc/source/ui/inc/corodlg.hxx @@ -0,0 +1,48 @@ +/* -*- 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_SC_SOURCE_UI_INC_CORODLG_HXX +#define INCLUDED_SC_SOURCE_UI_INC_CORODLG_HXX + +#include <vcl/weld.hxx> + +class ScColRowLabelDlg : public weld::GenericDialogController +{ +public: + ScColRowLabelDlg(weld::Window* pParent, bool bCol, bool bRow) + : GenericDialogController(pParent, "modules/scalc/ui/changesourcedialog.ui", + "ChangeSourceDialog") + , m_xBtnRow(m_xBuilder->weld_check_button("row")) + , m_xBtnCol(m_xBuilder->weld_check_button("col")) + { + m_xBtnCol->set_active(bCol); + m_xBtnRow->set_active(bRow); + } + + bool IsCol() const { return m_xBtnCol->get_active(); } + bool IsRow() const { return m_xBtnRow->get_active(); } + +private: + std::unique_ptr<weld::CheckButton> m_xBtnRow; + std::unique_ptr<weld::CheckButton> m_xBtnCol; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/crdlg.hxx b/sc/source/ui/inc/crdlg.hxx new file mode 100644 index 000000000..3aab04206 --- /dev/null +++ b/sc/source/ui/inc/crdlg.hxx @@ -0,0 +1,42 @@ +/* -*- 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_SC_SOURCE_UI_INC_CRDLG_HXX +#define INCLUDED_SC_SOURCE_UI_INC_CRDLG_HXX + +#include <vcl/weld.hxx> + +class ScColOrRowDlg : public weld::GenericDialogController +{ +public: + ScColOrRowDlg(weld::Window* pParent, const OUString& rStrTitle, const OUString& rStrLabel); + virtual ~ScColOrRowDlg() override; + +private: + std::unique_ptr<weld::Frame> m_xFrame; + std::unique_ptr<weld::RadioButton> m_xBtnRows; + std::unique_ptr<weld::RadioButton> m_xBtnCols; + std::unique_ptr<weld::Button> m_xBtnOk; + + DECL_LINK(OkHdl, weld::Button&, void); +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/crnrdlg.hxx b/sc/source/ui/inc/crnrdlg.hxx new file mode 100644 index 000000000..bfca95248 --- /dev/null +++ b/sc/source/ui/inc/crnrdlg.hxx @@ -0,0 +1,98 @@ +/* -*- 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_SC_SOURCE_UI_INC_CRNRDLG_HXX +#define INCLUDED_SC_SOURCE_UI_INC_CRNRDLG_HXX + +#include "anyrefdg.hxx" +#include <rangelst.hxx> + +#include <unordered_map> + +class ScViewData; +class ScDocument; + +class ScColRowNameRangesDlg : public ScAnyRefDlgController +{ +public: + ScColRowNameRangesDlg(SfxBindings* pB, SfxChildWindow* pCW, weld::Window* pParent, + ScViewData* ptrViewData); + virtual ~ScColRowNameRangesDlg() override; + + virtual void SetReference( const ScRange& rRef, ScDocument& rDoc ) override; + + virtual bool IsRefInputMode() const override; + virtual void SetActive() override; + virtual void Close() override; + +private: + ScRange theCurArea; + ScRange theCurData; + + ScRangePairListRef xColNameRanges; + ScRangePairListRef xRowNameRanges; + + typedef std::unordered_map< OUString, ScRange > NameRangeMap; + NameRangeMap aRangeMap; + ScViewData* pViewData; + ScDocument* pDoc; + bool bDlgLostFocus; + + formula::RefEdit* m_pEdActive; + std::unique_ptr<weld::TreeView> m_xLbRange; + + std::unique_ptr<formula::RefEdit> m_xEdAssign; + std::unique_ptr<formula::RefButton> m_xRbAssign; + std::unique_ptr<weld::RadioButton> m_xBtnColHead; + std::unique_ptr<weld::RadioButton> m_xBtnRowHead; + std::unique_ptr<formula::RefEdit> m_xEdAssign2; + std::unique_ptr<formula::RefButton> m_xRbAssign2; + + std::unique_ptr<weld::Button> m_xBtnOk; + std::unique_ptr<weld::Button> m_xBtnCancel; + std::unique_ptr<weld::Button> m_xBtnAdd; + std::unique_ptr<weld::Button> m_xBtnRemove; + + std::unique_ptr<weld::Frame> m_xRangeFrame; + std::unique_ptr<weld::Label> m_xRangeFT; + std::unique_ptr<weld::Label> m_xDataFT; + + void Init (); + void UpdateNames (); + void UpdateRangeData ( const ScRange& rRange, bool bColName ); + void SetColRowData( const ScRange& rLabelRange, bool bRef=false); + void AdjustColRowData( const ScRange& rDataRange, bool bRef=false); + DECL_LINK( CancelBtnHdl, weld::Button&, void ); + DECL_LINK( OkBtnHdl, weld::Button&, void ); + DECL_LINK( AddBtnHdl, weld::Button&, void ); + DECL_LINK( RemoveBtnHdl, weld::Button&, void ); + DECL_LINK( Range1SelectHdl, weld::TreeView&, void ); + DECL_LINK( Range1DataModifyHdl, formula::RefEdit&, void ); + DECL_LINK( ColClickHdl, weld::Button&, void ); + DECL_LINK( RowClickHdl, weld::Button&, void ); + DECL_LINK( Range2DataModifyHdl, formula::RefEdit&, void ); + DECL_LINK( GetEditFocusHdl, formula::RefEdit&, void ); + DECL_LINK( LoseEditFocusHdl, formula::RefEdit&, void ); + DECL_LINK( GetButtonFocusHdl, formula::RefButton&, void ); + DECL_LINK( LoseButtonFocusHdl, formula::RefButton&, void ); +}; + +#endif // INCLUDED_SC_SOURCE_UI_INC_CRNRDLG_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/csvcontrol.hxx b/sc/source/ui/inc/csvcontrol.hxx new file mode 100644 index 000000000..8a87e3063 --- /dev/null +++ b/sc/source/ui/inc/csvcontrol.hxx @@ -0,0 +1,377 @@ +/* -*- 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_SC_SOURCE_UI_INC_CSVCONTROL_HXX +#define INCLUDED_SC_SOURCE_UI_INC_CSVCONTROL_HXX + +#include <scdllapi.h> +#include <address.hxx> +#include "csvsplits.hxx" +#include <com/sun/star/uno/Reference.hxx> +#include <o3tl/typed_flags_set.hxx> +#include <rtl/ref.hxx> +#include <vcl/customweld.hxx> +#include "AccessibleCsvControl.hxx" + +namespace com::sun::star::accessibility { class XAccessible; } + +/** Minimum character count for a column in separators mode. */ +const sal_Int32 CSV_MINCOLWIDTH = 8; +/** Maximum length of a cell string. */ +const sal_Int32 CSV_MAXSTRLEN = 0x7FFF; +/** Transparency for header color of selected columns. */ +const sal_uInt16 CSV_HDR_TRANSPARENCY = 85; +/** Minimum distance to border for auto scroll. */ +const sal_Int32 CSV_SCROLL_DIST = 3; + +//! TODO make string array dynamic +const sal_Int32 CSV_PREVIEW_LINES = 32; // maximum count of preview lines +/** Maximum count of columns. */ +const sal_Int32 CSV_MAXCOLCOUNT = MAXCOLCOUNT; + +/** Default column data type. */ +const sal_Int32 CSV_TYPE_DEFAULT = 0; +/** Multi selection with different types. */ +const sal_Int32 CSV_TYPE_MULTI = -1; +/** No column selected. */ +const sal_Int32 CSV_TYPE_NOSELECTION = -2; + +// External used column types. +const sal_uInt8 SC_COL_STANDARD = 1; +const sal_uInt8 SC_COL_TEXT = 2; +const sal_uInt8 SC_COL_MDY = 3; +const sal_uInt8 SC_COL_DMY = 4; +const sal_uInt8 SC_COL_YMD = 5; +const sal_uInt8 SC_COL_SKIP = 9; +const sal_uInt8 SC_COL_ENGLISH = 10; + +/** Exported data of a column (data used in the dialog). */ +struct ScCsvExpData +{ + sal_Int32 mnIndex; /// Index of a column. + sal_uInt8 mnType; /// External type of the column. + + ScCsvExpData() : mnIndex( 0 ), mnType( SC_COL_STANDARD ) {} + ScCsvExpData( sal_Int32 nIndex, sal_uInt8 nType ) : + mnIndex( nIndex ), mnType( nType ) {} +}; + +typedef ::std::vector< ScCsvExpData > ScCsvExpDataVec; + +/** Specifies which element should be used to perform an action. */ +enum ScMoveMode +{ + MOVE_NONE, /// No action. + MOVE_FIRST, /// First element in current context. + MOVE_LAST, /// Last element in current context. + MOVE_PREV, /// Predecessor of current element in current context. + MOVE_NEXT, /// Successor of current element in current context. + MOVE_PREVPAGE, /// Previous page relative to current context. + MOVE_NEXTPAGE /// Next page relative to current context. +}; + +/** Flags for comparison of old and new control layout data. */ +enum class ScCsvDiff : sal_uInt32 { + Equal = 0x0000, + PosCount = 0x0001, + PosOffset = 0x0002, + HeaderWidth = 0x0004, + CharWidth = 0x0008, + LineCount = 0x0010, + LineOffset = 0x0020, + HeaderHeight = 0x0040, + LineHeight = 0x0080, + RulerCursor = 0x0100, + GridCursor = 0x0200, + + HorizontalMask = PosCount | PosOffset | HeaderWidth | CharWidth, + VerticalMask = LineCount | LineOffset | HeaderHeight | LineHeight +}; +namespace o3tl { + template<> struct typed_flags<ScCsvDiff> : is_typed_flags<ScCsvDiff, 0x03ff> {}; +} + + +/** A structure containing all layout data valid for both ruler and data grid + (i.e. scroll position or column width). */ +struct ScCsvLayoutData +{ + // horizontal settings + sal_Int32 mnPosCount; /// Number of positions. + sal_Int32 mnPosOffset; /// Horizontal scroll offset. + + sal_Int32 mnWinWidth; /// Width of ruler and data grid. + sal_Int32 mnHdrWidth; /// Width of the header column. + sal_Int32 mnCharWidth; /// Pixel width of one character. + + // vertical settings + sal_Int32 mnLineCount; /// Number of data lines. + sal_Int32 mnLineOffset; /// Index of first visible line (0-based). + + sal_Int32 mnWinHeight; /// Height of entire data grid (incl. header). + sal_Int32 mnHdrHeight; /// Height of the header line. + sal_Int32 mnLineHeight; /// Height of a data line. + + // cursor settings + sal_Int32 mnPosCursor; /// Position of ruler cursor. + sal_Int32 mnColCursor; /// Position of grid column cursor. + + mutable sal_Int32 mnNoRepaint; /// >0 = no repaint. + bool mbAppRTL; /// true = application in RTL mode. + + explicit ScCsvLayoutData(); + + /** Returns differences to rData. + @descr For each difference the appropriate bit is set in the returned value. */ + ScCsvDiff GetDiff( const ScCsvLayoutData& rData ) const; +}; + +inline bool operator==( const ScCsvLayoutData& rData1, const ScCsvLayoutData& rData2 ) +{ + return rData1.GetDiff( rData2 ) == ScCsvDiff::Equal; +} + +inline bool operator!=( const ScCsvLayoutData& rData1, const ScCsvLayoutData& rData2 ) +{ + return !(rData1 == rData2); +} + +/** Enumeration of possible commands to change any settings of the CSV controls. + @descr Controls have to send commands instead of changing their settings directly. + This helps to keep the different controls consistent to each other. + A command can contain 0 to 2 sal_Int32 parameters. In the description of each + command the required parameters are shown in brackets. [-] means no parameter. */ +enum ScCsvCmdType +{ + // misc + CSVCMD_NONE, /// No command. [-] + CSVCMD_REPAINT, /// Repaint all controls. [-] + + // modify horizontal dimensions + CSVCMD_SETPOSCOUNT, /// Change position/column count. [character count] + CSVCMD_SETPOSOFFSET, /// Change position offset (scroll pos). [position] + CSVCMD_SETHDRWIDTH, /// Change width of the header column. [width in pixel] + CSVCMD_SETCHARWIDTH, /// Change character pixel width. [width in pixel] + + // modify vertical dimensions + CSVCMD_SETLINECOUNT, /// Change number of data lines. [line count] + CSVCMD_SETLINEOFFSET, /// Change first visible line. [line index] + CSVCMD_SETHDRHEIGHT, /// Change height of top header line. [height in pixel] + CSVCMD_SETLINEHEIGHT, /// Change data line pixel height. [height in pixel} + + // cursors/positions + CSVCMD_MOVERULERCURSOR, /// Move ruler cursor to new position. [position] + CSVCMD_MOVEGRIDCURSOR, /// Move data grid cursor to new column. [position] + CSVCMD_MAKEPOSVISIBLE, /// Move to make passed position visible (for mouse tracking). [position] + + // table contents + CSVCMD_NEWCELLTEXTS, /// Recalculate splits and cell texts. [-] + CSVCMD_UPDATECELLTEXTS, /// Update cell texts with current split settings. [-] + CSVCMD_SETCOLUMNTYPE, /// Change data type of selected columns. [column type] + CSVCMD_EXPORTCOLUMNTYPE, /// Send selected column type to external controls. [-] + CSVCMD_SETFIRSTIMPORTLINE, /// Set number of first imported line. [line index] + + // splits + CSVCMD_INSERTSPLIT, /// Insert a split. [position] + CSVCMD_REMOVESPLIT, /// Remove a split. [position] + CSVCMD_TOGGLESPLIT, /// Inserts or removes a split. [position] + CSVCMD_MOVESPLIT, /// Move a split. [old position, new position] + CSVCMD_REMOVEALLSPLITS /// Remove all splits. [-] +}; + +/** Data for a CSV control command. The stored position data is always character based, + it's never a column index (required for internal consistency). */ +class ScCsvCmd +{ +private: + ScCsvCmdType meType; /// The command. + sal_Int32 mnParam1; /// First parameter. + sal_Int32 mnParam2; /// Second parameter. + +public: + explicit ScCsvCmd() : meType( CSVCMD_NONE ), + mnParam1( CSV_POS_INVALID ), mnParam2( CSV_POS_INVALID ) {} + + inline void Set( ScCsvCmdType eType, sal_Int32 nParam1, sal_Int32 nParam2 ); + + ScCsvCmdType GetType() const { return meType; } + sal_Int32 GetParam1() const { return mnParam1; } + sal_Int32 GetParam2() const { return mnParam2; } +}; + +inline void ScCsvCmd::Set( ScCsvCmdType eType, sal_Int32 nParam1, sal_Int32 nParam2 ) +{ + meType = eType; mnParam1 = nParam1; mnParam2 = nParam2; +} + +/** Base class for the CSV ruler and the data grid control. Implements command handling. */ +class SC_DLLPUBLIC ScCsvControl : public weld::CustomWidgetController +{ +private: + Link<ScCsvControl&,void> maCmdHdl; /// External command handler. + ScCsvCmd maCmd; /// Data of last command. + const ScCsvLayoutData& mrData; /// Shared layout data. + + bool mbValidGfx; /// Content of virtual devices valid? + +protected: + rtl::Reference<ScAccessibleCsvControl> mxAccessible; /// Reference to the accessible implementation object. + +public: + explicit ScCsvControl(const ScCsvLayoutData& rData); + virtual ~ScCsvControl() override; + + // event handling --------------------------------------------------------- + + virtual void GetFocus() override; + virtual void LoseFocus() override; + + /** Sends a GetFocus or LoseFocus event to the accessibility object. */ + void AccSendFocusEvent( bool bFocused ); + /** Sends a caret changed event to the accessibility object. */ + void AccSendCaretEvent(); + /** Sends a visible area changed event to the accessibility object. */ + void AccSendVisibleEvent(); + /** Sends a selection changed event to the accessibility object. */ + void AccSendSelectionEvent(); + /** Sends a table model changed event for changed cell contents to the accessibility object. */ + void AccSendTableUpdateEvent( sal_uInt32 nFirstColumn, sal_uInt32 nLastColumn, bool bAllRows = true ); + /** Sends a table model changed event for an inserted column to the accessibility object. */ + void AccSendInsertColumnEvent( sal_uInt32 nFirstColumn, sal_uInt32 nLastColumn ); + /** Sends a table model changed event for a removed column to the accessibility object. */ + void AccSendRemoveColumnEvent( sal_uInt32 nFirstColumn, sal_uInt32 nLastColumn ); + + ScAccessibleCsvControl* GetAccessible() { return mxAccessible.get(); } + + // repaint helpers -------------------------------------------------------- + + /** Sets the graphic invalid (next Redraw() will not use cached graphic). */ + void InvalidateGfx() { mbValidGfx = false; } + /** Sets the graphic valid (next Redraw() will use cached graphic). */ + void ValidateGfx() { mbValidGfx = true; } + /** Returns true, if cached graphic is valid. */ + bool IsValidGfx() const { return mbValidGfx; } + + /** Repaints all controls. + @param bInvalidate true = invalidates graphics of this control (not all). */ + void Repaint( bool bInvalidate = false ); + /** Increases no-repaint counter (controls do not repaint until the last EnableRepaint()). */ + void DisableRepaint(); + /** Decreases no-repaint counter and repaints if counter reaches 0. */ + void EnableRepaint(); + /** Returns true, if controls will not repaint. */ + bool IsNoRepaint() const { return mrData.mnNoRepaint > 0; } + + // command handling ------------------------------------------------------- + + /** Sets a new command handler. */ + void SetCmdHdl( const Link<ScCsvControl&,void>& rHdl ) { maCmdHdl = rHdl; } + /** Returns data of the last command. */ + const ScCsvCmd& GetCmd() const { return maCmd; } + + /** Executes a command by calling command handler. */ + void Execute( + ScCsvCmdType eType, + sal_Int32 nParam1 = CSV_POS_INVALID, + sal_Int32 nParam2 = CSV_POS_INVALID ); + + // layout helpers --------------------------------------------------------- + + /** Returns a reference to the current layout data. */ + const ScCsvLayoutData& GetLayoutData() const { return mrData; } + /** Returns true, if the Right-to-Left layout mode is active. */ + bool IsRTL() const { return mrData.mbAppRTL; } + + /** Returns the number of available positions. */ + sal_Int32 GetPosCount() const { return mrData.mnPosCount; } + /** Returns the number of visible positions. */ + sal_Int32 GetVisPosCount() const; + /** Returns the first visible position. */ + sal_Int32 GetFirstVisPos() const { return mrData.mnPosOffset; } + /** Returns the last visible position. */ + sal_Int32 GetLastVisPos() const { return GetFirstVisPos() + GetVisPosCount(); } + /** Returns highest possible position for first visible character. */ + sal_Int32 GetMaxPosOffset() const; + + /** Returns true, if it is allowed to set a split at nPos. */ + bool IsValidSplitPos( sal_Int32 nPos ) const; + /** Returns true, if nPos is an allowed AND visible split position. */ + bool IsVisibleSplitPos( sal_Int32 nPos ) const; + + /** Returns the width of the header column. */ + sal_Int32 GetHdrWidth() const { return mrData.mnHdrWidth; } + /** Returns the width of one character column. */ + sal_Int32 GetCharWidth() const { return mrData.mnCharWidth; } + /** Returns the start position of the header column. */ + sal_Int32 GetHdrX() const; + /** Returns the X position of the first pixel of the data area. */ + sal_Int32 GetFirstX() const; + /** Returns the X position of the last pixel of the data area. */ + sal_Int32 GetLastX() const; + /** Returns output X coordinate of the specified position. */ + sal_Int32 GetX( sal_Int32 nPos ) const; + /** Returns position from output coordinate. */ + sal_Int32 GetPosFromX( sal_Int32 nX ) const; + + /** Returns the number of data lines. */ + sal_Int32 GetLineCount() const { return mrData.mnLineCount; } + /** Returns the number of visible lines (including partly visible bottom line). */ + sal_Int32 GetVisLineCount() const; + /** Returns index of first visible line. */ + sal_Int32 GetFirstVisLine() const { return mrData.mnLineOffset; } + /** Returns index of last visible line. */ + sal_Int32 GetLastVisLine() const; + /** Returns highest possible index for first line. */ + sal_Int32 GetMaxLineOffset() const; + + /** Returns true, if nLine is a valid line index. */ + bool IsValidLine( sal_Int32 nLine ) const; + /** Returns true, if nLine is a valid and visible line index. */ + bool IsVisibleLine( sal_Int32 nLine ) const; + + /** Returns the height of the header line. */ + sal_Int32 GetHdrHeight() const { return mrData.mnHdrHeight; } + /** Returns the height of one line. */ + sal_Int32 GetLineHeight() const { return mrData.mnLineHeight; } + /** Returns output Y coordinate of the specified line. */ + sal_Int32 GetY( sal_Int32 nLine ) const; + /** Returns line index from output coordinate. */ + sal_Int32 GetLineFromY( sal_Int32 nY ) const; + + /** Returns the ruler cursor position. */ + sal_Int32 GetRulerCursorPos() const { return mrData.mnPosCursor; } + /** Returns the data grid cursor position (not column index!). */ + sal_Int32 GetGridCursorPos() const { return mrData.mnColCursor; } + + // static helpers --------------------------------------------------------- + + /** Inverts a rectangle in the specified output device. */ + static void ImplInvertRect( OutputDevice& rOutDev, const tools::Rectangle& rRect ); + + /** Returns direction code for the keys LEFT, RIGHT, HOME, END. + @param bHomeEnd false = ignore HOME and END key. */ + static ScMoveMode GetHorzDirection( sal_uInt16 nCode, bool bHomeEnd ); + /** Returns direction code for the keys UP, DOWN, HOME, END, PAGE UP, PAGE DOWN. + @param bHomeEnd false = ignore HOME and END key. */ + static ScMoveMode GetVertDirection( sal_uInt16 nCode, bool bHomeEnd ); +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/csvgrid.hxx b/sc/source/ui/inc/csvgrid.hxx new file mode 100644 index 000000000..84a0b6cb8 --- /dev/null +++ b/sc/source/ui/inc/csvgrid.hxx @@ -0,0 +1,319 @@ +/* -*- 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_SC_SOURCE_UI_INC_CSVGRID_HXX +#define INCLUDED_SC_SOURCE_UI_INC_CSVGRID_HXX + +#include <vcl/virdev.hxx> +#include <unotools/options.hxx> + +#include <vector> +#include <memory> +#include <scdllapi.h> +#include <editutil.hxx> +#include "csvcontrol.hxx" +#include "csvsplits.hxx" + +namespace svtools { class ColorConfig; } +class EditEngine; +class ScAsciiOptions; +class ScAccessibleCsvControl; +class ScCsvTableBox; + +const sal_uInt32 CSV_COLUMN_INVALID = CSV_VEC_NOTFOUND; + +/** This struct contains the state of one table column. */ +struct ScCsvColState +{ + sal_Int32 mnType; /// Data type. + bool mbColumnSelected; + + explicit ScCsvColState( sal_Int32 nType = CSV_TYPE_DEFAULT ) : + mnType( nType ), mbColumnSelected( false ) {} + + bool IsSelected() const { return mbColumnSelected; } + void Select( bool bSel ) { mbColumnSelected = bSel; } +}; + +typedef ::std::vector< ScCsvColState > ScCsvColStateVec; + +/** A data grid control for the CSV import dialog. The design of this control + simulates a Calc spreadsheet with row and column headers. */ +class SC_DLLPUBLIC ScCsvGrid : public ScCsvControl, public utl::ConfigurationListener +{ +private: + typedef ::std::unique_ptr< ScEditEngineDefaulter > ScEditEnginePtr; + + ScCsvTableBox* mpTableBox; /// Grid Parent + VclPtr<VirtualDevice> mpBackgrDev; /// Grid background, headers, cell texts. + VclPtr<VirtualDevice> mpGridDev; /// Data grid with selection and cursor. + std::unique_ptr<weld::Menu> mxPopup; /// Popup menu for column types. + + ::svtools::ColorConfig* mpColorConfig; /// Application color configuration. + Color maBackColor; /// Cell background color. + Color maGridColor; /// Table grid color. + Color maGridPBColor; /// Grid color for "first imported line" delimiter. + Color maAppBackColor; /// Background color for unused area. + Color maTextColor; /// Text color for data area. + Color maHeaderBackColor; /// Background color for headers. + Color maHeaderGridColor; /// Grid color for headers. + Color maHeaderTextColor; /// Text color for headers. + Color maSelectColor; /// Header color of selected columns. + + ScEditEnginePtr mpEditEngine; /// For drawing cell texts. + vcl::Font maHeaderFont; /// Font for column and row headers. + vcl::Font maMonoFont; /// Monospace font for data cells. + Size maWinSize; /// Size of the control. + Size maEdEngSize; /// Paper size for edit engine. + + ScCsvSplits maSplits; /// Vector with split positions. + ScCsvColStateVec maColStates; /// State of each column. + std::vector<OUString> maTypeNames; /// UI names of data types. + std::vector< std::vector<OUString> > maTexts; /// 2D-vector for cell texts. + + sal_Int32 mnFirstImpLine; /// First imported line (0-based). + sal_uInt32 mnRecentSelCol; /// Index of most recently selected column. + sal_uInt32 mnMTCurrCol; /// Current column of mouse tracking. + bool mbTracking; /// True if Mouse tracking + bool mbMTSelecting; /// Mouse tracking mode: true = select, false = deselect. + +public: + explicit ScCsvGrid(const ScCsvLayoutData& rData, std::unique_ptr<weld::Menu> xPopup, ScCsvTableBox* pTableBox); + virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override; + ScCsvTableBox* GetTableBox() { return mpTableBox; } + virtual ~ScCsvGrid() override; + + /** Finishes initialization. Must be called after constructing a new object. */ + void Init(); + + // common grid handling --------------------------------------------------- +public: + /** Updates layout data dependent from the control's state. */ + void UpdateLayoutData(); + /** Updates X coordinate of first visible position dependent from line numbers. */ + void UpdateOffsetX(); + /** Apply current layout data to the grid control. */ + void ApplyLayout( const ScCsvLayoutData& rOldData ); + /** Sets the number of the first imported line (for visual feedback). nLine is 0-based! */ + void SetFirstImportedLine( sal_Int32 nLine ); + + /** Finds a column position nearest to nPos which does not cause scrolling the visible area. */ + sal_Int32 GetNoScrollCol( sal_Int32 nPos ) const; + +private: + /** Reads colors from system settings. */ + SAL_DLLPRIVATE void InitColors(); + /** Initializes all font settings. */ + SAL_DLLPRIVATE void InitFonts(); + /** Initializes all data dependent from the control's size. */ + SAL_DLLPRIVATE void InitSizeData(); + + // split handling --------------------------------------------------------- +public: + /** Inserts a split. */ + void InsertSplit( sal_Int32 nPos ); + /** Removes a split. */ + void RemoveSplit( sal_Int32 nPos ); + /** Inserts a new or removes an existing split. */ + void MoveSplit( sal_Int32 nPos, sal_Int32 nNewPos ); + /** Removes all splits. */ + void RemoveAllSplits(); + /** Removes all splits and inserts the splits from rSplits. */ + void SetSplits( const ScCsvSplits& rSplits ); + +private: + /** Inserts a split and adjusts column data. */ + SAL_DLLPRIVATE bool ImplInsertSplit( sal_Int32 nPos ); + /** Removes a split and adjusts column data. */ + SAL_DLLPRIVATE bool ImplRemoveSplit( sal_Int32 nPos ); + /** Clears the split array and re-inserts boundary splits. */ + SAL_DLLPRIVATE void ImplClearSplits(); + + // columns/column types --------------------------------------------------- +public: + /** Returns the number of columns. */ + sal_uInt32 GetColumnCount() const { return maColStates.size(); } + /** Returns the index of the first visible column. */ + sal_uInt32 GetFirstVisColumn() const; + /** Returns the index of the last visible column. */ + sal_uInt32 GetLastVisColumn() const; + + /** Returns true, if nColIndex points to an existing column. */ + bool IsValidColumn( sal_uInt32 nColIndex ) const; + /** Returns true, if column with index nColIndex is (at least partly) visible. */ + bool IsVisibleColumn( sal_uInt32 nColIndex ) const; + + /** Returns X coordinate of the specified column. */ + sal_Int32 GetColumnX( sal_uInt32 nColIndex ) const; + /** Returns column index from output coordinate. */ + sal_uInt32 GetColumnFromX( sal_Int32 nX ) const; + + /** Returns start position of the column with the specified index. */ + sal_Int32 GetColumnPos( sal_uInt32 nColIndex ) const { return maSplits[ nColIndex ]; } + /** Returns column index from position. A split counts to its following column. */ + sal_uInt32 GetColumnFromPos( sal_Int32 nPos ) const; + /** Returns the character width of the column with the specified index. */ + sal_Int32 GetColumnWidth( sal_uInt32 nColIndex ) const; + + /** Returns the vector with the states of all columns. */ + const ScCsvColStateVec& GetColumnStates() const { return maColStates; } + /** Sets all column states to the values in the passed vector. */ + void SetColumnStates( const ScCsvColStateVec& rColStates ); + /** Returns the data type of the selected columns. */ + sal_Int32 GetSelColumnType() const; + /** Changes the data type of all selected columns. */ + void SetSelColumnType( sal_Int32 nType ); + /** Sets new UI data type names. */ + void SetTypeNames( const std::vector<OUString>& rTypeNames ); + /** Returns the UI type name of the specified column. */ + const OUString& GetColumnTypeName( sal_uInt32 nColIndex ) const; + + /** Fills the options object with column data for separators mode. */ + void FillColumnDataSep( ScAsciiOptions& rOptions ) const; + /** Fills the options object with column data for fixed width mode. */ + void FillColumnDataFix( ScAsciiOptions& rOptions ) const; + +private: + /** Returns the data type of the specified column. */ + SAL_DLLPRIVATE sal_Int32 GetColumnType( sal_uInt32 nColIndex ) const; + /** Sets the data type of the specified column. */ + SAL_DLLPRIVATE void SetColumnType( sal_uInt32 nColIndex, sal_Int32 nColType ); + + /** Scrolls data grid vertically. */ + SAL_DLLPRIVATE void ScrollVertRel( ScMoveMode eDir ); + /** Executes the data type popup menu. */ + SAL_DLLPRIVATE void ExecutePopup( const Point& rPos ); + + // selection handling ----------------------------------------------------- +public: + /** Returns true, if the specified column is selected. */ + bool IsSelected( sal_uInt32 nColIndex ) const; + /** Returns index of the first selected column. */ + sal_uInt32 GetFirstSelected() const; + /** Returns index of the first selected column really after nFromIndex. */ + sal_uInt32 GetNextSelected( sal_uInt32 nFromIndex ) const; + /** Selects or deselects the specified column. */ + void Select( sal_uInt32 nColIndex, bool bSelect = true ); + /** Toggles selection of the specified column. */ + void ToggleSelect( sal_uInt32 nColIndex ); + /** Selects or deselects the specified column range. */ + void SelectRange( sal_uInt32 nColIndex1, sal_uInt32 nColIndex2, bool bSelect = true ); + /** Selects or deselects all columns. */ + void SelectAll( bool bSelect = true ); + + /** Returns index of the focused column. */ + sal_uInt32 GetFocusColumn() const { return GetColumnFromPos( GetGridCursorPos() ); } + +private: + /** Moves column cursor to a new position. */ + SAL_DLLPRIVATE void MoveCursor( sal_uInt32 nColIndex ); + /** Moves column cursor to the given direction. */ + SAL_DLLPRIVATE void MoveCursorRel( ScMoveMode eDir ); + + /** Clears the entire selection without notify. */ + SAL_DLLPRIVATE void ImplClearSelection(); + + /** Executes selection action for a specific column. */ + SAL_DLLPRIVATE void DoSelectAction( sal_uInt32 nColIndex, sal_uInt16 nModifier ); + + // cell contents ---------------------------------------------------------- +public: + /** Fills all cells of a line with the passed text (separators mode). */ + void ImplSetTextLineSep( + sal_Int32 nLine, const OUString& rTextLine, + const OUString& rSepChars, sal_Unicode cTextSep, bool bMergeSep, bool bRemoveSpace = false ); + /** Fills all cells of a line with the passed text (fixed width mode). */ + void ImplSetTextLineFix( sal_Int32 nLine, const OUString& rTextLine ); + + /** Returns the text of the specified cell. */ + const OUString& GetCellText( sal_uInt32 nColIndex, sal_Int32 nLine ) const; + + // event handling --------------------------------------------------------- +protected: + virtual void Resize() override; + virtual void GetFocus() override; + virtual void LoseFocus() override; + + virtual bool MouseButtonDown( const MouseEvent& rMEvt ) override; + virtual bool MouseMove( const MouseEvent& rMEvt ) override; + virtual bool MouseButtonUp( const MouseEvent& rMEvt ) override; + virtual bool KeyInput( const KeyEvent& rKEvt ) override; + virtual bool Command( const CommandEvent& rCEvt ) override; + + virtual tools::Rectangle GetFocusRect() override; + + virtual void StyleUpdated() override; + + virtual void ConfigurationChanged( ::utl::ConfigurationBroadcaster*, ConfigurationHints ) override; + + // painting --------------------------------------------------------------- +protected: + virtual void Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& ) override; + +public: + /** Redraws the entire data grid. */ + void ImplRedraw(vcl::RenderContext& rRenderContext); + /** Returns a pointer to the used edit engine. */ + EditEngine* GetEditEngine(); + +private: + /** Returns the width of the control. */ + sal_Int32 GetWidth() const { return maWinSize.Width(); } + /** Returns the height of the control. */ + sal_Int32 GetHeight() const { return maWinSize.Height(); } + + /** Sets a clip region in the specified output device for the specified column. */ + SAL_DLLPRIVATE void ImplSetColumnClipRegion( OutputDevice& rOutDev, sal_uInt32 nColIndex ); + /** Draws the header of the specified column to the specified output device. */ + SAL_DLLPRIVATE void ImplDrawColumnHeader( OutputDevice& rOutDev, sal_uInt32 nColIndex, Color aFillColor ); + + /** Draws the text at the specified position to maBackgrDev. */ + SAL_DLLPRIVATE void ImplDrawCellText( const Point& rPos, const OUString& rText ); + /** Draws the "first imported line" separator to maBackgrDev (or erases, if bSet is false). */ + SAL_DLLPRIVATE void ImplDrawFirstLineSep( bool bSet ); + /** Draws the column with index nColIndex to maBackgrDev. */ + SAL_DLLPRIVATE void ImplDrawColumnBackgr( sal_uInt32 nColIndex ); + /** Draws the row headers column to maBackgrDev. */ + SAL_DLLPRIVATE void ImplDrawRowHeaders(); + /** Draws all columns and the row headers column to maBackgrDev. */ + SAL_DLLPRIVATE void ImplDrawBackgrDev(); + + /** Draws the column with index nColIndex with its selection state to maGridDev. */ + SAL_DLLPRIVATE void ImplDrawColumnSelection( sal_uInt32 nColIndex ); + /** Draws all columns with selection and cursor to maGridDev. */ + SAL_DLLPRIVATE void ImplDrawGridDev(); + + /** Redraws the entire column (background and selection). */ + SAL_DLLPRIVATE void ImplDrawColumn( sal_uInt32 nColIndex ); + + /** Optimized drawing: Scrolls horizontally and redraws only missing parts. */ + SAL_DLLPRIVATE void ImplDrawHorzScrolled( sal_Int32 nOldPos ); + + /** Inverts the cursor bar at the specified position in maGridDev. */ + SAL_DLLPRIVATE void ImplInvertCursor( sal_Int32 nPos ); + + // accessibility ---------------------------------------------------------- +protected: + /** Creates a new accessible object. */ + virtual css::uno::Reference<css::accessibility::XAccessible> CreateAccessible() override; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/csvruler.hxx b/sc/source/ui/inc/csvruler.hxx new file mode 100644 index 000000000..0913ac092 --- /dev/null +++ b/sc/source/ui/inc/csvruler.hxx @@ -0,0 +1,185 @@ +/* -*- 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_SC_SOURCE_UI_INC_CSVRULER_HXX +#define INCLUDED_SC_SOURCE_UI_INC_CSVRULER_HXX + +#include "csvcontrol.hxx" +#include "csvsplits.hxx" +#include <scdllapi.h> + +#include <vcl/virdev.hxx> + +class ScAccessibleCsvControl; +class ScCsvTableBox; + +/** A ruler control for the CSV import dialog. Supports setting and moving + splits (which divide lines of data into several columns). */ +class ScCsvRuler : public ScCsvControl +{ +private: + ScCsvTableBox* mpTableBox; /// Grid Parent + + ScopedVclPtrInstance<VirtualDevice> maBackgrDev;/// Ruler background, scaling. + ScopedVclPtrInstance<VirtualDevice> maRulerDev; /// Ruler with splits and cursor. + + Color maBackColor; /// Background color. + Color maActiveColor; /// Color for active part of ruler. + Color maTextColor; /// Text and scale color. + Color maSplitColor; /// Split area color. + + ScCsvSplits maSplits; /// Vector with split positions. + ScCsvSplits maOldSplits; /// Old state for cancellation. + + sal_Int32 mnPosCursorLast; /// Last valid position of cursor. + sal_Int32 mnPosMTStart; /// Start position of mouse tracking. + sal_Int32 mnPosMTCurr; /// Current position of mouse tracking. + bool mbPosMTMoved; /// Tracking: Anytime moved to another position? + + Size maWinSize; /// Size of the control. + tools::Rectangle maActiveRect; /// The active area of the ruler. + sal_Int32 mnSplitSize; /// Size of a split circle. + bool mbTracking; /// If currently mouse tracking + +public: + explicit ScCsvRuler(ScCsvLayoutData& rData, ScCsvTableBox* pTableBox); + virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override; + ScCsvTableBox* GetTableBox() { return mpTableBox; } + virtual ~ScCsvRuler() override; + + // common ruler handling -------------------------------------------------- +public: + /** Apply current layout data to the ruler. */ + void ApplyLayout( const ScCsvLayoutData& rOldData ); + +private: + /** Reads colors from system settings. */ + void InitColors(); + /** Initializes all data dependent from the control's size. */ + void InitSizeData(); + + /** Moves cursor to a new position. + @param bScroll sal_True = The method may scroll the ruler. */ + void MoveCursor( sal_Int32 nPos, bool bScroll = true ); + /** Moves cursor to the given direction. */ + void MoveCursorRel( ScMoveMode eDir ); + /** Sets cursor to an existing split, according to eDir. */ + void MoveCursorToSplit( ScMoveMode eDir ); + /** Scrolls data grid vertically. */ + void ScrollVertRel( ScMoveMode eDir ); + + // split handling --------------------------------------------------------- +public: + /** Returns the split array. */ + const ScCsvSplits& GetSplits() const { return maSplits; } + /** Returns the number of splits. */ + sal_uInt32 GetSplitCount() const + { return maSplits.Count(); } + /** Returns the position of the specified split. */ + sal_Int32 GetSplitPos( sal_uInt32 nIndex ) const + { return maSplits[ nIndex ]; } + /** Finds a position nearest to nPos which does not cause scrolling the visible area. */ + sal_Int32 GetNoScrollPos( sal_Int32 nPos ) const; + + /** Returns true if at position nPos is a split. */ + bool HasSplit( sal_Int32 nPos ) const { return maSplits.HasSplit( nPos ); } + /** Inserts a split. */ + void InsertSplit( sal_Int32 nPos ); + /** Removes a split. */ + void RemoveSplit( sal_Int32 nPos ); + /** Moves a split from nPos to nNewPos. */ + void MoveSplit( sal_Int32 nPos, sal_Int32 nNewPos ); + /** Removes all splits of the ruler. */ + void RemoveAllSplits(); + +private: + /** Finds next position without a split. */ + sal_Int32 FindEmptyPos( sal_Int32 nPos, ScMoveMode eDir ) const; + + /** Moves split and cursor to nNewPos and commits event. */ + void MoveCurrSplit( sal_Int32 nNewPos ); + /** Moves split and cursor to the given direction and commits event. */ + void MoveCurrSplitRel( ScMoveMode eDir ); + + // event handling --------------------------------------------------------- +protected: + virtual void Resize() override; + virtual void GetFocus() override; + virtual void LoseFocus() override; + virtual void StyleUpdated() override; + + virtual bool MouseButtonDown( const MouseEvent& rMEvt ) override; + virtual bool MouseMove( const MouseEvent& rMEvt ) override; + virtual bool MouseButtonUp( const MouseEvent& rMEvt ) override; + + virtual bool KeyInput( const KeyEvent& rKEvt ) override; + + virtual tools::Rectangle GetFocusRect() override; + +private: + /** Starts tracking at the specified position. */ + void StartMouseTracking( sal_Int32 nPos ); + /** Moves tracking to a new position. */ + void MoveMouseTracking( sal_Int32 nPos ); + /** Applies tracking action for the current tracking position */ + void EndMouseTracking(); + + // painting --------------------------------------------------------------- +protected: + virtual void Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& ) override; + +public: + /** Redraws the entire ruler. */ + void ImplRedraw(vcl::RenderContext& rRenderContext); + +private: + /** Returns the width of the control. */ + sal_Int32 GetWidth() const { return maWinSize.Width(); } + /** Returns the height of the control. */ + sal_Int32 GetHeight() const { return maWinSize.Height(); } + /** Update the split size depending on the last width set by CSVCMD_SETCHARWIDTH */ + void UpdateSplitSize(); + + /** Draws the background and active area to maBackgrDev (only the given X range). */ + void ImplDrawArea( sal_Int32 nPosX, sal_Int32 nWidth ); + /** Draws the entire ruler background with scaling to maBackgrDev. */ + void ImplDrawBackgrDev(); + + /** Draws a split to maRulerDev. */ + void ImplDrawSplit( sal_Int32 nPos ); + /** Erases a split from maRulerDev. */ + void ImplEraseSplit( sal_Int32 nPos ); + /** Draws the ruler background, all splits and the cursor to maRulerDev. */ + void ImplDrawRulerDev(); + + /** Inverts the cursor bar at the specified position in maRulerDev. */ + void ImplInvertCursor( sal_Int32 nPos ); + + /** Sets arrow or horizontal split pointer. */ + void ImplSetMousePointer( sal_Int32 nPos ); + + // accessibility ---------------------------------------------------------- +protected: + /** Creates a new accessible object. */ + virtual css::uno::Reference<css::accessibility::XAccessible> CreateAccessible() override; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/csvsplits.hxx b/sc/source/ui/inc/csvsplits.hxx new file mode 100644 index 000000000..4b67f9607 --- /dev/null +++ b/sc/source/ui/inc/csvsplits.hxx @@ -0,0 +1,84 @@ +/* -*- 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_SC_SOURCE_UI_INC_CSVSPLITS_HXX +#define INCLUDED_SC_SOURCE_UI_INC_CSVSPLITS_HXX + +#include <sal/types.h> + +#include <vector> + +/** Constant for an invalid vector index. */ +const sal_uInt32 CSV_VEC_NOTFOUND = SAL_MAX_UINT32; +/** Constant for an invalid ruler position. */ +const sal_Int32 CSV_POS_INVALID = -1; + +/** A vector of column splits that supports inserting, removing and moving splits. */ +class ScCsvSplits +{ +private: + typedef ::std::vector< sal_Int32 > ScSplitVector; + typedef ScSplitVector::const_iterator const_iterator; + + ScSplitVector maVec; /// The split container. + +public: + // *** access by position *** --------------------------------------------- + + /** Inserts a new split at position nPos into the vector. + @return true = split inserted (nPos was valid and empty). */ + bool Insert( sal_Int32 nPos ); + /** Removes a split by position. + @return true = split found and removed. */ + bool Remove( sal_Int32 nPos ); + /** Removes a range of splits in the given position range. */ + void RemoveRange( sal_Int32 nPosStart, sal_Int32 nPosEnd ); + /** Removes all elements from the vector. */ + void Clear(); + + /** Returns true if at position nPos is a split. */ + bool HasSplit( sal_Int32 nPos ) const; + + // *** access by index *** ------------------------------------------------ + + /** Searches for a split at position nPos. + @return the vector index of the split. */ + sal_uInt32 GetIndex( sal_Int32 nPos ) const; + /** Returns index of the first split greater than or equal to nPos. */ + sal_uInt32 LowerBound( sal_Int32 nPos ) const; + /** Returns index of the last split less than or equal to nPos. */ + sal_uInt32 UpperBound( sal_Int32 nPos ) const; + + /** Returns the number of splits. */ + sal_uInt32 Count() const + { return static_cast<sal_uInt32>(maVec.size()); } + /** Returns the position of the specified split. */ + sal_Int32 GetPos( sal_uInt32 nIndex ) const; + /** Returns the position of the specified split. */ + sal_Int32 operator[]( sal_uInt32 nIndex ) const + { return GetPos( nIndex ); } + +private: + /** Returns the vector index of an iterator. */ + sal_uInt32 GetIterIndex( const_iterator const & aIter ) const; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/csvtablebox.hxx b/sc/source/ui/inc/csvtablebox.hxx new file mode 100644 index 000000000..67506f160 --- /dev/null +++ b/sc/source/ui/inc/csvtablebox.hxx @@ -0,0 +1,135 @@ +/* -*- 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_SC_SOURCE_UI_INC_CSVTABLEBOX_HXX +#define INCLUDED_SC_SOURCE_UI_INC_CSVTABLEBOX_HXX + +#include <vcl/idle.hxx> +#include <vcl/weld.hxx> +#include <scdllapi.h> +#include "csvcontrol.hxx" +#include "csvruler.hxx" +#include "csvgrid.hxx" + +class ScAsciiOptions; +namespace weld { + class ComboBox; +} + +/* ============================================================================ +Position: Positions between the characters (the dots in the ruler). +Character: The characters (the range from one position to the next). +Split: Positions which contain a split to divide characters into groups (columns). +Column: The range between two splits. +============================================================================ */ + +/** The control in the CSV import dialog that contains a ruler and a data grid + to visualize and modify the current import settings. */ +class SC_DLLPUBLIC ScCsvTableBox +{ +private: + ScCsvLayoutData maData; /// Current layout data of the controls. + + std::unique_ptr<ScCsvRuler> mxRuler; /// The ruler for fixed width mode. + std::unique_ptr<ScCsvGrid> mxGrid; /// Calc-like data table for fixed width mode. + std::unique_ptr<weld::ScrolledWindow> mxScroll; /// Scrolled Window + std::unique_ptr<weld::CustomWeld> mxRulerWeld; /// Connect the ruler to its drawingarea + std::unique_ptr<weld::CustomWeld> mxGridWeld; /// connect the grid to its drawingarea + + Link<ScCsvTableBox&,void> maUpdateTextHdl; /// Updates all cell texts. + Link<ScCsvTableBox&,void> maColTypeHdl; /// Handler for exporting the column type. + + Idle maEndScrollIdle; /// Called when horizontal scrolling has ended + + ScCsvColStateVec maFixColStates; /// Column states in fixed width mode. + ScCsvColStateVec maSepColStates; /// Column states in separators mode. + + sal_Int32 mnFixedWidth; /// Cached total width for fixed width mode. + + bool mbFixedMode; /// false = Separators, true = Fixed width. + +public: + explicit ScCsvTableBox(weld::Builder& rBuilder); + ~ScCsvTableBox(); + + /** Finishes initialization. Must be called after constructing a new object. */ + void Init(); + + // common table box handling ---------------------------------------------- +public: + /** Sets the control to separators mode. */ + void SetSeparatorsMode(); + /** Sets the control to fixed width mode. */ + void SetFixedWidthMode(); + + ScCsvRuler& GetRuler() { return *mxRuler; } + ScCsvGrid& GetGrid() { return *mxGrid; } + + /** Initializes the children controls (pos/size, scroll bars, ...). */ + SAL_DLLPRIVATE void InitControls(); + +private: + /** Initializes size and position data of horizontal scrollbar. */ + SAL_DLLPRIVATE void InitHScrollBar(); + /** Initializes size and position data of vertical scrollbar. */ + SAL_DLLPRIVATE void InitVScrollBar(); + + /** Calculates and sets valid position offset nearest to nPos. */ + SAL_DLLPRIVATE void ImplSetPosOffset( sal_Int32 nPos ) + { maData.mnPosOffset = std::max( std::min( nPos, mxGrid->GetMaxPosOffset() ), sal_Int32( 0 ) ); } + /** Calculates and sets valid line offset nearest to nLine. */ + SAL_DLLPRIVATE void ImplSetLineOffset( sal_Int32 nLine ) + { maData.mnLineOffset = std::max( std::min( nLine, mxGrid->GetMaxLineOffset() ), sal_Int32( 0 ) ); } + /** Moves controls (not cursors!) so that nPos becomes visible. */ + SAL_DLLPRIVATE void MakePosVisible( sal_Int32 nPos ); + + // cell contents ---------------------------------------------------------- +public: + /** Fills all cells of all lines with the passed texts (Unicode strings). */ + void SetUniStrings( + const OUString* pTextLines, const OUString& rSepChars, + sal_Unicode cTextSep, bool bMergeSep, bool bRemoveSpace ); + + // column settings -------------------------------------------------------- +public: + /** Reads UI strings for data types from the list box. */ + void InitTypes(const weld::ComboBox& rListBox); + /** Returns the data type of the selected columns. */ + sal_Int32 GetSelColumnType() const { return mxGrid->GetSelColumnType(); } + + /** Fills the options object with current column data. */ + void FillColumnData( ScAsciiOptions& rOptions ) const; + + // event handling --------------------------------------------------------- +public: + /** Sets a new handler for "update cell texts" requests. */ + void SetUpdateTextHdl( const Link<ScCsvTableBox&,void>& rHdl ) { maUpdateTextHdl = rHdl; } + /** Sets a new handler for "column selection changed" events. */ + void SetColTypeHdl( const Link<ScCsvTableBox&,void>& rHdl ) { maColTypeHdl = rHdl; } + +private: + DECL_DLLPRIVATE_LINK( CsvCmdHdl, ScCsvControl&, void ); + DECL_DLLPRIVATE_LINK( HScrollHdl, weld::ScrolledWindow&, void ); + DECL_DLLPRIVATE_LINK( VScrollHdl, weld::ScrolledWindow&, void ); + DECL_DLLPRIVATE_LINK( ScrollEndHdl, Timer*, void ); +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/dapidata.hxx b/sc/source/ui/inc/dapidata.hxx new file mode 100644 index 000000000..fbe7cfdc1 --- /dev/null +++ b/sc/source/ui/inc/dapidata.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_SC_SOURCE_UI_INC_DAPIDATA_HXX +#define INCLUDED_SC_SOURCE_UI_INC_DAPIDATA_HXX + +#include <vcl/weld.hxx> + +struct ScImportSourceDesc; + +class ScDataPilotDatabaseDlg : public weld::GenericDialogController +{ +private: + std::unique_ptr<weld::ComboBox> m_xLbDatabase; + std::unique_ptr<weld::ComboBox> m_xCbObject; + std::unique_ptr<weld::ComboBox> m_xLbType; + + void FillObjects(); + + DECL_LINK(SelectHdl, weld::ComboBox&, void); + +public: + ScDataPilotDatabaseDlg(weld::Window* pParent); + virtual ~ScDataPilotDatabaseDlg() override; + + void GetValues(ScImportSourceDesc& rDesc); +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/dapitype.hxx b/sc/source/ui/inc/dapitype.hxx new file mode 100644 index 000000000..2fea18054 --- /dev/null +++ b/sc/source/ui/inc/dapitype.hxx @@ -0,0 +1,69 @@ +/* -*- 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_SC_SOURCE_UI_INC_DAPITYPE_HXX +#define INCLUDED_SC_SOURCE_UI_INC_DAPITYPE_HXX + +#include <vcl/weld.hxx> + +class ScDataPilotSourceTypeDlg : public weld::GenericDialogController +{ +private: + std::unique_ptr<weld::RadioButton> m_xBtnSelection; + std::unique_ptr<weld::RadioButton> m_xBtnNamedRange; + std::unique_ptr<weld::RadioButton> m_xBtnDatabase; + std::unique_ptr<weld::RadioButton> m_xBtnExternal; + std::unique_ptr<weld::ComboBox> m_xLbNamedRange; + +public: + ScDataPilotSourceTypeDlg(weld::Window* pParent, bool bEnableExternal); + virtual ~ScDataPilotSourceTypeDlg() override; + bool IsDatabase() const; + bool IsExternal() const; + bool IsNamedRange() const; + OUString GetSelectedNamedRange() const; + void AppendNamedRange(const OUString& rNames); + +private: + DECL_LINK(RadioClickHdl, weld::ToggleButton&, void); +}; + +class ScDataPilotServiceDlg : public weld::GenericDialogController +{ +private: + std::unique_ptr<weld::ComboBox> m_xLbService; + std::unique_ptr<weld::Entry> m_xEdSource; + std::unique_ptr<weld::Entry> m_xEdName; + std::unique_ptr<weld::Entry> m_xEdUser; + std::unique_ptr<weld::Entry> m_xEdPasswd; + +public: + ScDataPilotServiceDlg(weld::Window* pParent, const std::vector<OUString>& rServices); + virtual ~ScDataPilotServiceDlg() override; + + OUString GetServiceName() const; + OUString GetParSource() const; + OUString GetParName() const; + OUString GetParUser() const; + OUString GetParPass() const; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/datafdlg.hxx b/sc/source/ui/inc/datafdlg.hxx new file mode 100644 index 000000000..c7bd3d0b7 --- /dev/null +++ b/sc/source/ui/inc/datafdlg.hxx @@ -0,0 +1,72 @@ +/* -*- 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_SC_SOURCE_UI_INC_DATAFDLG_HXX +#define INCLUDED_SC_SOURCE_UI_INC_DATAFDLG_HXX + +#include <vcl/weld.hxx> +#include <types.hxx> +#include "viewfunc.hxx" + +class ScTabViewShell; +class ScDocument; + +#define MAX_DATAFORM_COLS 256 +#define MAX_DATAFORM_ROWS 32000 + +class ScDataFormDlg : public weld::GenericDialogController +{ +private: + OUString sNewRecord; + + ScTabViewShell* pTabViewShell; + ScDocument* pDoc; + sal_uInt16 aColLength; + SCROW nCurrentRow; + SCCOL nStartCol; + SCCOL nEndCol; + SCROW nStartRow; + SCROW nEndRow; + SCTAB nTab; + + std::unique_ptr<weld::Button> m_xBtnNew; + std::unique_ptr<weld::Button> m_xBtnDelete; + std::unique_ptr<weld::Button> m_xBtnRestore; + std::unique_ptr<weld::Button> m_xBtnPrev; + std::unique_ptr<weld::Button> m_xBtnNext; + std::unique_ptr<weld::Button> m_xBtnClose; + std::unique_ptr<weld::ScrolledWindow> m_xSlider; + std::unique_ptr<weld::Container> m_xGrid; + std::unique_ptr<weld::Label> m_xFixedText; + std::vector<std::unique_ptr<ScDataFormFragment>> m_aEntries; + +public: + ScDataFormDlg(weld::Window* pParent, ScTabViewShell* pTabViewShell); + virtual ~ScDataFormDlg() override; + + void FillCtrls(); +private: + + void SetButtonState(); + + // Handler: + DECL_LINK(Impl_NewHdl, weld::Button&, void); + DECL_LINK(Impl_PrevHdl, weld::Button&, void); + DECL_LINK(Impl_NextHdl, weld::Button&, void); + + DECL_LINK(Impl_RestoreHdl, weld::Button&, void); + DECL_LINK(Impl_DeleteHdl, weld::Button&, void); + DECL_LINK(Impl_CloseHdl, weld::Button&, void); + + DECL_LINK(Impl_ScrollHdl, weld::ScrolledWindow&, void); + DECL_LINK(Impl_DataModifyHdl, weld::Entry&, void); +}; +#endif // INCLUDED_SC_SOURCE_UI_INC_DATAFDLG_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/dataprovider.hxx b/sc/source/ui/inc/dataprovider.hxx new file mode 100644 index 000000000..a7a5f9b10 --- /dev/null +++ b/sc/source/ui/inc/dataprovider.hxx @@ -0,0 +1,150 @@ +/* -*- 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_SC_SOURCE_UI_INC_DATAPROVIDER_HXX +#define INCLUDED_SC_SOURCE_UI_INC_DATAPROVIDER_HXX + +#include <memory> +#include <salhelper/thread.hxx> +#include <rtl/ustring.hxx> +#include <rtl/ref.hxx> +#include <osl/mutex.hxx> +#include <document.hxx> + +#include <rtl/strbuf.hxx> + +#include <vector> +#include <map> + +#include <orcus/csv_parser.hpp> + +class SvStream; +class ScDBData; + +namespace sc { + +class DataTransformation; +class ExternalDataSource; + +class CSVFetchThread : public salhelper::Thread +{ + ScDocument& mrDocument; + OUString maURL; + + bool mbTerminate; + osl::Mutex maMtxTerminate; + + orcus::csv::parser_config maConfig; + + std::vector<std::shared_ptr<sc::DataTransformation>> maDataTransformations; + + std::function<void()> maImportFinishedHdl; + + +public: + CSVFetchThread(ScDocument& rDoc, const OUString&, std::function<void()> aImportFinishedHdl, + const std::vector<std::shared_ptr<sc::DataTransformation>>& mrDataTransformations); + virtual ~CSVFetchThread() override; + + void RequestTerminate(); + bool IsRequestedTerminate(); + void Terminate(); + void EndThread(); + + virtual void execute() override; +}; + +/** + * Abstract class for all data provider. + * + */ +class DataProvider +{ +protected: + /** + * If true make the threaded import deterministic for the tests. + */ + bool mbDeterministic; + sc::ExternalDataSource& mrDataSource; + +public: + DataProvider(sc::ExternalDataSource& rDataSource); + + virtual ~DataProvider(); + + virtual void Import() = 0; + + virtual const OUString& GetURL() const = 0; + + static std::unique_ptr<SvStream> FetchStreamFromURL(const OUString&, OStringBuffer& rBuffer); + + void setDeterministic(); +}; + +class CSVDataProvider : public DataProvider +{ + rtl::Reference<CSVFetchThread> mxCSVFetchThread; + ScDocument* mpDocument; + ScDocumentUniquePtr mpDoc; + + void Refresh(); + +public: + CSVDataProvider (ScDocument* pDoc, sc::ExternalDataSource& rDataSource); + virtual ~CSVDataProvider() override; + + virtual void Import() override; + + const OUString& GetURL() const override; + void ImportFinished(); +}; + +/** + * This class handles the copying of the data from the imported + * temporary document to the actual document. Additionally, in the future + * we may decide to store data transformations in this class. + * + * In addition this class also handles how to deal with excess data by for example extending the ScDBData or by only showing the first or last entries. + * + * TODO: move the DataProvider::WriteToDoc here + * + */ +class ScDBDataManager +{ + OUString maDBName; + ScDocument* mpDoc; + +public: + ScDBDataManager(const OUString& rDBName, ScDocument* pDoc); + ~ScDBDataManager(); + + void SetDatabase(const OUString& rDBName); + + ScDBData* getDBData(); + + void WriteToDoc(ScDocument& rDoc); +}; + +class DataProviderFactory +{ +private: + + static bool isInternalDataProvider(const OUString& rProvider); + +public: + + static std::shared_ptr<DataProvider> getDataProvider(ScDocument* pDoc, sc::ExternalDataSource& rDataSource); + + static std::vector<OUString> getDataProviders(); +}; + +} + +#endif +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/dataproviderdlg.hxx b/sc/source/ui/inc/dataproviderdlg.hxx new file mode 100644 index 000000000..2cc636973 --- /dev/null +++ b/sc/source/ui/inc/dataproviderdlg.hxx @@ -0,0 +1,77 @@ +/* -*- 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_SC_SOURCE_UI_INC_DATAPROVIDERDLG_HXX +#define INCLUDED_SC_SOURCE_UI_INC_DATAPROVIDERDLG_HXX + +#include <sal/config.h> + +#include <com/sun/star/awt/XWindow.hpp> +#include <vcl/idle.hxx> +#include <vcl/weld.hxx> +#include "datatableview.hxx" +#include <memory> + +class ScDocument; +class ScDataProviderBaseControl; +class ScDataTransformationBaseControl; +class ScDBData; + +class ScDataProviderDlg : public weld::GenericDialogController +{ +private: + std::shared_ptr<ScDocument> mxDoc; + std::unique_ptr<weld::Menu> mxStartMenu; + std::unique_ptr<weld::Menu> mxColumnMenu; + std::unique_ptr<weld::Container> mxBox; + css::uno::Reference<css::awt::XWindow> m_xTableParent; + VclPtr<ScDataTableView> mxTable; + std::unique_ptr<weld::ScrolledWindow> mxScroll; + std::unique_ptr<weld::Container> mxList; + std::unique_ptr<ScDataProviderBaseControl> mxDataProviderCtrl; + std::unique_ptr<weld::ComboBox> mxDBRanges; + + std::vector<std::unique_ptr<ScDataTransformationBaseControl>> maControls; + + Idle maIdle; + + sal_uInt32 mnIndex; + ScDBData* pDBData; + + void InitMenu(); + + DECL_LINK( StartMenuHdl, const OString&, void ); + DECL_LINK( ColumnMenuHdl, const OString&, void ); + DECL_LINK( ImportHdl, ScDataProviderBaseControl*, void ); + DECL_LINK( ScrollToEnd, Timer*, void ); + +public: + ScDataProviderDlg(weld::Window* pWindow, std::shared_ptr<ScDocument> pDoc, const ScDocument* pDocument); + virtual ~ScDataProviderDlg() override; + + void applyAndQuit(); + void cancelAndQuit(); + + void deleteColumn(); + void splitColumn(); + void mergeColumns(); + void textTransformation(); + void sortTransformation(); + void aggregateFunction(); + void numberTransformation(); + void deletefromList(sal_uInt32 nIndex); + void replaceNullTransformation(); + void dateTimeTransformation(); + + void import(ScDocument* pDoc, bool bInternal = false); +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/datastream.hxx b/sc/source/ui/inc/datastream.hxx new file mode 100644 index 000000000..653eb9edc --- /dev/null +++ b/sc/source/ui/inc/datastream.hxx @@ -0,0 +1,130 @@ +/* -*- 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_SC_SOURCE_UI_INC_DATASTREAM_HXX +#define INCLUDED_SC_SOURCE_UI_INC_DATASTREAM_HXX + +#include <sal/config.h> + +#include <rtl/ref.hxx> +#include <rtl/ustring.hxx> +#include <vcl/timer.hxx> +#include <address.hxx> + +#include <vector> + +#include <documentstreamaccess.hxx> + +class ScDocShell; + +namespace sc { + +namespace datastreams { + class ReaderThread; +} + +class DataStream +{ +public: + DataStream(const DataStream&) = delete; + const DataStream& operator=(const DataStream&) = delete; + + struct Cell + { + struct Str + { + size_t Pos; + size_t Size; + }; + + union + { + Str maStr; + double mfValue; + }; + + bool mbValue; + + Cell(); + Cell( const Cell& r ); + }; + + struct Line + { + OString maLine; + std::vector<Cell> maCells; + }; + typedef std::vector<Line> LinesType; + + enum MoveType { NO_MOVE, RANGE_DOWN, MOVE_DOWN, MOVE_UP }; + enum { VALUES_IN_LINE = 2 }; + + static void MakeToolbarVisible(); + static DataStream* Set(ScDocShell *pShell, const OUString& rURL, const ScRange& rRange, + sal_Int32 nLimit, MoveType eMove, sal_uInt32 nSettings); + + DataStream( + ScDocShell *pShell, const OUString& rURL, const ScRange& rRange, + sal_Int32 nLimit, MoveType eMove, sal_uInt32 nSettings); + + ~DataStream(); + + ScRange GetRange() const; + const OUString& GetURL() const { return msURL; } + MoveType GetMove() const { return meOrigMove;} + bool IsRefreshOnEmptyLine() const { return mbRefreshOnEmptyLine;} + + void Decode( + const OUString& rURL, const ScRange& rRange, sal_Int32 nLimit, + MoveType eMove, const sal_uInt32 nSettings); + + bool ImportData(); + void StartImport(); + void StopImport(); + + void SetRefreshOnEmptyLine( bool bVal ); + +private: + Line ConsumeLine(); + void MoveData(); + void Text2Doc(); + void Refresh(); + + DECL_LINK( ImportTimerHdl, Timer*, void ); + +private: + ScDocShell* mpDocShell; + DocumentStreamAccess maDocAccess; + OUString msURL; + sal_uInt32 mnSettings; + MoveType meOrigMove; // Initial move setting. This one gets saved to file. + MoveType meMove; // move setting during streaming, which may change in the middle. + bool mbRunning; + bool mbValuesInLine; + bool mbRefreshOnEmptyLine; + std::unique_ptr<LinesType> mpLines; + size_t mnLinesCount; + size_t mnLinesSinceRefresh; + double mfLastRefreshTime; + SCROW mnCurRow; + ScRange maStartRange; + ScRange maEndRange; + + Timer maImportTimer; + + rtl::Reference<datastreams::ReaderThread> mxReaderThread; + bool mbIsFirst; + bool mbIsUpdate; +}; + +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/datastreamdlg.hxx b/sc/source/ui/inc/datastreamdlg.hxx new file mode 100644 index 000000000..db9fe01b0 --- /dev/null +++ b/sc/source/ui/inc/datastreamdlg.hxx @@ -0,0 +1,66 @@ +/* -*- 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_SC_SOURCE_UI_INC_DATASTREAMDLG_HXX +#define INCLUDED_SC_SOURCE_UI_INC_DATASTREAMDLG_HXX + +#include <sal/config.h> + +#include <vcl/weld.hxx> + +class ScDocShell; +class SvtURLBox; +class ScRange; + +namespace sc { + +class DataStream; + +class DataStreamDlg : public weld::GenericDialogController +{ + ScDocShell *m_pDocShell; + + std::unique_ptr<SvtURLBox> m_xCbUrl; + std::unique_ptr<weld::Button> m_xBtnBrowse; + std::unique_ptr<weld::RadioButton> m_xRBValuesInLine; + std::unique_ptr<weld::RadioButton> m_xRBAddressValue; + std::unique_ptr<weld::CheckButton> m_xCBRefreshOnEmpty; + std::unique_ptr<weld::RadioButton> m_xRBDataDown; + std::unique_ptr<weld::RadioButton> m_xRBRangeDown; + std::unique_ptr<weld::RadioButton> m_xRBNoMove; + std::unique_ptr<weld::RadioButton> m_xRBMaxLimit; + std::unique_ptr<weld::RadioButton> m_xRBUnlimited; + std::unique_ptr<weld::Entry> m_xEdRange; + std::unique_ptr<weld::Entry> m_xEdLimit; + std::unique_ptr<weld::Button> m_xBtnOk; + std::unique_ptr<weld::Frame> m_xVclFrameLimit; + std::unique_ptr<weld::Frame> m_xVclFrameMove; + + DECL_LINK(UpdateClickHdl, weld::ToggleButton&, void); + DECL_LINK(UpdateHdl, weld::Entry&, void); + DECL_LINK(UpdateComboBoxHdl, weld::ComboBox&, void); + DECL_LINK(BrowseHdl, weld::Button&, void); + + void UpdateEnable(); + ScRange GetStartRange(); + +public: + DataStreamDlg(ScDocShell *pDocShell, weld::Window* pParent); + virtual ~DataStreamDlg() override; + + void Init( const DataStream& rStrm ); + + void StartStream(); +}; + +} + +#endif // INCLUDED_SC_SOURCE_UI_INC_DATASTREAMDLG_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/datatableview.hxx b/sc/source/ui/inc/datatableview.hxx new file mode 100644 index 000000000..fe415439e --- /dev/null +++ b/sc/source/ui/inc/datatableview.hxx @@ -0,0 +1,117 @@ +/* -*- 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_SC_SOURCE_UI_INC_DATATABLEVIEW_HXX +#define INCLUDED_SC_SOURCE_UI_INC_DATATABLEVIEW_HXX + +#include <com/sun/star/awt/XWindow.hpp> +#include <vcl/ctrl.hxx> +#include <vcl/scrbar.hxx> +#include <scdllapi.h> +#include <types.hxx> +#include "hdrcont.hxx" + +class ScDocument; + +class ScDataTableColView : public ScHeaderControl +{ + ScDocument* mpDoc; + SCCOL mnCol; + +public: + ScDataTableColView(vcl::Window* pParent, SelectionEngine* pSelectionEngine); + + void SetPos(SCCOLROW nRow); + void Init(ScDocument* pDoc); + + virtual SCCOLROW GetPos() const override; + virtual sal_uInt16 GetEntrySize(SCCOLROW nPos) const override; + virtual OUString GetEntryText(SCCOLROW nPos) const override; + virtual bool IsLayoutRTL() const override; + virtual void SetEntrySize(SCCOLROW nPos, sal_uInt16 nWidth) override; + virtual void HideEntries(SCCOLROW nPos, SCCOLROW nEndPos) override; +}; + +class ScDataTableRowView : public ScHeaderControl +{ + ScDocument* mpDoc; + SCROW mnRow; + +public: + ScDataTableRowView(vcl::Window* pParent, SelectionEngine* pSelectionEngine); + + void SetPos(SCCOLROW nRow); + void Init(ScDocument* pDoc); + + virtual SCCOLROW GetPos() const override; + virtual sal_uInt16 GetEntrySize(SCCOLROW nPos) const override; + virtual OUString GetEntryText(SCCOLROW nPos) const override; + virtual bool IsLayoutRTL() const override; + virtual void SetEntrySize(SCCOLROW nPos, sal_uInt16 nWidth) override; + virtual void HideEntries(SCCOLROW nPos, SCCOLROW nEndPos) override; +}; + +/* + * A simple UI component that presents a data table. + * + * Shares as much code as possible with the normal + * Calc grid rendering. + * + * This class should only depend on ScDocument and not + * on some of the Calc view shells. + */ +class ScDataTableView : public Control +{ + std::shared_ptr<ScDocument> mpDoc; + std::unique_ptr<SelectionEngine> mpSelectionEngine; + VclPtr<ScrollBarBox> mpTopLeft; + VclPtr<ScDataTableColView> mpColView; + VclPtr<ScDataTableRowView> mpRowView; + VclPtr<ScrollBar> mpVScroll; + VclPtr<ScrollBar> mpHScroll; + + SCROW mnFirstVisibleRow; + SCCOL mnFirstVisibleCol; + + std::unique_ptr<MouseEvent> mpMouseEvent; + + DECL_LINK(ScrollHdl, ScrollBar*, void); + +public: + ScDataTableView(const css::uno::Reference<css::awt::XWindow>& rParent); + + void Init(std::shared_ptr<ScDocument> pDoc); + + ~ScDataTableView() override; + + virtual void dispose() override; + + virtual void MouseButtonDown(const MouseEvent& rMEvt) override; + virtual void MouseButtonUp(const MouseEvent& rMEvt) override; + virtual void Resize() override; + virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) override; + virtual Size GetOptimalSize() const override; + + void getColRange(SCCOL& rStartCol, SCCOL& rEndCol) const; + void getRowRange(SCROW& rStartRow, SCROW& rEndRow) const; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/datatransformation.hxx b/sc/source/ui/inc/datatransformation.hxx new file mode 100644 index 000000000..55055821a --- /dev/null +++ b/sc/source/ui/inc/datatransformation.hxx @@ -0,0 +1,189 @@ +/* -*- 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_SC_SOURCE_UI_DATAPROVIDER_DATATRANSFORMATION_HXX +#define INCLUDED_SC_SOURCE_UI_DATAPROVIDER_DATATRANSFORMATION_HXX + +#include <types.hxx> +#include <scdllapi.h> + +#include <sortparam.hxx> + +#include <set> + +class ScDocument; + +namespace sc { + +enum class TransformationType +{ + MERGE_TRANSFORMATION, + SPLIT_TRANSFORMATION, + DELETE_TRANSFORMATION, + SORT_TRANSFORMATION, + TEXT_TRANSFORMATION, + AGGREGATE_FUNCTION, + NUMBER_TRANSFORMATION, + REMOVE_NULL_TRANSFORMATION, + DATETIME_TRANSFORMATION +}; + +enum class TEXT_TRANSFORM_TYPE { TO_LOWER, TO_UPPER, CAPITALIZE, TRIM }; + +enum class AGGREGATE_FUNCTION { SUM, AVERAGE, MIN, MAX }; + +enum class NUMBER_TRANSFORM_TYPE { ROUND, ROUND_UP, ROUND_DOWN, ABSOLUTE, LOG_E, LOG_10, CUBE, + SQUARE, SQUARE_ROOT, EXPONENT, IS_EVEN, IS_ODD, SIGN }; + +enum class DATETIME_TRANSFORMATION_TYPE { DATE_STRING, YEAR, START_OF_YEAR, END_OF_YEAR, MONTH, + MONTH_NAME, START_OF_MONTH, END_OF_MONTH, DAY, DAY_OF_WEEK, DAY_OF_YEAR, QUARTER, START_OF_QUARTER, + END_OF_QUARTER, TIME, HOUR, MINUTE, SECOND }; + +class SC_DLLPUBLIC DataTransformation +{ +protected: + + static SCROW getLastRow(const ScDocument& rDoc, SCCOL nCol); + +public: + virtual ~DataTransformation(); + + virtual void Transform(ScDocument& rDoc) const = 0; + + virtual TransformationType getTransformationType() const = 0; + +}; + +class SC_DLLPUBLIC ColumnRemoveTransformation : public DataTransformation +{ + std::set<SCCOL> maColumns; + +public: + + ColumnRemoveTransformation(const std::set<SCCOL>& rColumns); + virtual ~ColumnRemoveTransformation() override; + virtual void Transform(ScDocument& rDoc) const override; + virtual TransformationType getTransformationType() const override; + const std::set<SCCOL> & getColumns() const; +}; + +class SC_DLLPUBLIC SplitColumnTransformation : public DataTransformation +{ + SCCOL mnCol; + sal_Unicode mcSeparator; + +public: + + SplitColumnTransformation(SCCOL nCol, sal_Unicode cSeparator); + virtual void Transform(ScDocument& rDoc) const override; + virtual TransformationType getTransformationType() const override; + SCCOL getColumn() const; + sal_Unicode getSeparator() const; +}; + +class SC_DLLPUBLIC MergeColumnTransformation : public DataTransformation +{ + std::set<SCCOL> maColumns; + OUString maMergeString; + +public: + + MergeColumnTransformation(const std::set<SCCOL>& rColumns, const OUString& rMergeString); + virtual void Transform(ScDocument& rDoc) const override; + virtual TransformationType getTransformationType() const override; + const OUString & getMergeString() const; + const std::set<SCCOL> & getColumns() const; +}; + +class SortTransformation : public DataTransformation +{ + ScSortParam maSortParam; +public: + + SortTransformation(const ScSortParam& rParam); + virtual void Transform(ScDocument& rDoc) const override; + virtual TransformationType getTransformationType() const override; + const ScSortParam & getSortParam() const; +}; + +class SC_DLLPUBLIC TextTransformation : public DataTransformation +{ + std::set<SCCOL> mnCol; + TEXT_TRANSFORM_TYPE maType; + + public: + TextTransformation(const std::set<SCCOL>& nCol, const TEXT_TRANSFORM_TYPE rType); + virtual void Transform(ScDocument& rDoc) const override; + virtual TransformationType getTransformationType() const override; + TEXT_TRANSFORM_TYPE getTextTransformationType() const; + const std::set<SCCOL>& getColumns() const; +}; + +class SC_DLLPUBLIC AggregateFunction : public DataTransformation +{ + std::set<SCCOL> maColumns; + AGGREGATE_FUNCTION maType; + + public: + AggregateFunction(const std::set<SCCOL>& rColumns, const AGGREGATE_FUNCTION rType); + virtual void Transform(ScDocument& rDoc) const override; + virtual TransformationType getTransformationType() const override; + AGGREGATE_FUNCTION getAggregateType() const; + const std::set<SCCOL>& getColumns() const; +}; + +class SC_DLLPUBLIC NumberTransformation : public DataTransformation +{ + std::set<SCCOL> mnCol; + NUMBER_TRANSFORM_TYPE maType; + int maPrecision; + + public: + NumberTransformation(const std::set<SCCOL>& nCol, const NUMBER_TRANSFORM_TYPE rType); + NumberTransformation(const std::set<SCCOL>& nCol, const NUMBER_TRANSFORM_TYPE rType, + int nPrecision); + virtual void Transform(ScDocument& rDoc) const override; + virtual TransformationType getTransformationType() const override; + NUMBER_TRANSFORM_TYPE getNumberTransformationType() const; + int getPrecision() const; + const std::set<SCCOL>& getColumn() const; +}; + +class SC_DLLPUBLIC ReplaceNullTransformation : public DataTransformation +{ + std::set<SCCOL> mnCol; + OUString msReplaceWith; + + public: + ReplaceNullTransformation(const std::set<SCCOL>& nCol, const OUString& sReplaceWith); + virtual void Transform(ScDocument& rDoc) const override; + virtual TransformationType getTransformationType() const override; + const std::set<SCCOL>& getColumn() const; + const OUString& getReplaceString() const; +}; + +class SC_DLLPUBLIC DateTimeTransformation : public DataTransformation +{ + std::set<SCCOL> mnCol; + DATETIME_TRANSFORMATION_TYPE maType; + + public: + DateTimeTransformation(const std::set<SCCOL>& nCol, + const DATETIME_TRANSFORMATION_TYPE rType); + virtual void Transform(ScDocument& rDoc) const override; + virtual TransformationType getTransformationType() const override; + DATETIME_TRANSFORMATION_TYPE getDateTimeTransformationType() const; + const std::set<SCCOL>& getColumn() const; +}; + +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/dbdocfun.hxx b/sc/source/ui/inc/dbdocfun.hxx new file mode 100644 index 000000000..827c7c85c --- /dev/null +++ b/sc/source/ui/inc/dbdocfun.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_SC_SOURCE_UI_INC_DBDOCFUN_HXX +#define INCLUDED_SC_SOURCE_UI_INC_DBDOCFUN_HXX + +#include <address.hxx> +#include <vector> + +struct ScImportParam; +struct ScQueryParam; +struct ScSortParam; +struct ScSubTotalParam; + +class SfxViewFrame; +class ScDBData; +class ScDocShell; +class ScDPObject; +class ScDBCollection; + +namespace com::sun::star::uno { template <typename > class Sequence; } +namespace com::sun::star::beans { struct PropertyValue; } + +namespace svx { + class ODataAccessDescriptor; +} + +class ScDBDocFunc +{ +friend class ScDBFunc; + +private: + ScDocShell& rDocShell; + +public: + ScDBDocFunc( ScDocShell& rDocSh ): rDocShell(rDocSh) {} + + void UpdateImport( const OUString& rTarget, const svx::ODataAccessDescriptor& rDescriptor ); + + bool DoImport( SCTAB nTab, const ScImportParam& rParam, + const svx::ODataAccessDescriptor* pDescriptor); // used for selection an existing ResultSet + + void DoImportUno( const ScAddress& rPos, + const css::uno::Sequence<css::beans::PropertyValue>& aArgs ); + + static void ShowInBeamer( const ScImportParam& rParam, const SfxViewFrame* pFrame ); + + SC_DLLPUBLIC bool Sort( + SCTAB nTab, const ScSortParam& rSortParam, bool bRecord, bool bPaint, bool bApi ); + + SC_DLLPUBLIC bool Query( SCTAB nTab, const ScQueryParam& rQueryParam, + const ScRange* pAdvSource, bool bRecord, bool bApi ); + + void DoSubTotals( SCTAB nTab, const ScSubTotalParam& rParam, + bool bRecord, bool bApi ); + + bool AddDBRange( const OUString& rName, const ScRange& rRange ); + bool DeleteDBRange( const OUString& rName ); + bool RenameDBRange( const OUString& rOld, const OUString& rNew ); + void ModifyDBData( const ScDBData& rNewData ); // Name unveraendert + + void ModifyAllDBData( const ScDBCollection& rNewColl, const std::vector<ScRange>& rDelAreaList ); + + bool RepeatDB( const OUString& rDBName, bool bApi, bool bIsUnnamed, SCTAB aTab = 0); + + bool DataPilotUpdate( ScDPObject* pOldObj, const ScDPObject* pNewObj, + bool bRecord, bool bApi, bool bAllowMove = false ); + + bool RemovePivotTable(ScDPObject& rDPObj, bool bRecord, bool bApi); + bool CreatePivotTable(const ScDPObject& rDPObj, bool bRecord, bool bApi); + bool UpdatePivotTable(ScDPObject& rDPObj, bool bRecord, bool bApi); + + /** + * Reload the referenced pivot cache, and refresh all pivot tables that + * reference the cache. + */ + void RefreshPivotTables(const ScDPObject* pDPObj, bool bApi); + + /** + * Refresh the group dimensions of all pivot tables referencing the same + * cache. + */ + void RefreshPivotTableGroups(ScDPObject* pDPObj); +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/dbfunc.hxx b/sc/source/ui/inc/dbfunc.hxx new file mode 100644 index 000000000..139e9cc92 --- /dev/null +++ b/sc/source/ui/inc/dbfunc.hxx @@ -0,0 +1,121 @@ +/* -*- 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_SC_SOURCE_UI_INC_DBFUNC_HXX +#define INCLUDED_SC_SOURCE_UI_INC_DBFUNC_HXX + +#include "viewfunc.hxx" +#include <dptypes.hxx> + +namespace com::sun::star::sheet { struct DataPilotFieldFilter; } +struct ScSortParam; +struct ScQueryParam; +class ScDBData; +class ScDPObject; +class ScDPSaveData; +struct ScDPNumGroupInfo; +struct ScSubTotalParam; + +class SAL_DLLPUBLIC_RTTI ScDBFunc : public ScViewFunc +{ +private: + void GetSelectedMemberList(ScDPUniqueStringSet& rEntries, long& rDimension); + +public: + ScDBFunc( vcl::Window* pParent, ScDocShell& rDocSh, ScTabViewShell* pViewShell ); + virtual ~ScDBFunc(); + + // only UISort repeat the partial results if necessary + + void UISort( const ScSortParam& rSortParam ); + + void Sort( const ScSortParam& rSortParam, + bool bRecord = true, bool bPaint = true ); + SC_DLLPUBLIC void Query( const ScQueryParam& rQueryParam, + const ScRange* pAdvSource, bool bRecord ); + void DoSubTotals( const ScSubTotalParam& rParam, bool bRecord = true, + const ScSortParam* pForceNewSort = nullptr ); + + void ToggleAutoFilter(); + void HideAutoFilter(); + + void RepeatDB( bool bRecord = true ); + + bool ImportData( const ScImportParam& rParam ); + + void GotoDBArea( const OUString& rDBName ); + + // DB range from Cursor + ScDBData* GetDBData( bool bMarkArea = true, ScGetDBMode eMode = SC_DB_MAKE, ScGetDBSelection eSel = ScGetDBSelection::Keep); + ScDBData* GetAnonymousDBData(); + + void Consolidate( const ScConsolidateParam& rParam ); + + bool MakePivotTable( + const ScDPSaveData& rData, const ScRange& rDest, bool bNewTable, + const ScDPObject& rSource ); + + void DeletePivotTable(); + void RecalcPivotTable(); + bool HasSelectionForDateGroup( ScDPNumGroupInfo& rOldInfo, sal_Int32& rParts ); + bool HasSelectionForNumGroup( ScDPNumGroupInfo& rOldInfo ); + void GroupDataPilot(); + void DateGroupDataPilot( const ScDPNumGroupInfo& rInfo, sal_Int32 nParts ); + void NumGroupDataPilot( const ScDPNumGroupInfo& rInfo ); + void UngroupDataPilot(); + void DataPilotInput( const ScAddress& rPos, const OUString& rString ); + + void DataPilotSort(ScDPObject* pDPObject, long nDimIndex, bool bAscending, const sal_uInt16* pUserListId = nullptr); + bool DataPilotMove( const ScRange& rSource, const ScAddress& rDest ); + + bool HasSelectionForDrillDown( css::sheet::DataPilotFieldOrientation& rOrientation ); + void SetDataPilotDetails(bool bShow, const OUString* pNewDimensionName = nullptr); + + void ShowDataPilotSourceData( ScDPObject& rDPObj, + const css::uno::Sequence< css::sheet::DataPilotFieldFilter >& rFilters ); + + void MakeOutline( bool bColumns, bool bRecord = true ); + void RemoveOutline( bool bColumns, bool bRecord = true ); + void RemoveAllOutlines( bool bRecord = true ); + void TestRemoveOutline( bool& rCol, bool& rRow ); + + void AutoOutline(); + + void SelectLevel( bool bColumns, sal_uInt16 nLevel, + bool bRecord = true ); + void SetOutlineState( bool bColumn, sal_uInt16 nLevel, sal_uInt16 nEntry, bool bHidden); + void ShowOutline( bool bColumns, sal_uInt16 nLevel, sal_uInt16 nEntry, + bool bRecord = true, bool bPaint = true ); + void HideOutline( bool bColumns, sal_uInt16 nLevel, sal_uInt16 nEntry, + bool bRecord = true, bool bPaint = true ); + + void ShowMarkedOutlines( bool bRecord = true ); + void HideMarkedOutlines( bool bRecord = true ); + bool OutlinePossible(bool bHide); + + void UpdateCharts(bool bAllCharts); // Default: at the Cursor + + static sal_uInt16 DoUpdateCharts( const ScAddress& rPos, ScDocument* pDoc, bool bAllCharts ); + + void OnLOKShowHideColRow(bool bColumns, SCCOLROW nStartRow); +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/dbnamdlg.hxx b/sc/source/ui/inc/dbnamdlg.hxx new file mode 100644 index 000000000..27b02e298 --- /dev/null +++ b/sc/source/ui/inc/dbnamdlg.hxx @@ -0,0 +1,103 @@ +/* -*- 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_SC_SOURCE_UI_INC_DBNAMDLG_HXX +#define INCLUDED_SC_SOURCE_UI_INC_DBNAMDLG_HXX + +#include <vector> +#include "anyrefdg.hxx" +#include <dbdata.hxx> + +class ScViewData; +class ScDocument; + +class ScDbNameDlg : public ScAnyRefDlgController +{ +public: + ScDbNameDlg(SfxBindings* pB, SfxChildWindow* pCW, weld::Window* pParent, + ScViewData* ptrViewData); + virtual ~ScDbNameDlg() override; + + virtual void SetReference( const ScRange& rRef, ScDocument& rDoc ) override; + + virtual bool IsRefInputMode() const override; + virtual void SetActive() override; + virtual void Close() override; + +private: + bool bSaved; + + OUString aStrAdd; + OUString aStrModify; + OUString aStrInvalid; + + OUString aStrSource; + OUString aStrOperations; + + ScViewData* pViewData; + const ScDocument& rDoc; + bool bRefInputMode; + ScAddress::Details aAddrDetails; + + ScDBCollection aLocalDbCol; + ScRange theCurArea; + std::vector<ScRange> aRemoveList; + + std::unique_ptr<weld::EntryTreeView> m_xEdName; + + std::unique_ptr<weld::Frame> m_xAssignFrame; + std::unique_ptr<formula::RefEdit> m_xEdAssign; + std::unique_ptr<formula::RefButton> m_xRbAssign; + + std::unique_ptr<weld::Widget> m_xOptions; + std::unique_ptr<weld::CheckButton> m_xBtnHeader; + std::unique_ptr<weld::CheckButton> m_xBtnTotals; + std::unique_ptr<weld::CheckButton> m_xBtnDoSize; + std::unique_ptr<weld::CheckButton> m_xBtnKeepFmt; + std::unique_ptr<weld::CheckButton> m_xBtnStripData; + std::unique_ptr<weld::Label> m_xFTSource; + std::unique_ptr<weld::Label> m_xFTOperations; + + std::unique_ptr<weld::Button> m_xBtnOk; + std::unique_ptr<weld::Button> m_xBtnCancel; + std::unique_ptr<weld::Button> m_xBtnAdd; + std::unique_ptr<weld::Button> m_xBtnRemove; + + std::unique_ptr<weld::Button> m_xModifyPB; + std::unique_ptr<weld::Label> m_xInvalidFT; + + std::unique_ptr<weld::Label> m_xFrameLabel; + std::unique_ptr<weld::Expander> m_xExpander; +private: + void Init(); + void UpdateNames(); + void UpdateDBData( const OUString& rStrName ); + void SetInfoStrings( const ScDBData* pDBData ); + + DECL_LINK( CancelBtnHdl, weld::Button&, void ); + DECL_LINK( OkBtnHdl, weld::Button&, void ); + DECL_LINK( AddBtnHdl, weld::Button&, void ); + DECL_LINK( RemoveBtnHdl, weld::Button&, void ); + DECL_LINK( NameModifyHdl, weld::ComboBox&, void ); + DECL_LINK( AssModifyHdl, formula::RefEdit&, void ); +}; + +#endif // INCLUDED_SC_SOURCE_UI_INC_DBNAMDLG_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/delcldlg.hxx b/sc/source/ui/inc/delcldlg.hxx new file mode 100644 index 000000000..3a140bfe6 --- /dev/null +++ b/sc/source/ui/inc/delcldlg.hxx @@ -0,0 +1,44 @@ +/* -*- 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_SC_SOURCE_UI_INC_DELCLDLG_HXX +#define INCLUDED_SC_SOURCE_UI_INC_DELCLDLG_HXX + +#include <vcl/weld.hxx> + +#include <global.hxx> + +class ScDeleteCellDlg : public weld::GenericDialogController +{ +private: + std::unique_ptr<weld::RadioButton> m_xBtnCellsUp; + std::unique_ptr<weld::RadioButton> m_xBtnCellsLeft; + std::unique_ptr<weld::RadioButton> m_xBtnDelRows; + std::unique_ptr<weld::RadioButton> m_xBtnDelCols; + +public: + ScDeleteCellDlg(weld::Window* pParent, bool bDisallowCellMove); + virtual ~ScDeleteCellDlg() override; + + DelCellCmd GetDelCellCmd() const; +}; + +#endif // INCLUDED_SC_SOURCE_UI_INC_DELCLDLG_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/delcodlg.hxx b/sc/source/ui/inc/delcodlg.hxx new file mode 100644 index 000000000..d2f9e9535 --- /dev/null +++ b/sc/source/ui/inc/delcodlg.hxx @@ -0,0 +1,57 @@ +/* -*- 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_SC_SOURCE_UI_INC_DELCODLG_HXX +#define INCLUDED_SC_SOURCE_UI_INC_DELCODLG_HXX + +#include <vcl/weld.hxx> +#include <global.hxx> + +class ScDeleteContentsDlg : public weld::GenericDialogController +{ +private: + bool m_bObjectsDisabled; + + std::unique_ptr<weld::CheckButton> m_xBtnDelAll; + std::unique_ptr<weld::CheckButton> m_xBtnDelStrings; + std::unique_ptr<weld::CheckButton> m_xBtnDelNumbers; + std::unique_ptr<weld::CheckButton> m_xBtnDelDateTime; + std::unique_ptr<weld::CheckButton> m_xBtnDelFormulas; + std::unique_ptr<weld::CheckButton> m_xBtnDelNotes; + std::unique_ptr<weld::CheckButton> m_xBtnDelAttrs; + std::unique_ptr<weld::CheckButton> m_xBtnDelObjects; + std::unique_ptr<weld::Button> m_xBtnOk; + + static bool bPreviousAllCheck; + static InsertDeleteFlags nPreviousChecks; + + void DisableChecks( bool bDelAllChecked ); + DECL_LINK( DelAllHdl, weld::Button&, void ); + +public: + ScDeleteContentsDlg(weld::Window* pParent); + virtual ~ScDeleteContentsDlg() override; + void DisableObjects(); + + InsertDeleteFlags GetDelContentsCmdBits() const; +}; + +#endif // INCLUDED_SC_SOURCE_UI_INC_DELCODLG_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/docfunc.hxx b/sc/source/ui/inc/docfunc.hxx new file mode 100644 index 000000000..e3a8117a5 --- /dev/null +++ b/sc/source/ui/inc/docfunc.hxx @@ -0,0 +1,245 @@ +/* -*- 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_SC_SOURCE_UI_INC_DOCFUNC_HXX +#define INCLUDED_SC_SOURCE_UI_INC_DOCFUNC_HXX + +#include <tools/solar.h> +#include <global.hxx> +#include <formula/grammar.hxx> +#include <tabbgcolor.hxx> + +#include <memory> +#include <vector> +#include <map> + +class ScEditEngineDefaulter; +class SdrUndoAction; +class ScAddress; +class ScDocShell; +class ScMarkData; +class ScPatternAttr; +class ScRange; +class ScRangeList; +class ScFormulaCell; +class ScTokenArray; +struct ScTabOpParam; +class ScTableProtection; +struct ScCellMergeOption; +class ScConditionalFormat; +class ScConditionalFormatList; +class ScUndoRemoveMerge; +class ScRangeName; +class ScPostIt; + +enum class TransliterationFlags; +enum class CreateNameFlags; +namespace sc { + struct ColRowSpan; +} + +class ScDocFunc +{ +protected: + ScDocShell& rDocShell; + + bool AdjustRowHeight( const ScRange& rRange, bool bPaint = true ); + void CreateOneName( ScRangeName& rList, + SCCOL nPosX, SCROW nPosY, SCTAB nTab, + SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2, + bool& rCancel, bool bApi ); + void NotifyInputHandler( const ScAddress& rPos ); + + ScDocFunc( ScDocShell& rDocSh ): rDocShell(rDocSh) {} +public: + virtual ~ScDocFunc() {} + + void NotifyDrawUndo(std::unique_ptr<SdrUndoAction>); + + // for grouping multiple operations into one with a new name + void EnterListAction(const char* pNameResId); + void EndListAction(); + + bool DetectiveAddPred(const ScAddress& rPos); + bool DetectiveDelPred(const ScAddress& rPos); + bool DetectiveAddSucc(const ScAddress& rPos); + bool DetectiveDelSucc(const ScAddress& rPos); + bool DetectiveAddError(const ScAddress& rPos); + bool DetectiveMarkInvalid(SCTAB nTab); + bool DetectiveDelAll(SCTAB nTab); + bool DetectiveRefresh(bool bAutomatic = false); + void DetectiveCollectAllPreds(const ScRangeList& rSrcRanges, ::std::vector<ScTokenRef>& rRefTokens); + void DetectiveCollectAllSuccs(const ScRangeList& rSrcRanges, ::std::vector<ScTokenRef>& rRefTokens); + + SC_DLLPUBLIC bool DeleteContents( + const ScMarkData& rMark, InsertDeleteFlags nFlags, bool bRecord, bool bApi ); + + bool DeleteCell( + const ScAddress& rPos, const ScMarkData& rMark, InsertDeleteFlags nFlags, bool bRecord ); + + bool TransliterateText( const ScMarkData& rMark, TransliterationFlags nType, + bool bApi ); + + bool SetNormalString( bool& o_rbNumFmtSet, const ScAddress& rPos, const OUString& rText, bool bApi ); + bool SetValueCell( const ScAddress& rPos, double fVal, bool bInteraction ); + void SetValueCells( const ScAddress& rPos, const std::vector<double>& aVals, bool bInteraction ); + bool SetStringCell( const ScAddress& rPos, const OUString& rStr, bool bInteraction ); + bool SetEditCell( const ScAddress& rPos, const EditTextObject& rStr, bool bInteraction ); + + bool SetStringOrEditCell( const ScAddress& rPos, const OUString& rStr, bool bInteraction ); + + /** + * Below two methods take ownership of the formula cell instance(s). The caller + * must not delete it after passing it to this call. + */ + bool SetFormulaCell( const ScAddress& rPos, ScFormulaCell* pCell, bool bInteraction ); + bool SetFormulaCells( const ScAddress& rPos, std::vector<ScFormulaCell*>& rCells, bool bInteraction ); + void PutData( const ScAddress& rPos, ScEditEngineDefaulter& rEngine, bool bApi ); + bool SetCellText( + const ScAddress& rPos, const OUString& rText, bool bInterpret, bool bEnglish, bool bApi, + const formula::FormulaGrammar::Grammar eGrammar ); + + SC_DLLPUBLIC bool ShowNote( const ScAddress& rPos, bool bShow ); + + void SetNoteText( const ScAddress& rPos, const OUString& rNoteText, bool bApi ); + void ReplaceNote( const ScAddress& rPos, const OUString& rNoteText, const OUString* pAuthor, const OUString* pDate, bool bApi ); + SC_DLLPUBLIC ScPostIt* ImportNote( const ScAddress& rPos, const OUString& rNoteText ); + + bool ApplyAttributes( const ScMarkData& rMark, const ScPatternAttr& rPattern, + bool bApi ); + bool ApplyStyle( const ScMarkData& rMark, const OUString& rStyleName, + bool bApi ); + + bool InsertCells( const ScRange& rRange,const ScMarkData* pTabMark, + InsCellCmd eCmd, bool bRecord, bool bApi, bool bPartOfPaste = false ); + + bool DeleteCells( const ScRange& rRange, const ScMarkData* pTabMark, + DelCellCmd eCmd, bool bApi ); + + bool MoveBlock( const ScRange& rSource, const ScAddress& rDestPos, + bool bCut, bool bRecord, bool bPaint, bool bApi ); + + SC_DLLPUBLIC bool InsertTable( SCTAB nTab, const OUString& rName, bool bRecord, bool bApi ); + bool RenameTable( SCTAB nTab, const OUString& rName, bool bRecord, bool bApi ); + bool DeleteTable( SCTAB nTab, bool bRecord ); + + bool SetTabBgColor( SCTAB nTab, const Color& rColor, bool bRecord, bool bApi ); + bool SetTabBgColor( ScUndoTabColorInfo::List& rUndoTabColorList, bool bApi ); + + void SetTableVisible( SCTAB nTab, bool bVisible, bool bApi ); + + bool SetLayoutRTL( SCTAB nTab, bool bRTL ); + + SC_DLLPUBLIC bool SetWidthOrHeight( + bool bWidth, const std::vector<sc::ColRowSpan>& rRanges, SCTAB nTab, + ScSizeMode eMode, sal_uInt16 nSizeTwips, bool bRecord, bool bApi ); + + bool InsertPageBreak( bool bColumn, const ScAddress& rPos, + bool bRecord, bool bSetModified ); + bool RemovePageBreak( bool bColumn, const ScAddress& rPos, + bool bRecord, bool bSetModified ); + + void ProtectSheet( SCTAB nTab, const ScTableProtection& rProtect ); + + bool Protect( SCTAB nTab, const OUString& rPassword ); + bool Unprotect( SCTAB nTab, const OUString& rPassword, bool bApi ); + + void ClearItems( const ScMarkData& rMark, const sal_uInt16* pWhich, bool bApi ); + bool ChangeIndent( const ScMarkData& rMark, bool bIncrement, bool bApi ); + bool AutoFormat( const ScRange& rRange, const ScMarkData* pTabMark, + sal_uInt16 nFormatNo, bool bApi ); + + SC_DLLPUBLIC bool + EnterMatrix( const ScRange& rRange, const ScMarkData* pTabMark, + const ScTokenArray* pTokenArray, + const OUString& rString, bool bApi, bool bEnglish, + const OUString& rFormulaNmsp, + const formula::FormulaGrammar::Grammar ); + + bool TabOp( const ScRange& rRange, const ScMarkData* pTabMark, + const ScTabOpParam& rParam, bool bRecord, bool bApi ); + + bool FillSimple( const ScRange& rRange, const ScMarkData* pTabMark, + FillDir eDir, bool bApi ); + bool FillSeries( const ScRange& rRange, const ScMarkData* pTabMark, + FillDir eDir, FillCmd eCmd, FillDateCmd eDateCmd, + double fStart, double fStep, double fMax, + bool bApi ); + + // FillAuto: rRange is change from Source-Range to Dest-Range + SC_DLLPUBLIC bool + FillAuto( ScRange& rRange, const ScMarkData* pTabMark, FillDir eDir, FillCmd eCmd, FillDateCmd eDateCmd, sal_uLong nCount, double fStep, double fMax, bool bRecord, bool bApi ); + + bool FillAuto( ScRange& rRange, const ScMarkData* pTabMark, + FillDir eDir, sal_uLong nCount, bool bApi ); + + void ResizeMatrix( const ScRange& rOldRange, const ScAddress& rNewEnd ); + + bool MergeCells( const ScCellMergeOption& rOption, bool bContents, + bool bRecord, bool bApi, bool bEmptyMergedCells = false ); + bool UnmergeCells( const ScRange& rRange, bool bRecord, ScUndoRemoveMerge* pUndoRemoveMerge ); + bool UnmergeCells( const ScCellMergeOption& rOption, bool bRecord, ScUndoRemoveMerge* pUndoRemoveMerge ); + + // takes ownership of pNewRanges, nTab = -1 for local range names + void SetNewRangeNames( std::unique_ptr<ScRangeName> pNewRanges, bool bModifyDoc, SCTAB nTab ); + void ModifyRangeNames( const ScRangeName& rNewRanges, SCTAB nTab = -1 ); + /** + * Modify all range names, global scope names as well as sheet local ones, + * in one go. Note that this method will <b>not</b> destroy the instances + * passed as arguments (it creates copies); the caller is responsible for + * destroying them. + */ + void ModifyAllRangeNames(const std::map<OUString, std::unique_ptr<ScRangeName>>& rRangeMap); + + bool CreateNames( const ScRange& rRange, CreateNameFlags nFlags, bool bApi, SCTAB nTab = -1 ); // -1 for global range names + bool InsertNameList( const ScAddress& rStartPos, bool bApi ); + + void InsertAreaLink( const OUString& rFile, const OUString& rFilter, + const OUString& rOptions, const OUString& rSource, + const ScRange& rDestRange, sal_uLong nRefresh, + bool bFitBlock, bool bApi ); + + /** + * @param nOldIndex If 0 don't delete an old format + * @param pFormat if NULL only delete an old format + */ + void ReplaceConditionalFormat( sal_uLong nOldIndex, std::unique_ptr<ScConditionalFormat> pFormat, SCTAB nTab, const ScRangeList& rRanges ); + + /** + * Sets or replaces the conditional format list of a table + * + * @param pList the new ScConditionalFormatList, method takes ownership + * @param nTab the tab to which the conditional format list belongs + */ + void SetConditionalFormatList( ScConditionalFormatList* pList, SCTAB nTab ); + + void ConvertFormulaToValue( const ScRange& rRange, bool bInteraction ); +}; + +class ScDocFuncDirect : public ScDocFunc +{ +public: + ScDocFuncDirect( ScDocShell& rDocSh ) : ScDocFunc( rDocSh ) {} +}; + +void VBA_DeleteModule( ScDocShell& rDocSh, const OUString& sModuleName ); + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/docfuncutil.hxx b/sc/source/ui/inc/docfuncutil.hxx new file mode 100644 index 000000000..8d3cec001 --- /dev/null +++ b/sc/source/ui/inc/docfuncutil.hxx @@ -0,0 +1,45 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * 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_SC_DOCFUNCUTIL_HXX +#define INCLUDED_SC_DOCFUNCUTIL_HXX + +#include "undobase.hxx" + +#include <memory> + +class ScMarkData; +class ScRange; +enum class InsertDeleteFlags : sal_uInt16; + +namespace sc { + +class DocFuncUtil +{ +public: + + static bool hasProtectedTab( const ScDocument& rDoc, const ScMarkData& rMark ); + + static ScDocumentUniquePtr createDeleteContentsUndoDoc( + ScDocument& rDoc, const ScMarkData& rMark, const ScRange& rRange, + InsertDeleteFlags nFlags, bool bOnlyMarked ); + + static void addDeleteContentsUndo( + SfxUndoManager* pUndoMgr, ScDocShell* pDocSh, const ScMarkData& rMark, + const ScRange& rRange, ScDocumentUniquePtr&& pUndoDoc, InsertDeleteFlags nFlags, + const std::shared_ptr<ScSimpleUndo::DataSpansType>& pSpans, + bool bMulti, bool bDrawUndo ); + + static std::shared_ptr<ScSimpleUndo::DataSpansType> getNonEmptyCellSpans( + const ScDocument& rDoc, const ScMarkData& rMark, const ScRange& rRange ); +}; + +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/docsh.hxx b/sc/source/ui/inc/docsh.hxx new file mode 100644 index 000000000..dc77bdcbb --- /dev/null +++ b/sc/source/ui/inc/docsh.hxx @@ -0,0 +1,501 @@ +/* -*- 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_SC_SOURCE_UI_INC_DOCSH_HXX +#define INCLUDED_SC_SOURCE_UI_INC_DOCSH_HXX + +#include <sfx2/objsh.hxx> +#include <sfx2/docfac.hxx> +#include <sfx2/sfxmodelfactory.hxx> +#include <sfx2/viewsh.hxx> +#include <o3tl/deleter.hxx> +#include <comphelper/servicehelper.hxx> + +#include <scdllapi.h> +#include <document.hxx> +#include <shellids.hxx> +#include <optutil.hxx> +#include <docuno.hxx> + +#include <memory> +#include <unordered_map> +#include <map> + +class ScRefreshTimerProtector; +class ScEditEngineDefaulter; +class SfxStyleSheetBasePool; +class SfxStyleSheetHint; +class INetURLObject; + +class ScViewData; +class ScDocFunc; +class ScDrawLayer; +class ScTabViewShell; +class ScAutoStyleList; +class ScMarkData; +class ScPaintLockData; +class ScChangeAction; +class ScImportOptions; +class ScDocShellModificator; +class ScOptSolverSave; +class ScSheetSaveData; +class ScFlatBoolRowSegments; +struct ScColWidthParam; +class ScFormulaOptions; +namespace com::sun::star::script::vba { class XVBAScriptListener; } +namespace ooo::vba::excel { class XWorkbook; } +namespace com::sun::star::datatransfer { class XTransferable2; } +namespace sfx2 { class FileDialogHelper; } +struct DocShell_Impl; + +typedef std::unordered_map< sal_uLong, sal_uLong > ScChangeActionMergeMap; + +//enum ScDBFormat { SC_FORMAT_SDF, SC_FORMAT_DBF }; + +enum class LOKCommentNotificationType { Add, Modify, Remove }; + + // Extra flags for Repaint +#define SC_PF_LINES 1 +#define SC_PF_TESTMERGE 2 +#define SC_PF_WHOLEROWS 4 + +class SC_DLLPUBLIC ScDocShell final: public SfxObjectShell, public SfxListener +{ + ScDocument m_aDocument; + + OUString m_aDdeTextFmt; + + double m_nPrtToScreenFactor; + std::unique_ptr<DocShell_Impl> m_pImpl; + std::unique_ptr<ScDocFunc> m_pDocFunc; + + bool m_bHeaderOn; + bool m_bFooterOn; + bool m_bIsInplace:1; // Is set by the View + bool m_bIsEmpty:1; + bool m_bIsInUndo:1; + bool m_bDocumentModifiedPending:1; + bool m_bUpdateEnabled:1; + bool m_bUcalcTest:1; // avoid loading the styles in the ucalc test + bool m_bAreasChangedNeedBroadcast:1; + sal_uInt16 m_nDocumentLock; + sal_Int16 m_nCanUpdate; // stores the UpdateDocMode from loading a document till update links + + std::unique_ptr<ScDBData> m_pOldAutoDBRange; + + std::unique_ptr<ScAutoStyleList> m_pAutoStyleList; + std::unique_ptr<ScPaintLockData> m_pPaintLockData; + std::unique_ptr<ScOptSolverSave> m_pSolverSaveData; + std::unique_ptr<ScSheetSaveData> m_pSheetSaveData; + std::unique_ptr<ScFormatSaveData> m_pFormatSaveData; + + std::unique_ptr<ScDocShellModificator, o3tl::default_delete<ScDocShellModificator>> m_pModificator; // #109979#; is used to load XML (created in BeforeXMLLoading and destroyed in AfterXMLLoading) + + css::uno::Reference< ooo::vba::excel::XWorkbook> mxAutomationWorkbookObject; + + // Only used by Vba helper functions + css::uno::Reference<css::script::vba::XVBAScriptListener> m_xVBAListener; + css::uno::Reference<css::datatransfer::XTransferable2> m_xClipData; + + SAL_DLLPRIVATE void InitItems(); + SAL_DLLPRIVATE void DoEnterHandler(); + SAL_DLLPRIVATE void InitOptions(bool bForLoading); + SAL_DLLPRIVATE void ResetDrawObjectShell(); + + /** Do things that need to be done before saving to our own format and + necessary clean ups in dtor. */ + class SAL_DLLPRIVATE PrepareSaveGuard + { + public: + explicit PrepareSaveGuard( ScDocShell & rDocShell ); + ~PrepareSaveGuard() COVERITY_NOEXCEPT_FALSE; + private: + ScDocShell & mrDocShell; + }; + + SAL_DLLPRIVATE bool LoadXML( SfxMedium* pMedium, const css::uno::Reference< css::embed::XStorage >& ); + SAL_DLLPRIVATE bool SaveXML( SfxMedium* pMedium, const css::uno::Reference< css::embed::XStorage >& ); + SAL_DLLPRIVATE SCTAB GetSaveTab(); + + SAL_DLLPRIVATE ErrCode DBaseImport( const OUString& rFullFileName, rtl_TextEncoding eCharSet, + std::map<SCCOL, ScColWidthParam>& aColWidthParam, ScFlatBoolRowSegments& rRowHeightsRecalc ); + SAL_DLLPRIVATE ErrCode DBaseExport( + const OUString& rFullFileName, rtl_TextEncoding eCharSet, bool& bHasMemo ); + + SAL_DLLPRIVATE static bool MoveFile( const INetURLObject& rSource, const INetURLObject& rDest ); + SAL_DLLPRIVATE static bool KillFile( const INetURLObject& rURL ); + SAL_DLLPRIVATE static bool IsDocument( const INetURLObject& rURL ); + + SAL_DLLPRIVATE void LockPaint_Impl(bool bDoc); + SAL_DLLPRIVATE void UnlockPaint_Impl(bool bDoc); + SAL_DLLPRIVATE void LockDocument_Impl(sal_uInt16 nNew); + SAL_DLLPRIVATE void UnlockDocument_Impl(sal_uInt16 nNew); + + SAL_DLLPRIVATE void EnableSharedSettings( bool bEnable ); + SAL_DLLPRIVATE css::uno::Reference< css::frame::XModel > LoadSharedDocument(); + + SAL_DLLPRIVATE void UseSheetSaveEntries(); + + SAL_DLLPRIVATE std::unique_ptr<ScDocFunc> CreateDocFunc(); + + virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override; + +public: + SFX_DECL_INTERFACE(SCID_DOC_SHELL) + SFX_DECL_OBJECTFACTORY(); + +private: + /// SfxInterface initializer. + static void InitInterface_Impl(); + +public: + explicit ScDocShell( const ScDocShell& rDocShell ) = delete; + explicit ScDocShell( const SfxModelFlags i_nSfxCreationFlags = SfxModelFlags::EMBEDDED_OBJECT ); + virtual ~ScDocShell() override; + + virtual SfxUndoManager* + GetUndoManager() override; + + virtual void FillClass( SvGlobalName * pClassName, + SotClipboardFormatId * pFormat, + OUString * pFullTypeName, + sal_Int32 nFileFormat, + bool bTemplate = false ) const override; + + virtual std::set<Color> GetDocColors() override; + + virtual bool InitNew( const css::uno::Reference< css::embed::XStorage >& ) override; + virtual bool Load( SfxMedium& rMedium ) override; + virtual bool LoadFrom( SfxMedium& rMedium ) override; + virtual bool ConvertFrom( SfxMedium &rMedium ) override; + virtual bool LoadExternal( SfxMedium& rMedium ) override; + virtual bool Save() override; + virtual bool SaveAs( SfxMedium& rMedium ) override; + virtual bool ConvertTo( SfxMedium &rMedium ) override; + virtual bool PrepareClose( bool bUI = true ) override; + virtual void LoadStyles( SfxObjectShell &rSource ) override; + + virtual bool DoSaveCompleted( SfxMedium * pNewStor=nullptr, bool bRegisterRecent=true ) override; // SfxObjectShell + virtual bool QuerySlotExecutable( sal_uInt16 nSlotId ) override; + + virtual void Draw( OutputDevice *, const JobSetup & rSetup, sal_uInt16 nAspect ) override; + + virtual void SetVisArea( const tools::Rectangle & rVisArea ) override; + + virtual void TerminateEditing() override; + + using SfxObjectShell::GetVisArea; + virtual tools::Rectangle GetVisArea( sal_uInt16 nAspect ) const override; + + virtual Printer* GetDocumentPrinter() override; + + virtual void SetModified( bool = true ) override; + + void SetVisAreaOrSize( const tools::Rectangle& rVisArea ); + + virtual std::shared_ptr<SfxDocumentInfoDialog> CreateDocumentInfoDialog(weld::Window* pParent, const SfxItemSet &rSet) override; + + void GetDocStat( ScDocStat& rDocStat ); + + const ScDocument& GetDocument() const { return m_aDocument; } + ScDocument& GetDocument() { return m_aDocument; } + ScDocFunc& GetDocFunc() { return *m_pDocFunc; } + + css::uno::Reference<css::datatransfer::XTransferable2> const & GetClipData() const { return m_xClipData; } + void SetClipData(const css::uno::Reference<css::datatransfer::XTransferable2>& xTransferable) { m_xClipData = xTransferable; } + + SfxPrinter* GetPrinter( bool bCreateIfNotExist = true ); + sal_uInt16 SetPrinter( VclPtr<SfxPrinter> const & pNewPrinter, SfxPrinterChangeFlags nDiffFlags = SFX_PRINTER_ALL ); + + void UpdateFontList(); + + ScDrawLayer* MakeDrawLayer(); + + void AsciiSave( SvStream& rStream, const ScImportOptions& rOpt ); + + void Execute( SfxRequest& rReq ); + void GetState( SfxItemSet &rSet ); + void ExecutePageStyle ( const SfxViewShell& rCaller, SfxRequest& rReq, SCTAB nCurTab ); + void GetStatePageStyle( SfxItemSet& rSet, SCTAB nCurTab ); + + void CompareDocument( ScDocument& rOtherDoc ); + void MergeDocument( ScDocument& rOtherDoc, bool bShared = false, bool bCheckDuplicates = false, sal_uLong nOffset = 0, ScChangeActionMergeMap* pMergeMap = nullptr, bool bInverseMap = false ); + bool MergeSharedDocument( ScDocShell* pSharedDocShell ); + + ScChangeAction* GetChangeAction( const ScAddress& rPos ); + void SetChangeComment( ScChangeAction* pAction, const OUString& rComment ); + void ExecuteChangeCommentDialog( ScChangeAction* pAction, weld::Window* pParent, bool bPrevNext = true ); + /// Protect/unprotect ChangeTrack and return <TRUE/> if + /// protection was successfully changed. + /// If bJustQueryIfProtected==sal_True protection is not + /// changed and <TRUE/> is returned if not protected or + /// password was entered correctly. + bool ExecuteChangeProtectionDialog( bool bJustQueryIfProtected = false ); + + void SetPrintZoom( SCTAB nTab, sal_uInt16 nScale, sal_uInt16 nPages ); + bool AdjustPrintZoom( const ScRange& rRange ); + + void LoadStylesArgs( ScDocShell& rSource, bool bReplace, bool bCellStyles, bool bPageStyles ); + + void PageStyleModified( const OUString& rStyleName, bool bApi ); + + void NotifyStyle( const SfxStyleSheetHint& rHint ); + void DoAutoStyle( const ScRange& rRange, const OUString& rStyle ); + + static weld::Window* GetActiveDialogParent(); + void ErrorMessage(const char* pGlobStrId); + bool IsEditable() const; + + bool AdjustRowHeight( SCROW nStartRow, SCROW nEndRow, SCTAB nTab ); + void UpdateAllRowHeights( const ScMarkData* pTabMark = nullptr ); + void UpdatePendingRowHeights( SCTAB nUpdateTab, bool bBefore = false ); + + void RefreshPivotTables( const ScRange& rSource ); + void DoConsolidate( const ScConsolidateParam& rParam, bool bRecord = true ); + void UseScenario( SCTAB nTab, const OUString& rName, bool bRecord = true ); + SCTAB MakeScenario(SCTAB nTab, const OUString& rName, const OUString& rComment, + const Color& rColor, ScScenarioFlags nFlags, + ScMarkData& rMark, bool bRecord = true); + void ModifyScenario(SCTAB nTab, const OUString& rName, const OUString& rComment, + const Color& rColor, ScScenarioFlags nFlags); + sal_uLong TransferTab( ScDocShell& rSrcDocShell, SCTAB nSrcPos, + SCTAB nDestPos, bool bInsertNew, + bool bNotifyAndPaint ); + + bool MoveTable( SCTAB nSrcTab, SCTAB nDestTab, bool bCopy, bool bRecord ); + + void DoRecalc( bool bApi ); + void DoHardRecalc(); + + void UpdateOle( const ScViewData* pViewData, bool bSnapSize = false); + bool IsOle() const; + + void DBAreaDeleted( SCTAB nTab, SCCOL nX1, SCROW nY1, SCCOL nX2 ); + ScDBData* GetDBData( const ScRange& rMarked, ScGetDBMode eMode, ScGetDBSelection eSel ); + ScDBData* GetAnonymousDBData(const ScRange& rRange); + std::unique_ptr<ScDBData> GetOldAutoDBRange(); + void CancelAutoDBRange(); // called when dialog is cancelled + + virtual void ReconnectDdeLink(SfxObjectShell& rServer) override; + void UpdateLinks() override; + void AllowLinkUpdate(); + void ReloadAllLinks(); + void ReloadTabLinks(); + ScLkUpdMode GetLinkUpdateModeState() const; + + void SetFormulaOptions( const ScFormulaOptions& rOpt, bool bForLoading = false ); + /** + * Called when the Options dialog is dismissed with the OK button, to + * handle potentially conflicting option settings. + */ + void CheckConfigOptions(); + + void PostEditView( ScEditEngineDefaulter* pEditEngine, const ScAddress& rCursorPos ); + + void PostPaint( SCCOL nStartCol, SCROW nStartRow, SCTAB nStartTab, + SCCOL nEndCol, SCROW nEndRow, SCTAB nEndTab, PaintPartFlags nPart, + sal_uInt16 nExtFlags = 0 ); + void PostPaint( const ScRangeList& rRanges, PaintPartFlags nPart, sal_uInt16 nExtFlags = 0 ); + + void PostPaintCell( SCCOL nCol, SCROW nRow, SCTAB nTab ); + void PostPaintCell( const ScAddress& rPos ); + void PostPaintGridAll(); + void PostPaintExtras(); + + bool IsPaintLocked() const { return m_pPaintLockData != nullptr; } + + void PostDataChanged(); + + void UpdatePaintExt( sal_uInt16& rExtFlags, SCCOL nStartCol, SCROW nStartRow, SCTAB nStartTab, + SCCOL nEndCol, SCROW nEndRow, SCTAB nEndTab ); + void UpdatePaintExt( sal_uInt16& rExtFlags, const ScRange& rRange ); + + void SetDocumentModified(); + void SetDrawModified(); + + void LockPaint(); + void UnlockPaint(); + sal_uInt16 GetLockCount() const { return m_nDocumentLock;} + void SetLockCount(sal_uInt16 nNew); + + void LockDocument(); + void UnlockDocument(); + + DECL_LINK( DialogClosedHdl, sfx2::FileDialogHelper*, void ); + DECL_LINK( ReloadAllLinksHdl, Button*, void ); + + virtual SfxStyleSheetBasePool* GetStyleSheetPool() override; + + void SetInplace( bool bInplace ); + bool IsEmpty() const { return m_bIsEmpty; } + void SetEmpty(bool bSet); + + bool IsInUndo() const { return m_bIsInUndo; } + void SetInUndo(bool bSet); + + void CalcOutputFactor(); + double GetOutputFactor() const { return m_nPrtToScreenFactor;} + void GetPageOnFromPageStyleSet( const SfxItemSet* pStyleSet, + SCTAB nCurTab, + bool& rbHeader, + bool& rbFooter ); + +#if defined(_WIN32) + virtual bool DdeGetData( const OUString& rItem, const OUString& rMimeType, + css::uno::Any & rValue ) override; + virtual bool DdeSetData( const OUString& rItem, const OUString& rMimeType, + const css::uno::Any & rValue ) override; +#endif + + virtual ::sfx2::SvLinkSource* DdeCreateLinkSource( const OUString& rItem ) override; + + const OUString& GetDdeTextFmt() const { return m_aDdeTextFmt; } + + SfxBindings* GetViewBindings(); + + ScTabViewShell* GetBestViewShell( bool bOnlyVisible = true ); + + void SetDocumentModifiedPending( bool bVal ) + { m_bDocumentModifiedPending = bVal; } + bool IsDocumentModifiedPending() const + { return m_bDocumentModifiedPending; } + + bool IsUpdateEnabled() const + { return m_bUpdateEnabled; } + void SetUpdateEnabled(bool bValue) + { m_bUpdateEnabled = bValue; } + + void SetAreasChangedNeedBroadcast() + { m_bAreasChangedNeedBroadcast = true; } + + OutputDevice* GetRefDevice(); // WYSIWYG: Printer, otherwise VirtualDevice... + + static ScViewData* GetViewData(); + static SCTAB GetCurTab(); + + static ScDocShell* GetShellByNum( sal_uInt16 nDocNo ); + static OUString GetOwnFilterName(); + static OUString GetHtmlFilterName(); + static OUString GetWebQueryFilterName(); + static OUString GetAsciiFilterName(); + static OUString GetLotusFilterName(); + static OUString GetDBaseFilterName(); + static OUString GetDifFilterName(); + static bool HasAutomaticTableName( const OUString& rFilter ); + static void LOKCommentNotify(LOKCommentNotificationType nType, const ScDocument* pDocument, const ScAddress& rPos, const ScPostIt* pNote); + + DECL_LINK( RefreshDBDataHdl, Timer*, void ); + + void BeforeXMLLoading(); + void AfterXMLLoading(bool bRet); + + virtual HiddenInformation GetHiddenInformationState( HiddenInformation nStates ) override; + + const ScOptSolverSave* GetSolverSaveData() const { return m_pSolverSaveData.get(); } // may be null + void SetSolverSaveData( std::unique_ptr<ScOptSolverSave> pData ); + ScSheetSaveData* GetSheetSaveData(); + ScFormatSaveData* GetFormatSaveData(); + + static void ResetKeyBindings( ScOptionsUtil::KeyBindingType eType ); + + // password protection for Calc (derived from SfxObjectShell) + // see also: FID_CHG_RECORD, SID_CHG_PROTECT + virtual bool IsChangeRecording() const override; + virtual bool HasChangeRecordProtection() const override; + virtual void SetChangeRecording( bool bActivate ) override; + virtual void SetProtectionPassword( const OUString &rPassword ) override; + virtual bool GetProtectionHash( /*out*/ css::uno::Sequence< sal_Int8 > &rPasswordHash ) override; + + void SnapVisArea( tools::Rectangle& rRect ) const; + + void SetIsInUcalc(); + + void RegisterAutomationWorkbookObject(css::uno::Reference< ooo::vba::excel::XWorkbook > const& xWorkbook); +}; + +void UpdateAcceptChangesDialog(); + +typedef tools::SvRef<ScDocShell> ScDocShellRef; + +/** Create before modifications of the document and destroy thereafter. + Call SetDocumentModified() at an instance of this class instead of at + ScDocShell. + + Remembers in the ctor ScDocument's AutoCalcShellDisabled and IdleDisabled, + switches them off and restores them in the dtor, AutoCalcShellDisabled + also before a ScDocShell::SetDocumentModified() call if necessary. + In the dtor, if ScDocShell's bDocumentModifiedPending is set and + bAutoCalcShellDisabled is not set, then ScDocShell::SetDocumentModified() + is called. + + Several instances can be used in nested calls to ScDocFunc or ScDocShell + methods to avoid multiple modified status changes, only the last instance + destroyed calls ScDocShell::SetDocumentModified(). + */ +class ScDocShellModificator +{ + ScDocShell& rDocShell; + std::unique_ptr<ScRefreshTimerProtector> mpProtector; + bool bAutoCalcShellDisabled; + bool bIdleEnabled; + + ScDocShellModificator( const ScDocShellModificator& ) = delete; + ScDocShellModificator& operator=( const ScDocShellModificator& ) = delete; + +public: + explicit ScDocShellModificator( ScDocShell& ); + ~ScDocShellModificator() COVERITY_NOEXCEPT_FALSE; + void SetDocumentModified(); +}; + +//#i97876# Spreadsheet data changes are not notified +namespace HelperNotifyChanges +{ + inline ScModelObj* getMustPropagateChangesModel(const ScDocShell &rDocShell) + { + ScModelObj* pModelObj = comphelper::getUnoTunnelImplementation<ScModelObj>(rDocShell.GetModel()); + if (pModelObj && pModelObj->HasChangesListeners()) + return pModelObj; + return nullptr; + } + + inline void Notify(ScModelObj &rModelObj, const ScRangeList &rChangeRanges, + const OUString &rType = OUString("cell-change"), + const css::uno::Sequence< css::beans::PropertyValue >& rProperties = + css::uno::Sequence< css::beans::PropertyValue >()) + { + rModelObj.NotifyChanges(rType, rChangeRanges, rProperties); + } + + inline void NotifyIfChangesListeners(const ScDocShell &rDocShell, const ScRange &rRange, + const OUString &rType = OUString("cell-change")) + { + if (ScModelObj* pModelObj = getMustPropagateChangesModel(rDocShell)) + { + ScRangeList aChangeRanges(rRange); + Notify(*pModelObj, aChangeRanges, rType); + } + } +}; + +void VBA_InsertModule( ScDocument& rDoc, SCTAB nTab, const OUString& sModuleSource ); + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/dpcontrol.hxx b/sc/source/ui/inc/dpcontrol.hxx new file mode 100644 index 000000000..1b8c380e8 --- /dev/null +++ b/sc/source/ui/inc/dpcontrol.hxx @@ -0,0 +1,74 @@ +/* -*- 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_SC_SOURCE_UI_INC_DPCONTROL_HXX +#define INCLUDED_SC_SOURCE_UI_INC_DPCONTROL_HXX + +#include <rtl/ustring.hxx> +#include <tools/gen.hxx> +#include <tools/fract.hxx> +#include <vcl/vclptr.hxx> +#include <vcl/outdev.hxx> + +class StyleSettings; +class ScDocument; + +/** + * This class takes care of physically drawing field button controls inside + * data pilot tables. + */ +class ScDPFieldButton +{ +public: + ScDPFieldButton(OutputDevice* pOutDev, const StyleSettings* pStyle, const Fraction* pZoomY = nullptr, + ScDocument* pDoc = nullptr); + ~ScDPFieldButton(); + + void setText(const OUString& rText); + void setBoundingBox(const Point& rPos, const Size& rSize, bool bLayoutRTL); + void setDrawBaseButton(bool b); + void setDrawPopupButton(bool b); + void setHasHiddenMember(bool b); + void setPopupPressed(bool b); + void setPopupLeft(bool b); + void draw(); + + void getPopupBoundingBox(Point& rPos, Size& rSize) const; + +private: + void drawPopupButton(); + +private: + Point maPos; + Size maSize; + OUString maText; + Fraction maZoomY; + ScDocument* mpDoc; + VclPtr<OutputDevice> mpOutDev; + const StyleSettings* mpStyle; + bool mbBaseButton; + bool mbPopupButton; + bool mbHasHiddenMember; + bool mbPopupPressed; + bool mbPopupLeft; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/dpgroupdlg.hxx b/sc/source/ui/inc/dpgroupdlg.hxx new file mode 100644 index 000000000..d1b365877 --- /dev/null +++ b/sc/source/ui/inc/dpgroupdlg.hxx @@ -0,0 +1,142 @@ +/* -*- 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_SC_SOURCE_UI_INC_DPGROUPDLG_HXX +#define INCLUDED_SC_SOURCE_UI_INC_DPGROUPDLG_HXX + +#include <vcl/weld.hxx> +#include <dpnumgroupinfo.hxx> + +class ScDoubleField; +class SvtCalendarBox; + +class ScDPGroupEditHelper +{ +public: + explicit ScDPGroupEditHelper(weld::RadioButton& rRbAuto, + weld::RadioButton& rRbMan, + weld::Widget& rEdValue); + + bool IsAuto() const; + double GetValue() const; + void SetValue( bool bAuto, double fValue ); + +protected: + ~ScDPGroupEditHelper() {} + +private: + virtual bool ImplGetValue( double& rfValue ) const = 0; + virtual void ImplSetValue( double fValue ) = 0; + + DECL_LINK(ClickHdl, weld::Button&, void); + +private: + weld::RadioButton& mrRbAuto; + weld::RadioButton& mrRbMan; + weld::Widget& mrEdValue; +}; + +class ScDPNumGroupEditHelper : public ScDPGroupEditHelper +{ +public: + explicit ScDPNumGroupEditHelper(weld::RadioButton& rRbAuto, + weld::RadioButton& rRbMan, + ScDoubleField& rEdValue); + + virtual ~ScDPNumGroupEditHelper() {} +private: + virtual bool ImplGetValue( double& rfValue ) const override; + virtual void ImplSetValue( double fValue ) override; + +private: + ScDoubleField& mrEdValue; +}; + +class ScDPDateGroupEditHelper : public ScDPGroupEditHelper +{ +public: + explicit ScDPDateGroupEditHelper(weld::RadioButton& rRbAuto, + weld::RadioButton& rRbMan, + SvtCalendarBox& rEdValue, + const Date& rNullDate); + + virtual ~ScDPDateGroupEditHelper() {} + +private: + virtual bool ImplGetValue( double& rfValue ) const override; + virtual void ImplSetValue( double fValue ) override; + +private: + SvtCalendarBox& mrEdValue; + Date maNullDate; +}; + +class ScDPNumGroupDlg : public weld::GenericDialogController +{ +public: + explicit ScDPNumGroupDlg(weld::Window* pParent, const ScDPNumGroupInfo& rInfo); + virtual ~ScDPNumGroupDlg() override; + ScDPNumGroupInfo GetGroupInfo() const; + +private: + std::unique_ptr<weld::RadioButton> mxRbAutoStart; + std::unique_ptr<weld::RadioButton> mxRbManStart; + std::unique_ptr<ScDoubleField> mxEdStart; + std::unique_ptr<weld::RadioButton> mxRbAutoEnd; + std::unique_ptr<weld::RadioButton> mxRbManEnd; + std::unique_ptr<ScDoubleField> mxEdEnd; + std::unique_ptr<ScDoubleField> mxEdBy; + ScDPNumGroupEditHelper maStartHelper; + ScDPNumGroupEditHelper maEndHelper; +}; + +class ScDPDateGroupDlg : public weld::GenericDialogController +{ +public: + explicit ScDPDateGroupDlg(weld::Window* pParent, const ScDPNumGroupInfo& rInfo, + sal_Int32 nDatePart, const Date& rNullDate); + virtual ~ScDPDateGroupDlg() override; + ScDPNumGroupInfo GetGroupInfo() const; + sal_Int32 GetDatePart() const; + +private: + DECL_LINK(ClickHdl, weld::Button&, void); + + typedef std::pair<int, int> row_col; + DECL_LINK(CheckHdl, const row_col&, void); + +private: + std::unique_ptr<weld::RadioButton> mxRbAutoStart; + std::unique_ptr<weld::RadioButton> mxRbManStart; + std::unique_ptr<SvtCalendarBox> mxEdStart; + std::unique_ptr<weld::RadioButton> mxRbAutoEnd; + std::unique_ptr<weld::RadioButton> mxRbManEnd; + std::unique_ptr<SvtCalendarBox> mxEdEnd; + std::unique_ptr<weld::RadioButton> mxRbNumDays; + std::unique_ptr<weld::RadioButton> mxRbUnits; + std::unique_ptr<weld::SpinButton> mxEdNumDays; + std::unique_ptr<weld::TreeView> mxLbUnits; + std::unique_ptr<weld::Button> mxBtnOk; + ScDPDateGroupEditHelper maStartHelper; + ScDPDateGroupEditHelper maEndHelper; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/drawsh.hxx b/sc/source/ui/inc/drawsh.hxx new file mode 100644 index 000000000..62d3a6951 --- /dev/null +++ b/sc/source/ui/inc/drawsh.hxx @@ -0,0 +1,99 @@ +/* -*- 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_SC_SOURCE_UI_INC_DRAWSH_HXX +#define INCLUDED_SC_SOURCE_UI_INC_DRAWSH_HXX + +#include <sfx2/shell.hxx> +#include <shellids.hxx> +#include <svx/svdtypes.hxx> +#include <tools/link.hxx> +#include <rtl/ref.hxx> + +class AbstractSvxObjectNameDialog; +class ScViewData; +class ScDrawView; +class SdrMarkList; +class SfxModule; +class SdrObject; + +namespace weld { class Window; } + +namespace svx::sidebar { class SelectionChangeHandler; } + +class ScDrawShell : public SfxShell +{ + ScViewData* pViewData; + ::rtl::Reference<svx::sidebar::SelectionChangeHandler> mpSelectionChangeHandler; + + DECL_LINK( NameObjectHdl, AbstractSvxObjectNameDialog&, bool ); + + void SetHlinkForObject( SdrObject* pObj, const OUString& rHlnk ); + +protected: + virtual void Activate(bool bMDI) override; + ScViewData* GetViewData() { return pViewData; } + +public: + SFX_DECL_INTERFACE(SCID_DRAW_SHELL) + +private: + /// SfxInterface initializer. + static void InitInterface_Impl(); + +public: + ScDrawShell(ScViewData* pData); + virtual ~ScDrawShell() override; + + static void StateDisableItems( SfxItemSet &rSet ); + + void ExecDrawAttr(SfxRequest& rReq); + void GetDrawAttrState(SfxItemSet &rSet); + void GetAttrFuncState(SfxItemSet &rSet); + + void ExecDrawFunc(SfxRequest& rReq); + void GetDrawFuncState(SfxItemSet &rSet); + void GetState(SfxItemSet &rSet); + + void ExecFormText(const SfxRequest& rReq); // StarFontWork + void GetFormTextState(SfxItemSet& rSet); + + void ExecuteHLink(const SfxRequest& rReq); // Hyperlink + void GetHLinkState(SfxItemSet& rSet); + + void ExecFormatPaintbrush(const SfxRequest& rReq); + void StateFormatPaintbrush(SfxItemSet& rSet); + + void ExecuteMacroAssign(SdrObject* pObj, weld::Window* pWin); + void ExecuteLineDlg( const SfxRequest& rReq ); + void ExecuteAreaDlg( const SfxRequest& rReq ); + void ExecuteTextAttrDlg( SfxRequest& rReq ); + void ExecuteMeasureDlg( SfxRequest& rReq ); + + ScDrawView* GetDrawView(); + + static bool AreAllObjectsOnLayer(SdrLayerID nLayerNo,const SdrMarkList& rMark); + + void GetDrawAttrStateForIFBX( SfxItemSet& rSet ); + OUString const & GetSidebarContextName(); +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/drawutil.hxx b/sc/source/ui/inc/drawutil.hxx new file mode 100644 index 000000000..0623347f8 --- /dev/null +++ b/sc/source/ui/inc/drawutil.hxx @@ -0,0 +1,41 @@ +/* -*- 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_SC_SOURCE_UI_INC_DRAWUTIL_HXX +#define INCLUDED_SC_SOURCE_UI_INC_DRAWUTIL_HXX + +#include <types.hxx> + +class Fraction; +class OutputDevice; +class ScDocument; + +class ScDrawUtil +{ +public: + static void CalcScale( const ScDocument* pDoc, SCTAB nTab, + SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, + const OutputDevice* pDev, const Fraction& rZoomX, const Fraction& rZoomY, + double nPPTX, double nPPTY, + Fraction& rScaleX, Fraction& rScaleY ); +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/drawview.hxx b/sc/source/ui/inc/drawview.hxx new file mode 100644 index 000000000..444ce0d7b --- /dev/null +++ b/sc/source/ui/inc/drawview.hxx @@ -0,0 +1,183 @@ +/* -*- 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_SC_SOURCE_UI_INC_DRAWVIEW_HXX +#define INCLUDED_SC_SOURCE_UI_INC_DRAWVIEW_HXX + +#include <svx/fmview.hxx> + +#include <global.hxx> + +namespace com::sun::star::datatransfer { class XTransferable; } + +class ScDocument; +class ScViewData; +class ScDrawObjData; +class SdrUndoManager; + +class ScDrawView final : public FmFormView +{ + ScViewData* pViewData; + VclPtr<OutputDevice> pDev; //! needed ? + ScDocument* pDoc; + SCTAB nTab; + Fraction aScaleX; // Factor for Drawing-MapMode + Fraction aScaleY; + std::unique_ptr<SdrDropMarkerOverlay> pDropMarker; + SdrObject* pDropMarkObj; + bool bInConstruct; + + void Construct(); + + virtual void ModelHasChanged() override; + + // add custom handles (used by other apps, e.g. AnchorPos) + virtual void AddCustomHdl() override; + + void ImplClearCalcDropMarker(); + + // support enhanced text edit for draw objects + virtual SdrUndoManager* getSdrUndoManagerForEnhancedTextEdit() const override; + +public: + ScDrawView( + OutputDevice* pOut, + ScViewData* pData); + + virtual ~ScDrawView() override; + + virtual void MarkListHasChanged() override; + virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override; + + virtual void DoConnect(SdrOle2Obj* pOleObj) override; + + virtual void MakeVisible( const tools::Rectangle& rRect, vcl::Window& rWin ) override; + + virtual void DeleteMarked() override; + + virtual bool SdrBeginTextEdit( + SdrObject* pObj, + SdrPageView* pPV = nullptr, + vcl::Window* pWin = nullptr, + bool bIsNewObj = false, + SdrOutliner* pGivenOutliner = nullptr, + OutlinerView* pGivenOutlinerView = nullptr, + bool bDontDeleteOutliner = false, + bool bOnlyOneView = false, + bool bGrabFocus = true) override; + + virtual SdrEndTextEditKind SdrEndTextEdit( bool bDontDeleteReally = false ) override; + + void MarkDropObj( SdrObject* pObj ); + + void SetMarkedToLayer( SdrLayerID nLayerNo ); + + void InvalidateAttribs(); + void InvalidateDrawTextAttrs(); + + void BeginDrag( vcl::Window* pWindow, const Point& rStartPos ); + void DoCut(); + void DoCopy(); + + void GetScale( Fraction& rFractX, Fraction& rFractY ) const; + void RecalcScale(); + void UpdateWorkArea(); + SCTAB GetTab() const { return nTab; } + + void CalcNormScale( Fraction& rFractX, Fraction& rFractY ) const; + + void SetPageAnchored(); + void SetCellAnchored(bool bResizeWithCell); + ScAnchorType GetAnchorType() const; + + void UpdateIMap( SdrObject* pObj ); + + void UpdateUserViewOptions(); + + void SetMarkedOriginalSize(); + void FitToCellSize(); + + bool SelectObject( const OUString& rName ); + bool HasMarkedControl() const; + bool HasMarkedInternal() const; + + bool InsertObjectSafe(SdrObject* pObj, SdrPageView& rPV); + + /** Returns the selected object, if it is the caption object of a cell note. + @param ppCaptData (out-param) If not null, returns the pointer to the caption object data. */ + SdrObject* GetMarkedNoteCaption( ScDrawObjData** ppCaptData ); + + /** Locks/unlocks the specified layer in the draw page. + Unlocked layer is required to be able to edit the contained objects. */ + void LockCalcLayer( SdrLayerID nLayer, bool bLock ); + + /** Locks/unlocks the background layer that contains background objects. + Unlocked layer is required to be able to edit the objects. */ + void LockBackgroundLayer( bool bLock ) { LockCalcLayer( SC_LAYER_BACK, bLock ); } + + /** Locks/unlocks the internal layer that contains caption objects of cell notes. + Unlocked layer is required to be able to edit the contained objects. */ + void LockInternalLayer( bool bLock = true ) { LockCalcLayer( SC_LAYER_INTERN, bLock ); } + /** Unlocks the internal layer that contains caption objects of cell notes. */ + void UnlockInternalLayer() { LockInternalLayer( false ); } + + SdrEndTextEditKind ScEndTextEdit(); // calls SetDrawTextUndo(0) + css::uno::Reference< css::datatransfer::XTransferable > CopyToTransferable(); + + SdrObject* GetObjectByName(const OUString& rName); + bool GetObjectIsMarked( const SdrObject * pObject ); + void SelectCurrentViewObject( const OUString& rName ); + + // #i123922# helper which checks if a Graphic may be applied to an existing + // SdrObject; if it's a SdrGrafObj the fill will be replaced. If it's a + // fillable, non-OLE SdrObject, the FillStyle will be adapted + SdrObject* ApplyGraphicToObject( + SdrObject& rHitObject, + const Graphic& rGraphic, + const OUString& rBeginUndoText, + const OUString& rFile, + const OUString& rFilter); + + static void CheckOle( const SdrMarkList& rMarkList, bool& rAnyOle, bool& rOneOle ); + + void SyncForGrid( SdrObject* pObj ); + + bool calculateGridOffsetForSdrObject( + SdrObject& rSdrObject, + basegfx::B2DVector& rTarget) const; + bool calculateGridOffsetForB2DRange( + const basegfx::B2DRange& rB2DRange, + basegfx::B2DVector& rTarget) const; + void resetGridOffsetsForAllSdrPageViews(); + + /// See SdrMarkView::GetSfxViewShell(). + SfxViewShell* GetSfxViewShell() const override; + + // Do not create ObjectContact locally, but offer a call to allow override + // and to create own derivations of ObjectContact + virtual sdr::contact::ObjectContact* createViewSpecificObjectContact( + SdrPageWindow& rPageWindow, + const char* pDebugName) const override; +}; + +extern Point aDragStartDiff; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/drformsh.hxx b/sc/source/ui/inc/drformsh.hxx new file mode 100644 index 000000000..63ee223df --- /dev/null +++ b/sc/source/ui/inc/drformsh.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_SC_SOURCE_UI_INC_DRFORMSH_HXX +#define INCLUDED_SC_SOURCE_UI_INC_DRFORMSH_HXX + +#include <sfx2/shell.hxx> +#include <shellids.hxx> + +class ScViewData; +class SfxModule; + +#include "drawsh.hxx" + +class ScDrawFormShell : public ScDrawShell +{ +public: + SFX_DECL_INTERFACE(SCID_FORM_SHELL) + +private: + /// SfxInterface initializer. + static void InitInterface_Impl(); + +public: + ScDrawFormShell(ScViewData* pData); + virtual ~ScDrawFormShell() override; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/drtxtob.hxx b/sc/source/ui/inc/drtxtob.hxx new file mode 100644 index 000000000..83c75b552 --- /dev/null +++ b/sc/source/ui/inc/drtxtob.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_SC_SOURCE_UI_INC_DRTXTOB_HXX +#define INCLUDED_SC_SOURCE_UI_INC_DRTXTOB_HXX + +#include <sfx2/shell.hxx> +#include <tools/link.hxx> +#include <rtl/ref.hxx> + +#include <shellids.hxx> + +sal_uInt16 ScGetFontWorkId(); // instead of SvxFontWorkChildWindow::GetChildWindowId() + +class SfxModule; +class ScViewData; +class TransferableDataHelper; +class TransferableClipboardListener; + +class ScDrawTextObjectBar : public SfxShell +{ + ScViewData* pViewData; + rtl::Reference<TransferableClipboardListener> mxClipEvtLstnr; + bool bPastePossible; + + DECL_LINK( ClipboardChanged, TransferableDataHelper*, void ); + +public: + SFX_DECL_INTERFACE(SCID_DRAW_TEXT_SHELL) + +private: + /// SfxInterface initializer. + static void InitInterface_Impl(); + +public: + ScDrawTextObjectBar(ScViewData* pData); + virtual ~ScDrawTextObjectBar() override; + + static void StateDisableItems( SfxItemSet &rSet ); + + void Execute( SfxRequest &rReq ); + void ExecuteTrans( const SfxRequest& rReq ); + void GetState( SfxItemSet& rSet ); + void GetClipState( SfxItemSet& rSet ); + + void ExecuteAttr( SfxRequest &rReq ); + void GetAttrState( SfxItemSet& rSet ); + void ExecuteToggle( SfxRequest &rReq ); + void GetStatePropPanelAttr(SfxItemSet &); + + bool ExecuteCharDlg( const SfxItemSet& rArgs, SfxItemSet& rOutSet , sal_uInt16 nSlot); + bool ExecuteParaDlg( const SfxItemSet& rArgs, SfxItemSet& rOutSet ); + + void ExecuteExtra( SfxRequest &rReq ); + void ExecFormText(const SfxRequest& rReq); // StarFontWork + void GetFormTextState(SfxItemSet& rSet); + +private: + void ExecuteGlobal( SfxRequest &rReq ); // called by Execute for all objects + static void GetGlobalClipState( SfxItemSet& rSet ); + void ExecutePasteContents( SfxRequest &rReq ); + bool IsNoteEdit() const; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/drwtrans.hxx b/sc/source/ui/inc/drwtrans.hxx new file mode 100644 index 000000000..50e56cac1 --- /dev/null +++ b/sc/source/ui/inc/drwtrans.hxx @@ -0,0 +1,102 @@ +/* -*- 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_SC_SOURCE_UI_INC_DRWTRANS_HXX +#define INCLUDED_SC_SOURCE_UI_INC_DRWTRANS_HXX + +#include <com/sun/star/uno/Reference.hxx> +#include <vcl/transfer.hxx> + +#include <sfx2/objsh.hxx> +#include <charthelper.hxx> + +class SdrModel; +class ScDocShell; +class INetBookmark; +class SdrObject; +class SdrView; +class ScDrawView; +class SdrOle2Obj; +enum class ScDragSrc; + +class ScDrawTransferObj : public TransferDataContainer +{ +private: + std::unique_ptr<SdrModel> m_pModel; + TransferableDataHelper m_aOleData; + TransferableObjectDescriptor m_aObjDesc; + SfxObjectShellRef m_aDocShellRef; + SfxObjectShellRef m_aDrawPersistRef; + + // extracted from model in ctor: + Size m_aSrcSize; + std::unique_ptr<INetBookmark> m_pBookmark; + bool m_bGraphic; + bool m_bGrIsBit; + bool m_bOleObj; + // source information for drag&drop: + // (view is needed to handle drawing obejcts) + std::unique_ptr<SdrView> m_pDragSourceView; + ScDragSrc m_nDragSourceFlags; + bool m_bDragWasInternal; + + ScRangeListVector m_aProtectedChartRangesVector; + + OUString maShellID; + + void InitDocShell(); + SdrOle2Obj* GetSingleObject(); + + void CreateOLEData(); + +public: + ScDrawTransferObj( std::unique_ptr<SdrModel> pClipModel, ScDocShell* pContainerShell, + const TransferableObjectDescriptor& rDesc ); + virtual ~ScDrawTransferObj() override; + + virtual void AddSupportedFormats() override; + virtual bool GetData( const css::datatransfer::DataFlavor& rFlavor, const OUString& rDestDoc ) override; + virtual bool WriteObject( tools::SvRef<SotStorageStream>& rxOStm, void* pUserObject, sal_uInt32 nUserObjectId, + const css::datatransfer::DataFlavor& rFlavor ) override; + virtual void DragFinished( sal_Int8 nDropAction ) override; + + SdrModel* GetModel() const { return m_pModel.get(); } + + void SetDrawPersist( const SfxObjectShellRef& rRef ); + void SetDragSource( const ScDrawView* pView ); + void SetDragSourceObj( SdrObject& rObj, SCTAB nTab ); + void SetDragSourceFlags( ScDragSrc nFlags ); + void SetDragWasInternal(); + + const OUString& GetShellID() const; + + SdrView* GetDragSourceView() { return m_pDragSourceView.get(); } + ScDragSrc GetDragSourceFlags() const { return m_nDragSourceFlags; } + + static ScDrawTransferObj* GetOwnClipboard(const css::uno::Reference<css::datatransfer::XTransferable2>&); + + virtual sal_Int64 SAL_CALL getSomething( const css::uno::Sequence< sal_Int8 >& rId ) override; + static const css::uno::Sequence< sal_Int8 >& getUnoTunnelId(); + + const ScRangeListVector& GetProtectedChartRangesVector() const { return m_aProtectedChartRangesVector; } +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/dwfunctr.hxx b/sc/source/ui/inc/dwfunctr.hxx new file mode 100644 index 000000000..e9dc66132 --- /dev/null +++ b/sc/source/ui/inc/dwfunctr.hxx @@ -0,0 +1,80 @@ +/* -*- 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_SC_SOURCE_UI_INC_DWFUNCTR_HXX +#define INCLUDED_SC_SOURCE_UI_INC_DWFUNCTR_HXX + +#include <comphelper/configurationlistener.hxx> +#include <sfx2/sidebar/PanelLayout.hxx> + +class ScFuncDesc; +namespace formula { class IFunctionDescription; } + +class ScFunctionWin; + +class EnglishFunctionNameChange : public comphelper::ConfigurationListenerProperty<bool> +{ + VclPtr<ScFunctionWin> m_xFunctionWin; +protected: + virtual void setProperty(const css::uno::Any &rProperty) override; +public: + EnglishFunctionNameChange(const rtl::Reference<comphelper::ConfigurationListener> &rListener, ScFunctionWin* pFunctionWin) + : ConfigurationListenerProperty(rListener, "EnglishFunctionName") + , m_xFunctionWin(pFunctionWin) + { + } +}; + +class ScFunctionWin : public PanelLayout +{ + +private: + std::unique_ptr<weld::ComboBox> xCatBox; + std::unique_ptr<weld::TreeView> xFuncList; + std::unique_ptr<weld::Button> xInsertButton; + std::unique_ptr<weld::Label> xFiFuncDesc; + + rtl::Reference<comphelper::ConfigurationListener> xConfigListener; + std::unique_ptr<EnglishFunctionNameChange> xConfigChange; + const ScFuncDesc* pFuncDesc; + sal_uInt16 nArgs; + + ::std::vector< const formula::IFunctionDescription*> aLRUList; + + void UpdateLRUList(); + void DoEnter(); + void SetDescription(); + + DECL_LINK( SetRowActivatedHdl, weld::TreeView&, bool ); + DECL_LINK( SetSelectionClickHdl, weld::Button&, void ); + DECL_LINK( SelComboHdl, weld::ComboBox&, void ); + DECL_LINK( SelTreeHdl, weld::TreeView&, void ); + +public: + ScFunctionWin(vcl::Window* pParent, const css::uno::Reference<css::frame::XFrame> &rFrame); + + virtual ~ScFunctionWin() override; + virtual void dispose() override; + + void InitLRUList(); + void UpdateFunctionList(); +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/editable.hxx b/sc/source/ui/inc/editable.hxx new file mode 100644 index 000000000..2e86c1270 --- /dev/null +++ b/sc/source/ui/inc/editable.hxx @@ -0,0 +1,91 @@ +/* -*- 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_SC_SOURCE_UI_INC_EDITABLE_HXX +#define INCLUDED_SC_SOURCE_UI_INC_EDITABLE_HXX + +#include <address.hxx> + +class ScDocument; +class ScViewFunc; +class ScMarkData; + +namespace sc { + +enum class ColRowEditAction; + +} + +class ScEditableTester +{ + bool mbIsEditable; + bool mbOnlyMatrix; + +public: + ScEditableTester(); + + // calls TestBlock + /** @param bNoMatrixAtAll + TRUE if there must not be any matrix, not even entirely + contained; for example in sorting. */ + ScEditableTester( const ScDocument* pDoc, SCTAB nTab, + SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, + bool bNoMatrixAtAll = false ); + + // calls TestSelectedBlock + ScEditableTester( const ScDocument* pDoc, + SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, + const ScMarkData& rMark ); + + // calls TestRange + ScEditableTester( const ScDocument* pDoc, const ScRange& rRange ); + + // calls TestSelection + ScEditableTester( const ScDocument* pDoc, const ScMarkData& rMark ); + + // calls TestView + ScEditableTester( ScViewFunc* pView ); + + ScEditableTester( + const ScDocument& rDoc, sc::ColRowEditAction eAction, SCCOLROW nStart, SCCOLROW nEnd, + const ScMarkData& rMark ); + + // Several calls to the Test... methods check if *all* of the ranges + // are editable. For several independent checks, Reset() has to be used. + void TestBlock( const ScDocument* pDoc, SCTAB nTab, + SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, + bool bNoMatrixAtAll = false ); + void TestSelectedBlock( const ScDocument* pDoc, + SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, + const ScMarkData& rMark ); + void TestRange( const ScDocument* pDoc, const ScRange& rRange ); + void TestSelection( const ScDocument* pDoc, const ScMarkData& rMark ); + + void TestBlockForAction( + const ScDocument& rDoc, sc::ColRowEditAction eAction, SCCOLROW nStart, SCCOLROW nEnd, + const ScMarkData& rMark ); + + bool IsEditable() const { return mbIsEditable; } + bool IsFormatEditable() const { return mbIsEditable || mbOnlyMatrix; } + const char* GetMessageId() const; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/editfield.hxx b/sc/source/ui/inc/editfield.hxx new file mode 100644 index 000000000..ca5bab36f --- /dev/null +++ b/sc/source/ui/inc/editfield.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/. + * + * 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_SC_SOURCE_UI_INC_EDITFIELD_HXX +#define INCLUDED_SC_SOURCE_UI_INC_EDITFIELD_HXX + +#include <vcl/weld.hxx> + +/** An edit control that contains a double precision floating-point value. */ +class ScDoubleField +{ +private: + std::unique_ptr<weld::Entry> m_xEntry; + +public: + explicit ScDoubleField(std::unique_ptr<weld::Entry> xEntry); + + bool GetValue(double& rfValue) const; + void SetValue(double fValue, sal_Int32 nDecPlaces = 12); + + weld::Entry& get_widget() { return *m_xEntry; } + + void grab_focus() { m_xEntry->grab_focus(); } + bool get_sensitive() const { return m_xEntry->get_sensitive(); } + void set_sensitive(bool bSensitive) { m_xEntry->set_sensitive(bSensitive); } +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/editsh.hxx b/sc/source/ui/inc/editsh.hxx new file mode 100644 index 000000000..7eb432b1f --- /dev/null +++ b/sc/source/ui/inc/editsh.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_SC_SOURCE_UI_INC_EDITSH_HXX +#define INCLUDED_SC_SOURCE_UI_INC_EDITSH_HXX + +#include <sfx2/shell.hxx> +#include <tools/link.hxx> +#include <rtl/ref.hxx> + +#include <shellids.hxx> + +class SfxModule; +class EditView; +class ScViewData; +class ScInputHandler; +class SvxURLField; +class TransferableDataHelper; +class TransferableClipboardListener; + +class ScEditShell : public SfxShell +{ +private: + EditView* pEditView; + ScViewData* pViewData; + rtl::Reference<TransferableClipboardListener> mxClipEvtLstnr; + bool bPastePossible; + bool bIsInsertMode; + + const SvxURLField* GetURLField(); + ScInputHandler* GetMyInputHdl(); + + DECL_LINK( ClipboardChanged, TransferableDataHelper*, void ); + +public: + SFX_DECL_INTERFACE(SCID_EDIT_SHELL) + +private: + /// SfxInterface initializer. + static void InitInterface_Impl(); + +public: + ScEditShell(EditView* pView, ScViewData* pData); + virtual ~ScEditShell() override; + + void SetEditView(EditView* pView); + EditView* GetEditView() {return pEditView;} + + void Execute(SfxRequest& rReq); + void ExecuteTrans(const SfxRequest& rReq); + void GetState(SfxItemSet &rSet); + void GetClipState(SfxItemSet& rSet); + + void ExecuteAttr(SfxRequest& rReq); + void GetAttrState(SfxItemSet &rSet); + + void ExecuteUndo(const SfxRequest& rReq); + void GetUndoState(SfxItemSet &rSet); + + OUString GetSelectionText( bool bWholeWord ); +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/filldlg.hxx b/sc/source/ui/inc/filldlg.hxx new file mode 100644 index 000000000..6c7688920 --- /dev/null +++ b/sc/source/ui/inc/filldlg.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_SC_SOURCE_UI_INC_FILLDLG_HXX +#define INCLUDED_SC_SOURCE_UI_INC_FILLDLG_HXX + +#include <vcl/weld.hxx> +#include <global.hxx> + +class ScDocument; + +class ScFillSeriesDlg : public weld::GenericDialogController +{ +public: + ScFillSeriesDlg( weld::Window* pParent, + ScDocument& rDocument, + FillDir eFillDir, + FillCmd eFillCmd, + FillDateCmd eFillDateCmd, + const OUString& aStartStr, + double fStep, + double fMax, + SCSIZE nSelectHeight, + SCSIZE nSelectWidth, + sal_uInt16 nPossDir ); + virtual ~ScFillSeriesDlg() override; + + FillDir GetFillDir() const { return theFillDir; } + FillCmd GetFillCmd() const { return theFillCmd; } + FillDateCmd GetFillDateCmd() const { return theFillDateCmd; } + double GetStart() const { return fStartVal; } + double GetStep() const { return fIncrement; } + double GetMax() const { return fEndVal; } + + OUString GetStartStr() const { return m_xEdStartVal->get_text(); } + + void SetEdStartValEnabled(bool bFlag); + +private: + const OUString aStartStrVal; + const OUString aErrMsgInvalidVal; + + ScDocument& rDoc; + FillDir theFillDir; + FillCmd theFillCmd; + FillDateCmd theFillDateCmd; + double fStartVal; + double fIncrement; + double fEndVal; + const SCSIZE m_nSelectHeight; + const SCSIZE m_nSelectWidth; + + std::unique_ptr<weld::Label> m_xFtStartVal; + std::unique_ptr<weld::Entry> m_xEdStartVal; + + std::unique_ptr<weld::Label> m_xFtEndVal; + std::unique_ptr<weld::Entry> m_xEdEndVal; + + std::unique_ptr<weld::Label> m_xFtIncrement; + std::unique_ptr<weld::Entry> m_xEdIncrement; + std::unique_ptr<weld::RadioButton> m_xBtnDown; + std::unique_ptr<weld::RadioButton> m_xBtnRight; + std::unique_ptr<weld::RadioButton> m_xBtnUp; + std::unique_ptr<weld::RadioButton> m_xBtnLeft; + + std::unique_ptr<weld::RadioButton> m_xBtnArithmetic; + std::unique_ptr<weld::RadioButton> m_xBtnGeometric; + std::unique_ptr<weld::RadioButton> m_xBtnDate; + std::unique_ptr<weld::RadioButton> m_xBtnAutoFill; + + std::unique_ptr<weld::Label> m_xFtTimeUnit; + std::unique_ptr<weld::RadioButton> m_xBtnDay; + std::unique_ptr<weld::RadioButton> m_xBtnDayOfWeek; + std::unique_ptr<weld::RadioButton> m_xBtnMonth; + std::unique_ptr<weld::RadioButton> m_xBtnYear; + + std::unique_ptr<weld::Button> m_xBtnOk; + + void Init( sal_uInt16 nPossDir ); + weld::Entry* CheckValues(); + + DECL_LINK(OKHdl, weld::Button&, void); + DECL_LINK(DisableHdl, weld::ToggleButton&, void); +}; + +#endif // INCLUDED_SC_SOURCE_UI_INC_FILLDLG_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/filtdlg.hxx b/sc/source/ui/inc/filtdlg.hxx new file mode 100644 index 000000000..8445f1c46 --- /dev/null +++ b/sc/source/ui/inc/filtdlg.hxx @@ -0,0 +1,227 @@ +/* -*- 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_SC_SOURCE_UI_INC_FILTDLG_HXX +#define INCLUDED_SC_SOURCE_UI_INC_FILTDLG_HXX + +#include <address.hxx> +#include "anyrefdg.hxx" +#include <queryparam.hxx> +#include <filterentries.hxx> + +#include <memory> +#include <deque> +#include <vector> +#include <map> + +class ScFilterOptionsMgr; +class ScViewData; +class ScDocument; +class ScQueryItem; + +class ScFilterDlg : public ScAnyRefDlgController +{ + struct EntryList + { + ScFilterEntries maFilterEntries; + size_t mnHeaderPos; + + EntryList(const EntryList&) = delete; + const EntryList& operator=(const EntryList&) = delete; + + EntryList(); + }; + typedef std::map<SCCOL, std::unique_ptr<EntryList>> EntryListsMap; +public: + ScFilterDlg(SfxBindings* pB, SfxChildWindow* pCW, weld::Window* pParent, + const SfxItemSet& rArgSet); + virtual ~ScFilterDlg() override; + + virtual void SetReference( const ScRange& rRef, ScDocument& rDoc ) override; + + virtual bool IsRefInputMode() const override; + virtual void SetActive() override; + + virtual void Close() override; + void SliderMoved(); + size_t GetSliderPos() const; + void RefreshEditRow( size_t nOffset ); + +private: + const OUString aStrUndefined; + const OUString aStrNone; + + const OUString aStrEmpty; + const OUString aStrNotEmpty; + const OUString aStrColumn; + + std::unique_ptr<ScFilterOptionsMgr> pOptionsMgr; + + const sal_uInt16 nWhichQuery; + ScQueryParam theQueryData; + std::unique_ptr<ScQueryItem> pOutItem; + ScViewData* pViewData; + ScDocument* pDoc; + SCTAB nSrcTab; + + std::vector<weld::ComboBox*> maValueEdArr; + std::vector<weld::ComboBox*> maFieldLbArr; + std::vector<weld::ComboBox*> maCondLbArr; + std::vector<weld::ComboBox*> maConnLbArr; + + std::deque<bool> maHasDates; + std::deque<bool> maRefreshExceptQuery; + bool bRefInputMode; + + EntryListsMap m_EntryLists; + + // Hack: RefInput control + std::unique_ptr<Timer> pTimer; + + std::unique_ptr<weld::ComboBox> m_xLbConnect1; + std::unique_ptr<weld::ComboBox> m_xLbField1; + std::unique_ptr<weld::ComboBox> m_xLbCond1; + std::unique_ptr<weld::ComboBox> m_xEdVal1; + + std::unique_ptr<weld::ComboBox> m_xLbConnect2; + std::unique_ptr<weld::ComboBox> m_xLbField2; + std::unique_ptr<weld::ComboBox> m_xLbCond2; + std::unique_ptr<weld::ComboBox> m_xEdVal2; + + std::unique_ptr<weld::ComboBox> m_xLbConnect3; + std::unique_ptr<weld::ComboBox> m_xLbField3; + std::unique_ptr<weld::ComboBox> m_xLbCond3; + std::unique_ptr<weld::ComboBox> m_xEdVal3; + + std::unique_ptr<weld::ComboBox> m_xLbConnect4; + std::unique_ptr<weld::ComboBox> m_xLbField4; + std::unique_ptr<weld::ComboBox> m_xLbCond4; + std::unique_ptr<weld::ComboBox> m_xEdVal4; + + std::unique_ptr<weld::Widget> m_xContents; + std::unique_ptr<weld::ScrolledWindow> m_xScrollBar; + std::unique_ptr<weld::Expander> m_xExpander; + + std::unique_ptr<weld::Button> m_xBtnOk; + std::unique_ptr<weld::Button> m_xBtnCancel; + + std::unique_ptr<weld::CheckButton> m_xBtnCase; + std::unique_ptr<weld::CheckButton> m_xBtnRegExp; + std::unique_ptr<weld::CheckButton> m_xBtnHeader; + std::unique_ptr<weld::CheckButton> m_xBtnUnique; + std::unique_ptr<weld::CheckButton> m_xBtnCopyResult; + std::unique_ptr<weld::ComboBox> m_xLbCopyArea; + std::unique_ptr<formula::RefEdit> m_xEdCopyArea; + std::unique_ptr<formula::RefButton> m_xRbCopyArea; + std::unique_ptr<weld::CheckButton> m_xBtnDestPers; + std::unique_ptr<weld::Label> m_xFtDbAreaLabel; + std::unique_ptr<weld::Label> m_xFtDbArea; + +private: + void Init ( const SfxItemSet& rArgSet ); + void FillFieldLists (); + void UpdateValueList ( size_t nList ); + void UpdateHdrInValueList( size_t nList ); + void ClearValueList ( size_t nList ); + size_t GetFieldSelPos ( SCCOL nField ); + ScQueryItem* GetOutputItem (); + + // Handler: + DECL_LINK( LbSelectHdl, weld::ComboBox&, void ); + DECL_LINK( ValModifyHdl, weld::ComboBox&, void ); + DECL_LINK( CheckBoxHdl, weld::Button&, void ); + DECL_LINK( EndDlgHdl, weld::Button&, void ); + DECL_LINK( ScrollHdl, weld::ScrolledWindow&, void ); + DECL_LINK( MoreExpandedHdl, weld::Expander&, void ); + + // Hack: RefInput control + DECL_LINK( TimeOutHdl, Timer*, void ); +}; + +class ScSpecialFilterDlg : public ScAnyRefDlgController +{ +public: + ScSpecialFilterDlg(SfxBindings* pB, SfxChildWindow* pCW, weld::Window* pParent, + const SfxItemSet& rArgSet); + virtual ~ScSpecialFilterDlg() override; + + virtual void SetReference( const ScRange& rRef, ScDocument& rDoc ) override; + + virtual bool IsRefInputMode() const override; + virtual void SetActive() override; + + virtual void Close() override; + +private: + const OUString aStrUndefined; + + std::unique_ptr<ScFilterOptionsMgr> pOptionsMgr; + + const sal_uInt16 nWhichQuery; + const ScQueryParam theQueryData; + std::unique_ptr<ScQueryItem> pOutItem; + ScViewData* pViewData; + ScDocument* pDoc; + + bool bRefInputMode; + + formula::RefEdit* m_pRefInputEdit; + + std::unique_ptr<weld::ComboBox> m_xLbFilterArea; + std::unique_ptr<formula::RefEdit> m_xEdFilterArea; + std::unique_ptr<formula::RefButton> m_xRbFilterArea; + + std::unique_ptr<weld::Expander> m_xExpander; + std::unique_ptr<weld::CheckButton> m_xBtnCase; + std::unique_ptr<weld::CheckButton> m_xBtnRegExp; + std::unique_ptr<weld::CheckButton> m_xBtnHeader; + std::unique_ptr<weld::CheckButton> m_xBtnUnique; + std::unique_ptr<weld::CheckButton> m_xBtnCopyResult; + std::unique_ptr<weld::ComboBox> m_xLbCopyArea; + std::unique_ptr<formula::RefEdit> m_xEdCopyArea; + std::unique_ptr<formula::RefButton> m_xRbCopyArea; + std::unique_ptr<weld::CheckButton> m_xBtnDestPers; + std::unique_ptr<weld::Label> m_xFtDbAreaLabel; + std::unique_ptr<weld::Label> m_xFtDbArea; + + std::unique_ptr<weld::Button> m_xBtnOk; + std::unique_ptr<weld::Button> m_xBtnCancel; + + std::unique_ptr<weld::Frame> m_xFilterFrame; + std::unique_ptr<weld::Label> m_xFilterLabel; + +private: + void Init( const SfxItemSet& rArgSet ); + ScQueryItem* GetOutputItem( const ScQueryParam& rParam, + const ScRange& rSource ); + + // Handler + DECL_LINK( FilterAreaSelHdl, weld::ComboBox&, void ); + DECL_LINK( FilterAreaModHdl, formula::RefEdit&, void ); + DECL_LINK( EndDlgHdl, weld::Button&, void ); + + // RefInput control + DECL_LINK( RefInputEditHdl, formula::RefEdit&, void ); + DECL_LINK( RefInputButtonHdl, formula::RefButton&, void ); + void RefInputHdl(); +}; + +#endif // INCLUDED_SC_SOURCE_UI_INC_FILTDLG_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/foptmgr.hxx b/sc/source/ui/inc/foptmgr.hxx new file mode 100644 index 000000000..b26ffbe1d --- /dev/null +++ b/sc/source/ui/inc/foptmgr.hxx @@ -0,0 +1,85 @@ +/* -*- 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_SC_SOURCE_UI_INC_FOPTMGR_HXX +#define INCLUDED_SC_SOURCE_UI_INC_FOPTMGR_HXX + +namespace formula +{ + class RefButton; + class RefButton; + class RefEdit; +} +struct ScQueryParam; +class ScDocument; +class ScViewData; + +class ScFilterOptionsMgr +{ +public: + ScFilterOptionsMgr(ScViewData* ptrViewData, + const ScQueryParam& refQueryData, + weld::CheckButton* refBtnCase, + weld::CheckButton* refBtnRegExp, + weld::CheckButton* refBtnHeader, + weld::CheckButton* refBtnUnique, + weld::CheckButton* refBtnCopyResult, + weld::CheckButton* refBtnDestPers, + weld::ComboBox* refLbCopyArea, + formula::RefEdit* refEdCopyArea, + formula::RefButton* refRbCopyArea, + weld::Label* refFtDbAreaLabel, + weld::Label* refFtDbArea, + const OUString& refStrUndefined ); + ~ScFilterOptionsMgr(); + bool VerifyPosStr ( const OUString& rPosStr ) const; + +private: + ScViewData* pViewData; + ScDocument* pDoc; + + weld::CheckButton* pBtnCase; + weld::CheckButton* pBtnRegExp; + weld::CheckButton* pBtnHeader; + weld::CheckButton* pBtnUnique; + weld::CheckButton* pBtnCopyResult; + weld::CheckButton* pBtnDestPers; + weld::ComboBox* pLbCopyArea; + formula::RefEdit* pEdCopyArea; + formula::RefButton* pRbCopyArea; + weld::Label* pFtDbAreaLabel; + weld::Label* pFtDbArea; + + const OUString& rStrUndefined; + + const ScQueryParam& rQueryData; + +private: + void Init(); + + // Handler: + DECL_LINK( EdAreaModifyHdl, formula::RefEdit&, void ); + DECL_LINK( LbAreaSelHdl, weld::ComboBox&, void ); + DECL_LINK( BtnCopyResultHdl, weld::ToggleButton&, void ); +}; + + +#endif // INCLUDED_SC_SOURCE_UI_INC_FOPTMGR_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/formatsh.hxx b/sc/source/ui/inc/formatsh.hxx new file mode 100644 index 000000000..ad1c55b50 --- /dev/null +++ b/sc/source/ui/inc/formatsh.hxx @@ -0,0 +1,78 @@ +/* -*- 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_SC_SOURCE_UI_INC_FORMATSH_HXX +#define INCLUDED_SC_SOURCE_UI_INC_FORMATSH_HXX + +#include <sfx2/shell.hxx> +#include <shellids.hxx> + +class SfxModule; +class ScViewData; +enum class SvNumFormatType : sal_Int16; + +class ScFormatShell: public SfxShell +{ + ScViewData* pViewData; + +protected: + ScViewData* GetViewData(){return pViewData;} + const ScViewData* GetViewData() const {return pViewData;} + +public: + SFX_DECL_INTERFACE(SCID_FORMAT_SHELL) + +private: + /// SfxInterface initializer. + static void InitInterface_Impl(); + +public: + ScFormatShell(ScViewData* pData); + virtual ~ScFormatShell() override; + + void ExecuteNumFormat( SfxRequest& rReq ); + void GetNumFormatState( SfxItemSet& rSet ); + + void ExecuteAttr( SfxRequest& rReq ); + void GetAttrState( SfxItemSet& rSet ); + + void ExecuteAlignment( SfxRequest& rReq ); + + void ExecuteTextAttr( SfxRequest& rReq ); + void GetTextAttrState( SfxItemSet& rSet ); + + void GetAlignState( SfxItemSet& rSet ); + void GetBorderState( SfxItemSet& rSet ); + + void ExecuteStyle( SfxRequest& rReq ); + void GetStyleState( SfxItemSet& rSet ); + + void ExecuteTextDirection( const SfxRequest& rReq ); + void GetTextDirectionState( SfxItemSet& rSet ); + + void ExecFormatPaintbrush( const SfxRequest& rReq ); + void StateFormatPaintbrush( SfxItemSet& rSet ); + +private: + SvNumFormatType GetCurrentNumberFormatType(); +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/formdata.hxx b/sc/source/ui/inc/formdata.hxx new file mode 100644 index 000000000..f7d7dca2e --- /dev/null +++ b/sc/source/ui/inc/formdata.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_SC_SOURCE_UI_INC_FORMDATA_HXX +#define INCLUDED_SC_SOURCE_UI_INC_FORMDATA_HXX + +#include <formula/formdata.hxx> +class ScInputHandler; +class ScDocShell; + +class ScFormEditData : public formula::FormEditData +{ +public: + ScFormEditData(); + virtual ~ScFormEditData() override; + + ScInputHandler* GetInputHandler() { return pInputHandler;} + ScDocShell* GetDocShell() { return pScDocShell;} + + void SetInputHandler(ScInputHandler* pHdl) { pInputHandler=pHdl;} + void SetDocShell(ScDocShell* pSds) { pScDocShell=pSds;} + + virtual void SaveValues() override; + +private: + ScFormEditData(ScFormEditData const &) = delete; + void operator =(ScFormEditData const &) = delete; + + ScInputHandler* pInputHandler; + ScDocShell* pScDocShell; +}; + +#endif // INCLUDED_SC_SOURCE_UI_INC_FORMDATA_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/formula.hxx b/sc/source/ui/inc/formula.hxx new file mode 100644 index 000000000..b404b20d6 --- /dev/null +++ b/sc/source/ui/inc/formula.hxx @@ -0,0 +1,106 @@ +/* -*- 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_SC_SOURCE_UI_INC_FORMULA_HXX +#define INCLUDED_SC_SOURCE_UI_INC_FORMULA_HXX + +#include <memory> +#include "anyrefdg.hxx" + +#include <formula/formula.hxx> +#include "IAnyRefDialog.hxx" + +class ScViewData; +class ScDocument; +class ScFuncDesc; +class ScInputHandler; +class ScDocShell; + +class ScFormulaDlg final : public formula::FormulaDlg, + public IAnyRefDialog +{ + ScFormulaReferenceHelper m_aHelper; + css::uno::Reference< css::sheet::XFormulaParser> m_xParser; + css::uno::Reference< css::sheet::XFormulaOpCodeMapper> m_xOpCodeMapper; + + ScDocument* m_pDoc; + ScAddress m_CursorPos; + ScTabViewShell* m_pViewShell; + mutable std::shared_ptr<ScCompiler> m_xCompiler; + +public: + ScFormulaDlg( SfxBindings* pB, SfxChildWindow* pCW, + weld::Window* pParent, const ScViewData* pViewData, const formula::IFunctionManager* _pFunctionMgr); + virtual ~ScFormulaDlg() COVERITY_NOEXCEPT_FALSE override; + + // IFormulaEditorHelper + virtual void notifyChange() override; + virtual void fill() override; + virtual bool calculateValue(const OUString& _sExpression, OUString& _rResult, bool bMatrixFormula) override; + virtual std::shared_ptr<formula::FormulaCompiler> getCompiler() const override; + virtual std::unique_ptr<formula::FormulaCompiler> createCompiler( formula::FormulaTokenArray& rArray ) const override; + virtual void doClose(bool _bOk) override; + virtual void insertEntryToLRUList(const formula::IFunctionDescription* pDesc) override; + virtual void showReference(const OUString& _sFormula) override; + virtual void dispatch(bool _bOK, bool _bMatrixChecked) override; + virtual void setDispatcherLock( bool bLock ) override; + virtual void deleteFormData() override; + virtual void clear() override; + virtual void switchBack() override; + virtual formula::FormEditData* getFormEditData() const override; + virtual void setCurrentFormula(const OUString& _sReplacement) override; + virtual void setSelection(sal_Int32 _nStart, sal_Int32 _nEnd) override; + virtual void getSelection(sal_Int32& _nStart, sal_Int32& _nEnd) const override; + virtual OUString getCurrentFormula() const override; + + virtual formula::IFunctionManager* getFunctionManager() override; + virtual ::std::unique_ptr<formula::FormulaTokenArray> convertToTokenArray(const css::uno::Sequence< css::sheet::FormulaToken >& _aTokenList) override; + virtual css::uno::Reference< css::sheet::XFormulaParser> getFormulaParser() const override; + virtual css::uno::Reference< css::sheet::XFormulaOpCodeMapper> getFormulaOpCodeMapper() const override; + virtual css::table::CellAddress getReferencePosition() const override; + + virtual void Close() override; + + // sc::IAnyRefDialog + virtual void ShowReference(const OUString& _sRef) override; + virtual void HideReference( bool bDoneRefMode = true ) override; + virtual void SetReference( const ScRange& rRef, ScDocument& rD ) override; + + virtual void ReleaseFocus( formula::RefEdit* pEdit ) override; + virtual void ToggleCollapsed( formula::RefEdit* pEdit, formula::RefButton* pButton ) override; + virtual void RefInputDone( bool bForced = false ) override; + virtual bool IsTableLocked() const override; + virtual bool IsRefInputMode() const override; + + virtual bool IsDocAllowed( SfxObjectShell* pDocSh ) const override; + virtual void AddRefEntry() override; + virtual void SetActive() override; + virtual void ViewShellChanged() override; + +private: + virtual void RefInputStart( formula::RefEdit* pEdit, formula::RefButton* pButton = nullptr ) override; + static void SaveLRUEntry(const ScFuncDesc* pFuncDesc); + + static bool IsInputHdl(const ScInputHandler* pHdl); + static ScInputHandler* GetNextInputHandler(const ScDocShell* pDocShell, ScTabViewShell** ppViewSh); +}; + +#endif // INCLUDED_SC_SOURCE_UI_INC_FORMULA_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/fuconarc.hxx b/sc/source/ui/inc/fuconarc.hxx new file mode 100644 index 000000000..c538e8f77 --- /dev/null +++ b/sc/source/ui/inc/fuconarc.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/. + * + * 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_SC_SOURCE_UI_INC_FUCONARC_HXX +#define INCLUDED_SC_SOURCE_UI_INC_FUCONARC_HXX + +#include "fuconstr.hxx" + +/** Draw rectangle */ +class FuConstArc : public FuConstruct +{ +public: + FuConstArc(ScTabViewShell& rViewSh, vcl::Window* pWin, ScDrawView* pView, + SdrModel* pDoc, const SfxRequest& rReq); + + virtual ~FuConstArc() override; + // Mouse- & Key-Events + virtual bool MouseButtonUp(const MouseEvent& rMEvt) override; + virtual bool MouseButtonDown(const MouseEvent& rMEvt) override; + + virtual void Activate() override; + virtual void Deactivate() override; + + // Create default drawing objects via keyboard + virtual SdrObjectUniquePtr CreateDefaultObject(const sal_uInt16 nID, const tools::Rectangle& rRectangle) override; +}; + +#endif // _SD_FUCONARC_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/fuconcustomshape.hxx b/sc/source/ui/inc/fuconcustomshape.hxx new file mode 100644 index 000000000..c9bad69b3 --- /dev/null +++ b/sc/source/ui/inc/fuconcustomshape.hxx @@ -0,0 +1,52 @@ +/* -*- 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_SC_SOURCE_UI_INC_FUCONCUSTOMSHAPE_HXX +#define INCLUDED_SC_SOURCE_UI_INC_FUCONCUSTOMSHAPE_HXX + +#include "fuconstr.hxx" + +class FuConstCustomShape : public FuConstruct +{ + OUString aCustomShape; + + void SetAttributes( SdrObject* pObj ); + +public: + FuConstCustomShape(ScTabViewShell& rViewSh, vcl::Window* pWin, ScDrawView* pView, + SdrModel* pDoc, const SfxRequest& rReq); + + virtual ~FuConstCustomShape() override; + // Mouse- & Key-Events + virtual bool MouseButtonUp(const MouseEvent& rMEvt) override; + virtual bool MouseButtonDown(const MouseEvent& rMEvt) override; + + virtual void Activate() override; + virtual void Deactivate() override; + + // Create default drawing objects via keyboard + virtual SdrObjectUniquePtr CreateDefaultObject( const sal_uInt16 nID, const tools::Rectangle& rRectangle ) override; + + // #i33136# + virtual bool doConstructOrthogonal() const override; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/fuconpol.hxx b/sc/source/ui/inc/fuconpol.hxx new file mode 100644 index 000000000..ca1fd5863 --- /dev/null +++ b/sc/source/ui/inc/fuconpol.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_SC_SOURCE_UI_INC_FUCONPOL_HXX +#define INCLUDED_SC_SOURCE_UI_INC_FUCONPOL_HXX + +#include "fuconstr.hxx" + +/** Base class for all functions */ +class FuConstPolygon : public FuConstruct +{ +public: + FuConstPolygon(ScTabViewShell& rViewSh, vcl::Window* pWin, ScDrawView* pView, + SdrModel* pDoc, const SfxRequest& rReq); + + virtual ~FuConstPolygon() override; + // Mouse- & Key-Events + virtual bool MouseMove(const MouseEvent& rMEvt) override; + virtual bool MouseButtonUp(const MouseEvent& rMEvt) override; + virtual bool MouseButtonDown(const MouseEvent& rMEvt) override; + + virtual void Activate() override; + virtual void Deactivate() override; + + // Create default drawing objects via keyboard + virtual SdrObjectUniquePtr CreateDefaultObject(const sal_uInt16 nID, const tools::Rectangle& rRectangle) override; +}; + +#endif // _FUCONPOL_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/fuconrec.hxx b/sc/source/ui/inc/fuconrec.hxx new file mode 100644 index 000000000..2d7340a7a --- /dev/null +++ b/sc/source/ui/inc/fuconrec.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_SC_SOURCE_UI_INC_FUCONREC_HXX +#define INCLUDED_SC_SOURCE_UI_INC_FUCONREC_HXX + +#include "fuconstr.hxx" + +/** Draw rectangle */ +class FuConstRectangle : public FuConstruct +{ +public: + FuConstRectangle(ScTabViewShell& rViewSh, vcl::Window* pWin, ScDrawView* pView, + SdrModel* pDoc, const SfxRequest& rReq); + + virtual ~FuConstRectangle() override; + // Mouse- & Key-Events + virtual bool MouseButtonUp(const MouseEvent& rMEvt) override; + virtual bool MouseButtonDown(const MouseEvent& rMEvt) override; + + virtual void Activate() override; + virtual void Deactivate() override; + static void SetLineEnds(SfxItemSet& rAttr, const SdrObject& rObj, sal_uInt16 nSlotId); + + // Create default drawing objects via keyboard + virtual SdrObjectUniquePtr CreateDefaultObject(const sal_uInt16 nID, const tools::Rectangle& rRectangle) override; +}; + +#endif // _SD_FUCONREC_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/fuconstr.hxx b/sc/source/ui/inc/fuconstr.hxx new file mode 100644 index 000000000..e87a32092 --- /dev/null +++ b/sc/source/ui/inc/fuconstr.hxx @@ -0,0 +1,44 @@ +/* -*- 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_SC_SOURCE_UI_INC_FUCONSTR_HXX +#define INCLUDED_SC_SOURCE_UI_INC_FUCONSTR_HXX + +#include "fudraw.hxx" + +/** Draw rectangle */ +class FuConstruct : public FuDraw +{ +public: + FuConstruct(ScTabViewShell& rViewSh, vcl::Window* pWin, ScDrawView* pView, + SdrModel* pDoc, const SfxRequest& rReq); + + virtual ~FuConstruct() override; + // Mouse- & Key-Events + virtual bool KeyInput(const KeyEvent& rKEvt) override; + virtual bool MouseMove(const MouseEvent& rMEvt) override; + virtual bool MouseButtonUp(const MouseEvent& rMEvt) override; + virtual bool MouseButtonDown(const MouseEvent& rMEvt) override; + + bool SimpleMouseButtonUp(const MouseEvent& rMEvt); +}; + +#endif // _SD_FUCONSTR_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/fuconuno.hxx b/sc/source/ui/inc/fuconuno.hxx new file mode 100644 index 000000000..80bce1946 --- /dev/null +++ b/sc/source/ui/inc/fuconuno.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_SC_SOURCE_UI_INC_FUCONUNO_HXX +#define INCLUDED_SC_SOURCE_UI_INC_FUCONUNO_HXX + +#include "fuconstr.hxx" + +enum class SdrInventor : sal_uInt32; + +/** Draw Control */ +class FuConstUnoControl final : public FuConstruct +{ + SdrInventor nInventor; + sal_uInt16 nIdentifier; + +public: + FuConstUnoControl(ScTabViewShell& rViewSh, vcl::Window* pWin, ScDrawView* pView, + SdrModel* pDoc, const SfxRequest& rReq); + + virtual ~FuConstUnoControl() override; + // Mouse- & Key-Events + virtual bool MouseButtonUp(const MouseEvent& rMEvt) override; + virtual bool MouseButtonDown(const MouseEvent& rMEvt) override; + + virtual void Activate() override; + virtual void Deactivate() override; + + // Create default drawing objects via keyboard + virtual SdrObjectUniquePtr CreateDefaultObject(const sal_uInt16 nID, const tools::Rectangle& rRectangle) override; +}; + +#endif // _SD_FUCONCTL_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/fudraw.hxx b/sc/source/ui/inc/fudraw.hxx new file mode 100644 index 000000000..a3c1e6f2d --- /dev/null +++ b/sc/source/ui/inc/fudraw.hxx @@ -0,0 +1,57 @@ +/* -*- 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_SC_SOURCE_UI_INC_FUDRAW_HXX +#define INCLUDED_SC_SOURCE_UI_INC_FUDRAW_HXX + +#include "fupoor.hxx" + +enum class PointerStyle; + +/** Base class for all Drawmodule specific functions */ +class FuDraw : public FuPoor +{ + protected: + PointerStyle aNewPointer; + PointerStyle aOldPointer; + + public: + FuDraw(ScTabViewShell& rViewSh, vcl::Window* pWin, ScDrawView* pView, + SdrModel* pDoc, const SfxRequest& rReq); + virtual ~FuDraw() override; + + virtual bool KeyInput(const KeyEvent& rKEvt) override; + + virtual void ForcePointer(const MouseEvent* pMEvt); + + virtual bool MouseMove(const MouseEvent& rMEvt) override; + virtual bool MouseButtonUp(const MouseEvent& rMEvt) override; + virtual bool MouseButtonDown(const MouseEvent& rMEvt) override; + + bool IsEditingANote() const; + bool IsSizingOrMovingNote( const MouseEvent& rMEvt ) const; + + private: + void DoModifiers(const MouseEvent& rMEvt); + void ResetModifiers(); +}; + +#endif // _SD_FUDRAW_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/fuinsert.hxx b/sc/source/ui/inc/fuinsert.hxx new file mode 100644 index 000000000..a9c8fb5c7 --- /dev/null +++ b/sc/source/ui/inc/fuinsert.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_SC_SOURCE_UI_INC_FUINSERT_HXX +#define INCLUDED_SC_SOURCE_UI_INC_FUINSERT_HXX + +#include "fupoor.hxx" +#include <scdllapi.h> +#include <svx/svdoole2.hxx> +#include <com/sun/star/ui/dialogs/DialogClosedEvent.hpp> +#include <com/sun/star/ui/dialogs/XAsynchronousExecutableDialog.hpp> + +class FuInsertGraphic : public FuPoor +{ +public: + FuInsertGraphic(ScTabViewShell& rViewSh, vcl::Window* pWin, ScDrawView* pView, + SdrModel* pDoc, SfxRequest& rReq); + virtual ~FuInsertGraphic() override; +}; + +class FuInsertOLE : public FuPoor +{ +public: + FuInsertOLE(ScTabViewShell& rViewSh, vcl::Window* pWin, ScDrawView* pView, + SdrModel* pDoc, SfxRequest& rReq); +}; + +class FuInsertChart : public FuPoor +{ + public: + FuInsertChart( ScTabViewShell& pViewSh, vcl::Window* pWin, ScDrawView* pView, + SdrModel* pDoc, SfxRequest& rReq, + const Link<css::ui::dialogs::DialogClosedEvent*, void>& rLink); +}; + +class FuInsertMedia : public FuPoor +{ +public: + FuInsertMedia(ScTabViewShell& rViewSh, vcl::Window* pWin, ScDrawView* pView, + SdrModel* pDoc, const SfxRequest& rReq); + virtual ~FuInsertMedia() override; +}; + +void SC_DLLPUBLIC ScLimitSizeOnDrawPage( Size& rSize, Point& rPos, const Size& rPage ); + +#endif // _SD_FUINSERT_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/fupoor.hxx b/sc/source/ui/inc/fupoor.hxx new file mode 100644 index 000000000..d95b4f0d4 --- /dev/null +++ b/sc/source/ui/inc/fupoor.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_SC_SOURCE_UI_INC_FUPOOR_HXX +#define INCLUDED_SC_SOURCE_UI_INC_FUPOOR_HXX + +#include <vcl/timer.hxx> +#include <sfx2/request.hxx> +#include <svx/svdobj.hxx> +#include <vcl/window.hxx> + +class ScDrawView; +class ScTabViewShell; +class SdrModel; +class CommandEvent; +class KeyEvent; +class MouseEvent; + +// Return values for command +#define SC_CMD_NONE 0 +#define SC_CMD_USED 1 + +/** Base class for all functions */ +class FuPoor +{ +protected: + ScDrawView* pView; + ScTabViewShell& rViewShell; + VclPtr<vcl::Window> pWindow; + SdrModel* pDrDoc; + + SfxRequest aSfxRequest; + + Timer aScrollTimer; // for Autoscrolling + DECL_LINK( ScrollHdl, Timer *, void ); + void ForceScroll(const Point& aPixPos); + + Timer aDragTimer; // for Drag&Drop + DECL_LINK( DragTimerHdl, Timer *, void ); + DECL_LINK( DragHdl, void *, void ); + bool bIsInDragMode; + Point aMDPos; // Position of MouseButtonDown + + // member to hold state of the mouse buttons for creation + // of own MouseEvents (like in ScrollHdl) +private: + sal_uInt16 mnCode; + +public: + FuPoor(ScTabViewShell& rViewSh, vcl::Window* pWin, ScDrawView* pView, + SdrModel* pDoc, const SfxRequest& rReq); + virtual ~FuPoor(); + + // see member + void SetMouseButtonCode(sal_uInt16 nNew) { if(nNew != mnCode) mnCode = nNew; } + sal_uInt16 GetMouseButtonCode() const { return mnCode; } + + // Mouse- & Key-Events; return value=TRUE: Event was processed + virtual bool KeyInput(const KeyEvent& rKEvt); + virtual bool MouseMove(const MouseEvent&) { return false; } + + // moved from inline to *.cxx + virtual bool MouseButtonUp(const MouseEvent& rMEvt); // { return FALSE; } + + // moved from inline to *.cxx + virtual bool MouseButtonDown(const MouseEvent& rMEvt); // { return FALSE; } + + sal_uInt8 Command(const CommandEvent& rCEvt); + + virtual void Activate(); + virtual void Deactivate(); + + void SetWindow(vcl::Window* pWin) { pWindow = pWin; } + + sal_uInt16 GetSlotID() const { return aSfxRequest.GetSlot(); } + + bool IsDetectiveHit( const Point& rLogicPos ); + + void StopDragTimer(); + + // Create default drawing objects via keyboard + virtual SdrObjectUniquePtr CreateDefaultObject(const sal_uInt16 nID, const tools::Rectangle& rRectangle); + +protected: + static void ImpForceQuadratic(tools::Rectangle& rRect); + +public: + // #i33136# + virtual bool doConstructOrthogonal() const; +}; + +#endif // _SD_FUPOOR_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/fusel.hxx b/sc/source/ui/inc/fusel.hxx new file mode 100644 index 000000000..70648c707 --- /dev/null +++ b/sc/source/ui/inc/fusel.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_SC_SOURCE_UI_INC_FUSEL_HXX +#define INCLUDED_SC_SOURCE_UI_INC_FUSEL_HXX + +#include "fudraw.hxx" + +class SdrPageView; + +/** Base class for all functions */ +class FuSelection : public FuDraw +{ +public: + FuSelection(ScTabViewShell& rViewSh, vcl::Window* pWin, ScDrawView* pView, + SdrModel* pDoc, const SfxRequest& rReq ); + + virtual ~FuSelection() override; + // Mouse- & Key-Events + virtual bool MouseMove(const MouseEvent& rMEvt) override; + virtual bool MouseButtonUp(const MouseEvent& rMEvt) override; + virtual bool MouseButtonDown(const MouseEvent& rMEvt) override; + + void ActivateNoteHandles(SdrObject* pObj); + +private: + bool TestDetective( const SdrPageView* pPV, const Point& rPos ); // -> fusel2 + + bool IsNoteCaptionMarked() const; + bool IsNoteCaptionClicked( const Point& rPos ) const; +}; + +#endif // _SD_FUSEL_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/futext.hxx b/sc/source/ui/inc/futext.hxx new file mode 100644 index 000000000..d6bbdb8f6 --- /dev/null +++ b/sc/source/ui/inc/futext.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_SC_SOURCE_UI_INC_FUTEXT_HXX +#define INCLUDED_SC_SOURCE_UI_INC_FUTEXT_HXX + +#include "fuconstr.hxx" + +class SdrOutliner; + +/** Base class for Text functions */ +class FuText : public FuConstruct +{ +public: + FuText(ScTabViewShell& rViewSh, vcl::Window* pWin, ScDrawView* pView, + SdrModel* pDoc, const SfxRequest& rReq); + + virtual ~FuText() override; + + virtual bool KeyInput(const KeyEvent& rKEvt) override; + virtual bool MouseMove(const MouseEvent& rMEvt) override; + virtual bool MouseButtonUp(const MouseEvent& rMEvt) override; + virtual bool MouseButtonDown(const MouseEvent& rMEvt) override; + + virtual void Activate() override; + virtual void Deactivate() override; + + virtual void ForcePointer(const MouseEvent* pMEvt) override; + + void SetInEditMode( SdrObject* pObj = nullptr, const Point* pMousePixel = nullptr, + bool bCursorToEnd = false, const KeyEvent* pInitialKey = nullptr ); + void StopEditMode(); + + // Create default drawing objects via keyboard + virtual SdrObjectUniquePtr CreateDefaultObject(const sal_uInt16 nID, const tools::Rectangle& rRectangle) override; + +private: + std::unique_ptr<SdrOutliner> MakeOutliner(); +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/graphsh.hxx b/sc/source/ui/inc/graphsh.hxx new file mode 100644 index 000000000..d2fee2481 --- /dev/null +++ b/sc/source/ui/inc/graphsh.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_SC_SOURCE_UI_INC_GRAPHSH_HXX +#define INCLUDED_SC_SOURCE_UI_INC_GRAPHSH_HXX + +#include <memory> +#include <vector> +#include <sfx2/shell.hxx> +#include <shellids.hxx> + +class SdrExternalToolEdit; +class ScViewData; +class SfxModule; + +#include "drawsh.hxx" + +class ScGraphicShell: public ScDrawShell +{ +public: + SFX_DECL_INTERFACE(SCID_GRAPHIC_SHELL) + +private: + std::vector<std::unique_ptr<SdrExternalToolEdit>> m_ExternalEdits; + + /// SfxInterface initializer. + static void InitInterface_Impl(); + +public: + ScGraphicShell(ScViewData* pData); + virtual ~ScGraphicShell() override; + + void Execute(SfxRequest& rReq); + void GetAttrState(SfxItemSet &rSet); + + void ExecuteFilter(const SfxRequest& rReq); + void GetFilterState(SfxItemSet &rSet); + + void ExecuteExternalEdit(SfxRequest& rReq); + void GetExternalEditState(SfxItemSet &rSet); + + void ExecuteCompressGraphic(SfxRequest& rReq); + void GetCompressGraphicState(SfxItemSet &rSet); + + void ExecuteCropGraphic(SfxRequest& rReq); + void GetCropGraphicState(SfxItemSet &rSet); + + void ExecuteSaveGraphic(SfxRequest& rReq); + void GetSaveGraphicState(SfxItemSet &rSet); + + void ExecuteChangePicture(SfxRequest& rReq); + void GetChangePictureState(SfxItemSet &rSet); +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/gridmerg.hxx b/sc/source/ui/inc/gridmerg.hxx new file mode 100644 index 000000000..a6c484afa --- /dev/null +++ b/sc/source/ui/inc/gridmerg.hxx @@ -0,0 +1,52 @@ +/* -*- 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_SC_SOURCE_UI_INC_GRIDMERG_HXX +#define INCLUDED_SC_SOURCE_UI_INC_GRIDMERG_HXX + +class OutputDevice; + +class ScGridMerger +{ +private: + VclPtr<OutputDevice> pDev; + long nOneX; + long nOneY; + long nFixStart; + long nFixEnd; + long nVarStart; + long nVarDiff; + long nCount; + bool bVertical; + bool bOptimize; + + void AddLine( long nStart, long nEnd, long nPos ); + +public: + ScGridMerger( OutputDevice* pOutDev, long nOnePixelX, long nOnePixelY ); + ~ScGridMerger(); + + void AddHorLine(bool bWorksInPixels, long nX1, long nX2, long nY, bool bDashed = false); + void AddVerLine(bool bWorksInPixels, long nX, long nY1, long nY2, bool bDashed = false); + void Flush(); +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/gridwin.hxx b/sc/source/ui/inc/gridwin.hxx new file mode 100644 index 000000000..e04fc42cb --- /dev/null +++ b/sc/source/ui/inc/gridwin.hxx @@ -0,0 +1,492 @@ +/* -*- 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_SC_SOURCE_UI_INC_GRIDWIN_HXX +#define INCLUDED_SC_SOURCE_UI_INC_GRIDWIN_HXX + +#include <vcl/transfer.hxx> +#include "viewutil.hxx" +#include "viewdata.hxx" +#include "cbutton.hxx" +#include "checklistmenu.hxx" +#include <com/sun/star/sheet/DataPilotFieldOrientation.hpp> +#include <o3tl/deleter.hxx> + +#include <memory> +#include <vector> + +namespace editeng { + struct MisspellRanges; +} + +namespace sc { + struct SpellCheckContext; +} + +namespace sdr::overlay { class OverlayManager; } + +class FmFormView; +struct ScTableInfo; +class ScDPObject; +class ScDPFieldButton; +class ScOutputData; +class ScFilterListBox; +class SdrObject; +class SdrEditView; +class ScNoteMarker; +class FloatingWindow; +class SdrHdlList; +class ScTransferObj; +struct SpellCallbackInfo; + + // mouse status (nMouseStatus) + +#define SC_GM_NONE 0 +#define SC_GM_TABDOWN 1 +#define SC_GM_DBLDOWN 2 +#define SC_GM_FILTER 3 +#define SC_GM_IGNORE 4 +#define SC_GM_WATERUNDO 5 +#define SC_GM_URLDOWN 6 + + // page drag mode + +#define SC_PD_NONE 0 +#define SC_PD_RANGE_L 1 +#define SC_PD_RANGE_R 2 +#define SC_PD_RANGE_T 4 +#define SC_PD_RANGE_B 8 +#define SC_PD_RANGE_TL (SC_PD_RANGE_T|SC_PD_RANGE_L) +#define SC_PD_RANGE_TR (SC_PD_RANGE_T|SC_PD_RANGE_R) +#define SC_PD_RANGE_BL (SC_PD_RANGE_B|SC_PD_RANGE_L) +#define SC_PD_RANGE_BR (SC_PD_RANGE_B|SC_PD_RANGE_R) +#define SC_PD_BREAK_H 16 +#define SC_PD_BREAK_V 32 + +// predefines +namespace sdr::overlay { class OverlayObjectList; } + +class SAL_DLLPUBLIC_RTTI ScGridWindow : public vcl::Window, public DropTargetHelper, public DragSourceHelper +{ + // ScFilterListBox is always used for selection list + friend class ScFilterListBox; + + enum RfCorner + { + NONE, + LEFT_UP, + RIGHT_UP, + LEFT_DOWN, + RIGHT_DOWN + }; + + std::unique_ptr<sdr::overlay::OverlayObjectList> mpOOCursors; + std::unique_ptr<sdr::overlay::OverlayObjectList> mpOOSelection; + std::unique_ptr<sdr::overlay::OverlayObjectList> mpOOSelectionBorder; + std::unique_ptr<sdr::overlay::OverlayObjectList> mpOOAutoFill; + std::unique_ptr<sdr::overlay::OverlayObjectList> mpOODragRect; + std::unique_ptr<sdr::overlay::OverlayObjectList> mpOOHeader; + std::unique_ptr<sdr::overlay::OverlayObjectList> mpOOShrink; + + std::optional<tools::Rectangle> mpAutoFillRect; + + /// LibreOfficeKit needs a persistent FmFormView for tiled rendering, + /// otherwise the invalidations from drawinglayer do not work. + std::unique_ptr<FmFormView> mpLOKDrawView; + + struct MouseEventState; + + /** + * Stores current visible column and row ranges, used to avoid expensive + * operations on objects that are outside visible area. + */ + struct VisibleRange + { + SCCOL mnCol1; + SCCOL mnCol2; + SCROW mnRow1; + SCROW mnRow2; + + VisibleRange(const ScDocument*); + + bool isInside(SCCOL nCol, SCROW nRow) const; + bool set(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2); + }; + + VisibleRange maVisibleRange; + + struct LOKCursorEntry + { + Fraction aScaleX; + Fraction aScaleY; + tools::Rectangle aRect; + }; + + // Stores the last cursor position in twips for all + // zoom levels demanded from a ScGridWindow instance. + std::vector<LOKCursorEntry> maLOKLastCursor; + + std::unique_ptr<sc::SpellCheckContext> mpSpellCheckCxt; + + ScViewData* pViewData; + ScSplitPos eWhich; + ScHSplitPos eHWhich; + ScVSplitPos eVWhich; + + std::unique_ptr<ScNoteMarker, o3tl::default_delete<ScNoteMarker>> mpNoteMarker; + + VclPtr<ScFilterListBox> mpFilterBox; + VclPtr<FloatingWindow> mpFilterFloat; + VclPtr<ScCheckListMenuWindow> mpAutoFilterPopup; + VclPtr<ScCheckListMenuWindow> mpDPFieldPopup; + std::unique_ptr<ScDPFieldButton> mpFilterButton; + + ScCheckListMenuWindow::ResultType aSaveAutoFilterResult; + + sal_uInt16 nCursorHideCount; + + sal_uInt16 nButtonDown; + sal_uInt8 nMouseStatus; + enum class ScNestedButtonState { NONE, Down, Up }; + ScNestedButtonState nNestedButtonState; // track nested button up/down calls + + long nDPField; + ScDPObject* pDragDPObj; //! name? + + sal_uInt16 nRFIndex; + SCCOL nRFAddX; + SCROW nRFAddY; + + sal_uInt16 nPagebreakMouse; // Page break mode, Drag + SCCOLROW nPagebreakBreak; + SCCOLROW nPagebreakPrev; + ScRange aPagebreakSource; + ScRange aPagebreakDrag; + + SvtScriptType nPageScript; + + SCCOL nDragStartX; + SCROW nDragStartY; + SCCOL nDragEndX; + SCROW nDragEndY; + InsCellCmd meDragInsertMode; + + ScDDComboBoxButton aComboButton; + + Point aCurMousePos; + + sal_uInt16 nPaintCount; + tools::Rectangle aRepaintPixel; + + ScAddress aAutoMarkPos; + ScAddress aListValPos; + + tools::Rectangle aInvertRect; + + RfCorner aRFSelectedCorned; + + bool bEEMouse:1; // Edit Engine has mouse + bool bDPMouse:1; // DataPilot D&D (new Pivot table) + bool bRFMouse:1; // RangeFinder drag + bool bRFSize:1; + bool bPagebreakDrawn:1; + bool bDragRect:1; + bool bIsInPaint:1; + bool bNeedsRepaint:1; + bool bAutoMarkVisible:1; + bool bListValButton:1; + + DECL_LINK( PopupModeEndHdl, FloatingWindow*, void ); + DECL_LINK( PopupSpellingHdl, SpellCallbackInfo&, void ); + + bool TestMouse( const MouseEvent& rMEvt, bool bAction ); + + bool DoPageFieldSelection( SCCOL nCol, SCROW nRow ); + bool DoAutoFilterButton( SCCOL nCol, SCROW nRow, const MouseEvent& rMEvt ); + void DoPushPivotButton( SCCOL nCol, SCROW nRow, const MouseEvent& rMEvt, bool bButton, bool bPopup ); + + void DPMouseMove( const MouseEvent& rMEvt ); + void DPMouseButtonUp( const MouseEvent& rMEvt ); + void DPTestMouse( const MouseEvent& rMEvt, bool bMove ); + + /** + * Check if the mouse click is on a field popup button. + * + * @return true if the field popup menu has been launched and no further + * mouse event handling is necessary, false otherwise. + */ + bool DPTestFieldPopupArrow(const MouseEvent& rMEvt, const ScAddress& rPos, const ScAddress& rDimPos, ScDPObject* pDPObj); + + void DPLaunchFieldPopupMenu(const Point& rScrPos, const Size& rScrSize, const ScAddress& rPos, ScDPObject* pDPObj); + + void RFMouseMove( const MouseEvent& rMEvt, bool bUp ); + + void PagebreakMove( const MouseEvent& rMEvt, bool bUp ); + + void UpdateDragRect( bool bShowRange, const tools::Rectangle& rPosRect ); + + bool IsAutoFilterActive( SCCOL nCol, SCROW nRow, SCTAB nTab ); + void FilterSelect( sal_uLong nSel ); + + void ExecDataSelect( SCCOL nCol, SCROW nRow, const OUString& rStr ); + + bool HasScenarioButton( const Point& rPosPixel, ScRange& rScenRange ); + + void DropScroll( const Point& rMousePos ); + + sal_Int8 AcceptPrivateDrop( const AcceptDropEvent& rEvt ); + sal_Int8 ExecutePrivateDrop( const ExecuteDropEvent& rEvt ); + sal_Int8 DropTransferObj( ScTransferObj* pTransObj, SCCOL nDestPosX, SCROW nDestPosY, + const Point& rLogicPos, sal_Int8 nDndAction ); + + void HandleMouseButtonDown( const MouseEvent& rMEvt, MouseEventState& rState ); + + bool DrawMouseButtonDown(const MouseEvent& rMEvt); + bool DrawMouseButtonUp(const MouseEvent& rMEvt); + bool DrawMouseMove(const MouseEvent& rMEvt); + bool DrawKeyInput(const KeyEvent& rKEvt); + bool DrawCommand(const CommandEvent& rCEvt); + bool DrawHasMarkedObj(); + void DrawEndAction(); + void DrawMarkDropObj( SdrObject* pObj ); + bool IsMyModel(const SdrEditView* pSdrView); + + void DrawRedraw( ScOutputData& rOutputData, SdrLayerID nLayer ); + void DrawSdrGrid( const tools::Rectangle& rDrawingRect, OutputDevice* pContentDev ); + void DrawAfterScroll(); + tools::Rectangle GetListValButtonRect( const ScAddress& rButtonPos ); + + void DrawPagePreview( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2, vcl::RenderContext& rRenderContext); + + bool GetEditUrl( const Point& rPos, + OUString* pName=nullptr, OUString* pUrl=nullptr, OUString* pTarget=nullptr ); + + bool IsSpellErrorAtPos( const Point& rPos, SCCOL nCol1, SCROW nRow ); + + bool HitRangeFinder( const Point& rMouse, RfCorner& rCorner, sal_uInt16* pIndex, + SCCOL* pAddX, SCROW* pAddY ); + + sal_uInt16 HitPageBreak( const Point& rMouse, ScRange* pSource, + SCCOLROW* pBreak, SCCOLROW* pPrev ); + + /** The cell may be covered by text that overflows from a previous cell. + + @return if true, the given cell is covered by (overflowing) text and + rTextStartPosX returns the column where the text that overflows + starts. + */ + bool IsCellCoveredByText(SCCOL nPosX, SCROW nPosY, SCTAB nTab, SCCOL &rTextStartPosX); + + void PasteSelection( const Point& rPosPixel ); + + void SelectForContextMenu( const Point& rPosPixel, SCCOL nCellX, SCROW nCellY ); + + void GetSelectionRects( ::std::vector< tools::Rectangle >& rPixelRects ) const; + void GetPixelRectsFor( const ScMarkData &rMarkData, + ::std::vector< tools::Rectangle >& rPixelRects ) const; + void UpdateKitSelection(const std::vector<tools::Rectangle>& rRectangles, + std::vector<tools::Rectangle>* pLogicRects = nullptr); + bool NeedLOKCursorInvalidation(const tools::Rectangle& rCursorRect, + const Fraction aScaleX, const Fraction aScaleY); + void InvalidateLOKViewCursor(const tools::Rectangle& rCursorRect, + const Fraction aScaleX, const Fraction aScaleY); + +protected: + virtual void PrePaint(vcl::RenderContext& rRenderContext) override; + virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) override; + virtual void GetFocus() override; + virtual void LoseFocus() override; + + virtual void RequestHelp( const HelpEvent& 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: + enum class AutoFilterMode { Normal, Top10, Custom, Empty, NonEmpty, SortAscending, SortDescending }; + + ScGridWindow( vcl::Window* pParent, ScViewData* pData, ScSplitPos eWhichPos ); + virtual ~ScGridWindow() override; + virtual void dispose() override; + + virtual void KeyInput(const KeyEvent& rKEvt) override; + // #i70788# flush and get overlay + rtl::Reference<sdr::overlay::OverlayManager> getOverlayManager() const; + void flushOverlayManager(); + + virtual void Command( const CommandEvent& rCEvt ) override; + virtual void DataChanged( const DataChangedEvent& rDCEvt ) override; + + virtual void MouseButtonDown( const MouseEvent& rMEvt ) override; + virtual void MouseButtonUp( const MouseEvent& rMEvt ) override; + virtual void MouseMove( const MouseEvent& rMEvt ) override; + virtual bool PreNotify( NotifyEvent& rNEvt ) override; + virtual void Tracking( const TrackingEvent& rTEvt ) override; + + void PaintTile( VirtualDevice& rDevice, + int nOutputWidth, int nOutputHeight, + int nTilePosX, int nTilePosY, + long nTileWidth, long nTileHeight ); + + /// @see Window::LogicInvalidate(). + void LogicInvalidate(const tools::Rectangle* pRectangle) override; + + /// Update the cell selection according to what handles have been dragged. + /// @see vcl::ITiledRenderable::setTextSelection() for the values of nType. + /// Coordinates are in pixels. + void SetCellSelectionPixel(int nType, int nPixelX, int nPixelY); + /// Get the cell selection, coordinates are in logic units. + void GetCellSelection(std::vector<tools::Rectangle>& rLogicRects); + + virtual css::uno::Reference< css::accessibility::XAccessible > CreateAccessible() override; + + void FakeButtonUp(); + + const Point& GetMousePosPixel() const { return aCurMousePos; } + void UpdateStatusPosSize(); + + void ClickExtern(); + + using Window::SetPointer; + + void MoveMouseStatus( ScGridWindow &rDestWin ); + + void ScrollPixel( long nDifX, long nDifY ); + void UpdateEditViewPos(); + + void UpdateFormulas(SCCOL nX1 = -1, SCROW nY1 = -1, SCCOL nX2 = -1, SCROW nY2 = -1); + + void ShowFilterMenu(const tools::Rectangle& rCellRect, bool bLayoutRTL); + + void LaunchDataSelectMenu( SCCOL nCol, SCROW nRow ); + void DoScenarioMenu( const ScRange& rScenRange ); + + void LaunchAutoFilterMenu(SCCOL nCol, SCROW nRow); + void RefreshAutoFilterButton(const ScAddress& rPos); + void UpdateAutoFilterFromMenu(AutoFilterMode eMode); + + void LaunchPageFieldMenu( SCCOL nCol, SCROW nRow ); + void LaunchDPFieldMenu( SCCOL nCol, SCROW nRow ); + + css::sheet::DataPilotFieldOrientation GetDPFieldOrientation( SCCOL nCol, SCROW nRow ) const; + + void DPLaunchFieldPopupMenu(const Point& rScrPos, const Size& rScrSize, + long nDimIndex, ScDPObject* pDPObj); + + void DrawButtons(SCCOL nX1, SCCOL nX2, const ScTableInfo& rTabInfo, OutputDevice* pContentDev); + + using Window::Draw; + void Draw( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2, + ScUpdateMode eMode ); + + /// Draw content of the gridwindow; shared between the desktop and the tiled rendering. + void DrawContent(OutputDevice &rDevice, const ScTableInfo& rTableInfo, ScOutputData& aOutputData, bool bLogicText); + + void CreateAnchorHandle(SdrHdlList& rHdl, const ScAddress& rAddress); + + void HideCursor(); + void ShowCursor(); + void UpdateAutoFillMark(bool bMarked, const ScRange& rMarkRange); + + void UpdateListValPos( bool bVisible, const ScAddress& rPos ); + + bool ShowNoteMarker( SCCOL nPosX, SCROW nPosY, bool bKeyboard ); + void HideNoteMarker(); + + /// MapMode for the drawinglayer objects. + MapMode GetDrawMapMode( bool bForce = false ); + + void StopMarking(); + void UpdateInputContext(); + + bool NeedsRepaint() { return bNeedsRepaint; } + + void DoInvertRect( const tools::Rectangle& rPixel ); + + void CheckNeedsRepaint(); + + void UpdateDPFromFieldPopupMenu(); + bool UpdateVisibleRange(); + + void CursorChanged(); + void DrawLayerCreated(); + bool ContinueOnlineSpelling(); + void EnableAutoSpell( bool bEnable ); + void ResetAutoSpell(); + void SetAutoSpellData( SCCOL nPosX, SCROW nPosY, const std::vector<editeng::MisspellRanges>* pRanges ); + const std::vector<editeng::MisspellRanges>* GetAutoSpellData( SCCOL nPosX, SCROW nPosY ); + bool InsideVisibleRange( SCCOL nPosX, SCROW nPosY ); + + void DeleteCopySourceOverlay(); + void UpdateCopySourceOverlay(); + void DeleteCursorOverlay(); + void UpdateCursorOverlay(); + void DeleteSelectionOverlay(); + void UpdateSelectionOverlay(); + void DeleteAutoFillOverlay(); + void UpdateAutoFillOverlay(); + void DeleteDragRectOverlay(); + void UpdateDragRectOverlay(); + void DeleteHeaderOverlay(); + void UpdateHeaderOverlay(); + void DeleteShrinkOverlay(); + void UpdateShrinkOverlay(); + void UpdateAllOverlays(); + + /// get Cell cursor in this view's co-ordinate system @see ScModelObj::getCellCursor(). + OString getCellCursor() const; + void notifyKitCellCursor() const; + void notifyKitCellViewCursor(const SfxViewShell* pForShell) const; + void updateKitCellCursor(const SfxViewShell* pOtherShell) const; + /// notify this view with new positions for other view's cursors (after zoom) + void updateKitOtherCursors() const; + void updateOtherKitSelections() const; + + /// Same as MouseButtonDown(), but coordinates are in logic unit. + virtual void LogicMouseButtonDown(const MouseEvent& rMouseEvent) override; + /// Same as MouseButtonUp(), but coordinates are in logic unit. + virtual void LogicMouseButtonUp(const MouseEvent& rMouseEvent) override; + /// Same as MouseMove(), but coordinates are in logic unit. + virtual void LogicMouseMove(const MouseEvent& rMouseEvent) override; + + ScViewData* getViewData(); + virtual FactoryFunction GetUITestFactory() const override; + + void updateLOKValListButton(bool bVisible, const ScAddress& rPos) const; + +protected: + void ImpCreateOverlayObjects(); + void ImpDestroyOverlayObjects(); + +private: + +#ifdef DBG_UTIL + void dumpCellProperties(); + void dumpColumnInformationPixel(); + void dumpColumnInformationHmm(); + void dumpGraphicInformation(); + void dumpColumnCellStorage(); +#endif + +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/groupdlg.hxx b/sc/source/ui/inc/groupdlg.hxx new file mode 100644 index 000000000..6f654d193 --- /dev/null +++ b/sc/source/ui/inc/groupdlg.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_SC_SOURCE_UI_INC_GROUPDLG_HXX +#define INCLUDED_SC_SOURCE_UI_INC_GROUPDLG_HXX + +#include <vcl/weld.hxx> + +class ScGroupDlg : public weld::GenericDialogController +{ +public: + ScGroupDlg(weld::Window* pParent, bool bUnGroup, bool bRows); + virtual ~ScGroupDlg() override; + bool GetColsChecked() const; + +private: + std::unique_ptr<weld::RadioButton> m_xBtnRows; + std::unique_ptr<weld::RadioButton> m_xBtnCols; +}; + +#endif // INCLUDED_SC_SOURCE_UI_INC_GROUPDLG_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/hdrcont.hxx b/sc/source/ui/inc/hdrcont.hxx new file mode 100644 index 000000000..08be7eba5 --- /dev/null +++ b/sc/source/ui/inc/hdrcont.hxx @@ -0,0 +1,129 @@ +/* -*- 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_SC_SOURCE_UI_INC_HDRCONT_HXX +#define INCLUDED_SC_SOURCE_UI_INC_HDRCONT_HXX + +#include <vcl/window.hxx> +#include <scdllapi.h> +#include <types.hxx> + +#define HDR_SIZE_OPTIMUM 0xFFFF + +// Size of the sliders +#define HDR_SLIDERSIZE 2 + +class ScTabView; +class SelectionEngine; + +class ScHeaderControl : public vcl::Window +{ +private: + SelectionEngine* pSelEngine; + vcl::Font aNormFont; + vcl::Font aBoldFont; + bool bBoldSet; + + bool bVertical; // Vertical = Row header + + long nWidth; + long nSmallWidth; + long nBigWidth; + + SCCOLROW nSize; + + SCCOLROW nMarkStart; + SCCOLROW nMarkEnd; + bool bMarkRange; + + bool bDragging; // Resizing + SCCOLROW nDragNo; + long nDragStart; + long nDragPos; + void* nTipVisible; + bool bDragMoved; + + bool bIgnoreMove; + + bool bInRefMode; + + long GetScrPos( SCCOLROW nEntryNo ) const; + SCCOLROW GetMousePos( const MouseEvent& rMEvt, bool& rBorder ) const; + bool IsSelectionAllowed(SCCOLROW nPos) const; + void ShowDragHelp(); + + void DoPaint( SCCOLROW nStart, SCCOLROW nEnd ); + +protected: + ScTabView* pTabView; + + // Window overrides + + virtual void Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect ) override; + + virtual void MouseMove( const MouseEvent& rMEvt ) override; + virtual void MouseButtonUp( const MouseEvent& rMEvt ) override; + virtual void MouseButtonDown( const MouseEvent& rMEvt ) override; + virtual void Tracking( const TrackingEvent& rTEvt ) override; + + virtual void RequestHelp( const HelpEvent& rHEvt ) override; + + // new methods + + virtual SCCOLROW GetPos() const = 0; // current position (Scrolling) + virtual sal_uInt16 GetEntrySize( SCCOLROW nEntryNo ) const = 0; // width / height (Pixel) + virtual OUString GetEntryText( SCCOLROW nEntryNo ) const = 0; + + virtual SCCOLROW GetHiddenCount( SCCOLROW nEntryNo ) const; + virtual bool IsLayoutRTL() const; + virtual bool IsMirrored() const; + + virtual void SetEntrySize( SCCOLROW nPos, sal_uInt16 nNewWidth ) = 0; + virtual void HideEntries( SCCOLROW nStart, SCCOLROW nEnd ) = 0; + + virtual void SetMarking( bool bSet ); + virtual void SelectWindow(); + virtual bool IsDisabled() const; + virtual bool ResizeAllowed() const; + virtual OUString GetDragHelp( long nVal ); + + virtual void DrawInvert( long nDragPos ); + virtual void Command( const CommandEvent& rCEvt ) override; + +public: + ScHeaderControl( vcl::Window* pParent, SelectionEngine* pSelectionEngine, + SCCOLROW nNewSize, bool bNewVertical, ScTabView* pTab ); + virtual ~ScHeaderControl() override; + + void SetIgnoreMove(bool bSet) { bIgnoreMove = bSet; } + + void StopMarking(); + + void SetMark( bool bNewSet, SCCOLROW nNewStart, SCCOLROW nNewEnd ); + + long GetWidth() const { return nWidth; } + long GetSmallWidth() const { return nSmallWidth; } + long GetBigWidth() const { return nBigWidth; } + void SetWidth( long nNew ); + void GetMarkRange(SCCOLROW& rStart, SCCOLROW& rEnd) const; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/hfedtdlg.hxx b/sc/source/ui/inc/hfedtdlg.hxx new file mode 100644 index 000000000..d1448e8fa --- /dev/null +++ b/sc/source/ui/inc/hfedtdlg.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_SC_SOURCE_UI_INC_HFEDTDLG_HXX +#define INCLUDED_SC_SOURCE_UI_INC_HFEDTDLG_HXX + +#include <sfx2/tabdlg.hxx> +#include <editeng/svxenum.hxx> + +class ScHFEditDlg : public SfxTabDialogController +{ + SvxNumType eNumType; +protected: + ScHFEditDlg(weld::Window* pParent, + const SfxItemSet& rCoreSet, const OUString& rPageStyle, + const OUString& rUIXMLDescription, const OString& rID); +public: + virtual void PageCreated(const OString& rId, SfxTabPage& rPage) override; +}; + +class ScHFEditHeaderDlg : public ScHFEditDlg +{ +public: + ScHFEditHeaderDlg(weld::Window* pParent, + const SfxItemSet& rCoreSet, const OUString& rPageStyle); +}; + +class ScHFEditFooterDlg : public ScHFEditDlg +{ +public: + ScHFEditFooterDlg(weld::Window* pParent, + const SfxItemSet& rCoreSet, const OUString& rPageStyle); +}; + +class ScHFEditLeftHeaderDlg : public ScHFEditDlg +{ +public: + ScHFEditLeftHeaderDlg(weld::Window* pParent, + const SfxItemSet& rCoreSet, const OUString& rPageStyle); +}; + +class ScHFEditRightHeaderDlg : public ScHFEditDlg +{ +public: + ScHFEditRightHeaderDlg(weld::Window* pParent, + const SfxItemSet& rCoreSet, const OUString& rPageStyle); +}; + +class ScHFEditLeftFooterDlg : public ScHFEditDlg +{ +public: + ScHFEditLeftFooterDlg(weld::Window* pParent, + const SfxItemSet& rCoreSet, const OUString& rPageStyle); +}; + +class ScHFEditRightFooterDlg : public ScHFEditDlg +{ +public: + ScHFEditRightFooterDlg(weld::Window* pParent, + const SfxItemSet& rCoreSet, const OUString& rPageStyle); +}; + +class ScHFEditSharedHeaderDlg : public ScHFEditDlg +{ +public: + ScHFEditSharedHeaderDlg(weld::Window* pParent, + const SfxItemSet& rCoreSet, const OUString& rPageStyle); +}; + +class ScHFEditSharedFooterDlg : public ScHFEditDlg +{ +public: + ScHFEditSharedFooterDlg(weld::Window* pParent, + const SfxItemSet& rCoreSet, const OUString& rPageStyle); +}; + +class ScHFEditAllDlg : public ScHFEditDlg +{ +public: + ScHFEditAllDlg(weld::Window* pParent, + const SfxItemSet& rCoreSet, const OUString& rPageStyle); +}; + +class ScHFEditActiveDlg : public ScHFEditDlg +{ +public: + ScHFEditActiveDlg(weld::Window* pParent, + const SfxItemSet& rCoreSet, const OUString& rPageStyle); +}; + +#endif // INCLUDED_SC_SOURCE_UI_INC_HFEDTDLG_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/highred.hxx b/sc/source/ui/inc/highred.hxx new file mode 100644 index 000000000..316c5a62e --- /dev/null +++ b/sc/source/ui/inc/highred.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_SC_SOURCE_UI_INC_HIGHRED_HXX +#define INCLUDED_SC_SOURCE_UI_INC_HIGHRED_HXX + +#include "anyrefdg.hxx" + +#include <svx/ctredlin.hxx> +#include <chgviset.hxx> + +class ScViewData; +class ScDocument; + + +class ScHighlightChgDlg : public ScAnyRefDlgController +{ +private: + ScViewData* pViewData; + ScDocument* pDoc; + ScChangeViewSettings aChangeViewSet; + + std::unique_ptr<weld::CheckButton> m_xHighlightBox; + std::unique_ptr<weld::CheckButton> m_xCbAccept; + std::unique_ptr<weld::CheckButton> m_xCbReject; + std::unique_ptr<weld::Button> m_xOkButton; + + std::unique_ptr<formula::RefEdit> m_xEdAssign; + std::unique_ptr<formula::RefButton> m_xRbAssign; + + std::unique_ptr<weld::Container> m_xBox; + + std::unique_ptr<SvxTPFilter> m_xFilterCtr; + + void Init(); + + DECL_LINK( RefHandle, SvxTPFilter*, void ); + DECL_LINK( HighlightHandle, weld::Button&, void ); + DECL_LINK( OKBtnHdl, weld::Button&, void ); + +protected: + + virtual void RefInputDone( bool bForced = false ) override; + +public: + ScHighlightChgDlg( SfxBindings* pB, SfxChildWindow* pCW, weld::Window* pParent, + ScViewData* ptrViewData); + + virtual ~ScHighlightChgDlg() override; + + virtual void SetActive() override; + virtual void SetReference( const ScRange& rRef, ScDocument& rDoc ) override; + virtual void Close() override; + virtual bool IsRefInputMode() const override; + +}; + +#endif // INCLUDED_SC_SOURCE_UI_INC_HIGHRED_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/hiranges.hxx b/sc/source/ui/inc/hiranges.hxx new file mode 100644 index 000000000..fe50a37f8 --- /dev/null +++ b/sc/source/ui/inc/hiranges.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/. + * + * 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_SC_SOURCE_UI_INC_HIRANGES_HXX +#define INCLUDED_SC_SOURCE_UI_INC_HIRANGES_HXX + +#include <tools/color.hxx> +#include <address.hxx> + +struct ScHighlightEntry +{ + ScRange aRef; + Color aColor; + + ScHighlightEntry( const ScRange& rR, const Color& rC ) : + aRef(rR), aColor(rC) {} +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/imoptdlg.hxx b/sc/source/ui/inc/imoptdlg.hxx new file mode 100644 index 000000000..bac941c2a --- /dev/null +++ b/sc/source/ui/inc/imoptdlg.hxx @@ -0,0 +1,58 @@ +/* -*- 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_SC_SOURCE_UI_INC_IMOPTDLG_HXX +#define INCLUDED_SC_SOURCE_UI_INC_IMOPTDLG_HXX + +#include <rtl/textenc.h> +#include <rtl/ustring.hxx> +#include <scdllapi.h> + +class SC_DLLPUBLIC ScImportOptions +{ +public: + ScImportOptions( const OUString& rStr ); + + ScImportOptions( sal_Unicode nFieldSep, sal_Unicode nTextSep, rtl_TextEncoding nEnc ) + : nFieldSepCode(nFieldSep), nTextSepCode(nTextSep), + bFixedWidth(false), bSaveAsShown(false), bQuoteAllText(false), + bSaveNumberAsSuch(true), bSaveFormulas(false), bRemoveSpace(false) + { SetTextEncoding( nEnc ); } + + ScImportOptions& operator=( const ScImportOptions& rCpy ) = default; + + OUString BuildString() const; + + void SetTextEncoding( rtl_TextEncoding nEnc ); + + sal_Unicode nFieldSepCode; + sal_Unicode nTextSepCode; + OUString aStrFont; + rtl_TextEncoding eCharSet; + bool bFixedWidth; + bool bSaveAsShown; + bool bQuoteAllText; + bool bSaveNumberAsSuch; + bool bSaveFormulas; + bool bRemoveSpace; +}; + +#endif // INCLUDED_SC_SOURCE_UI_INC_IMOPTDLG_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/impex.hxx b/sc/source/ui/inc/impex.hxx new file mode 100644 index 000000000..2cda5bf24 --- /dev/null +++ b/sc/source/ui/inc/impex.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_SC_SOURCE_UI_INC_IMPEX_HXX +#define INCLUDED_SC_SOURCE_UI_INC_IMPEX_HXX + +#include <o3tl/deleter.hxx> +#include <sot/formats.hxx> +#include <address.hxx> +#include <tools/stream.hxx> + +class ScDocShell; +class ScDocument; +class ScAsciiOptions; + +/** + * These options control how multi-line cells are converted during export in + * certain lossy formats (such as csv). + */ +struct ScExportTextOptions +{ + enum NewlineConversion { ToSystem, ToSpace, None }; + ScExportTextOptions( NewlineConversion eNewlineConversion = ToSystem, sal_Unicode cSeparatorConvertTo = 0, bool bAddQuotes = false ) : + meNewlineConversion( eNewlineConversion ), mcSeparatorConvertTo( cSeparatorConvertTo ), mbAddQuotes( bAddQuotes ) {} + + NewlineConversion meNewlineConversion; + sal_Unicode mcSeparatorConvertTo; // Convert separator to this character + bool mbAddQuotes; +}; + +class SC_DLLPUBLIC ScImportExport +{ + ScDocShell* pDocSh; + ScDocument* pDoc; + std::unique_ptr<ScDocument, o3tl::default_delete<ScDocument>> pUndoDoc; + ScRange aRange; + OUString aStreamPath; + OUString aNonConvertibleChars; + OUString maFilterOptions; + sal_uInt32 nSizeLimit; + SCROW nMaxImportRow; + sal_Unicode cSep; // Separator + sal_Unicode cStr; // String Delimiter + bool bFormulas; // Formula in Text? + bool bIncludeFiltered; // include filtered rows? (default true) + bool bAll; // no selection + bool bSingle; // Single selection + bool bUndo; // with Undo? + bool bOverflowRow; // too many rows + bool bOverflowCol; // too many columns + bool bOverflowCell; // too much data for a cell + bool mbApi; + bool mbImportBroadcast; // whether or not to broadcast after data import. + bool mbOverwriting; // Whether we could be overwriting existing values (paste). + // In this case we cannot use the insert optimization, but we + // do not need to broadcast after the import. + ScExportTextOptions mExportTextOptions; + + std::unique_ptr<ScAsciiOptions> pExtOptions; // extended options + + bool StartPaste(); // Protect check, set up Undo + void EndPaste(bool bAutoRowHeight = true); // Undo/Redo actions, Repaint + bool Doc2Text( SvStream& ); + bool Text2Doc( SvStream& ); + bool Doc2Sylk( SvStream& ); + bool Sylk2Doc( SvStream& ); + bool Doc2HTML( SvStream&, const OUString& ); + bool Doc2RTF( SvStream& ); + bool Doc2Dif( SvStream& ); + bool Dif2Doc( SvStream& ); + bool ExtText2Doc( SvStream& ); // with pExtOptions + bool RTF2Doc( SvStream&, const OUString& rBaseURL ); + bool HTML2Doc( SvStream&, const OUString& rBaseURL ); + +public: + ScImportExport( ScDocument* ); // the whole document + ScImportExport( ScDocument*, const OUString& ); // Range/cell input + ScImportExport( ScDocument*, const ScAddress& ); + ScImportExport( ScDocument*, const ScRange& ); + ~ScImportExport() COVERITY_NOEXCEPT_FALSE; + + void SetExtOptions( const ScAsciiOptions& rOpt ); + void SetFilterOptions( const OUString& rFilterOptions ); + bool IsRef() const { return !bAll; } + + const ScRange& GetRange() const { return aRange; } + + static void EmbeddedNullTreatment( OUString & rStr ); + + static bool IsFormatSupported( SotClipboardFormatId nFormat ); + static const sal_Unicode* ScanNextFieldFromString( const sal_Unicode* p, + OUString& rField, sal_Unicode cStr, const sal_Unicode* pSeps, + bool bMergeSeps, bool& rbIsQuoted, bool& rbOverflowCell, bool bRemoveSpace ); + static void WriteUnicodeOrByteString( SvStream& rStrm, const OUString& rString, bool bZero = false ); + static void WriteUnicodeOrByteEndl( SvStream& rStrm ); + + //! only if stream is only used in own (!) memory + static void SetNoEndianSwap( SvStream& rStrm ); + + void SetSeparator( sal_Unicode c ) { cSep = c; } + void SetDelimiter( sal_Unicode c ) { cStr = c; } + void SetFormulas( bool b ) { bFormulas = b; } + void SetIncludeFiltered( bool b ) { bIncludeFiltered = b; } + + void SetStreamPath( const OUString& rPath ) { aStreamPath = rPath; } + + bool ImportString( const OUString&, SotClipboardFormatId ); + bool ExportString( OUString&, SotClipboardFormatId ); + bool ExportByteString( OString&, rtl_TextEncoding, SotClipboardFormatId ); + + bool ImportStream( SvStream&, const OUString& rBaseURL, SotClipboardFormatId ); + bool ExportStream( SvStream&, const OUString& rBaseURL, SotClipboardFormatId ); + + bool ExportData( const OUString& rMimeType, + css::uno::Any & rValue ); + + // after import + bool IsOverflowRow() const { return bOverflowRow; } + bool IsOverflowCol() const { return bOverflowCol; } + bool IsOverflowCell() const { return bOverflowCell; } + bool IsOverflow() const { return bOverflowRow || bOverflowCol || bOverflowCell; } + + const OUString& GetNonConvertibleChars() const { return aNonConvertibleChars; } + + void SetApi( bool bApi ) { mbApi = bApi; } + void SetImportBroadcast( bool b ) { mbImportBroadcast = b; } + void SetOverwriting( const bool bOverwriting ) { mbOverwriting = bOverwriting; } + void SetExportTextOptions( const ScExportTextOptions& options ) { mExportTextOptions = options; } +}; + +// Helper class for importing clipboard strings as streams. +class ScImportStringStream : public SvMemoryStream +{ +public: + ScImportStringStream(const OUString& rStr); +}; + +/** Read a CSV (comma separated values) data line using + ReadUniOrByteStringLine(). + + @param bEmbeddedLineBreak + If TRUE and a line-break occurs inside a field of data, + a line feed LF '\n' and the next line are appended. Repeats + until a line-break is not in a field. A field is determined + by delimiting rFieldSeparators and optionally surrounded by + a pair of cFieldQuote characters. For a line-break to be + within a field, the field content MUST be surrounded by + cFieldQuote characters, and the opening cFieldQuote MUST be + at the very start of a line or follow right behind a field + separator with no extra characters in between, with the + exception of blanks contradictory to RFC 4180. Anything, + including field separators and escaped quotes (by doubling + them) may appear in a quoted field. + + If bEmbeddedLineBreak==FALSE, nothing is parsed and the + string returned is simply one ReadUniOrByteStringLine(). + + @param rFieldSeparators + A list of characters that each may act as a field separator. + If rcDetectSep was 0 and a separator is detected then it is appended to + rFieldSeparators. + + @param cFieldQuote + The quote character used. + + @param rcDetectSep + If 0 then attempt to detect a possible space (blank) separator if + rFieldSeparators doesn't include it already. This can be necessary because + of the "accept broken misquoted CSV fields" feature that tries to ignore + trailing blanks after a quoted field and if no separator follows continues + to add content to the field assuming the single double quote was in error. + If this blank separator is detected it is added to rFieldSeparators and the + line is reread with the new separators + + check Stream::good() to detect IO problems during read + + @ATTENTION + Note that the string returned may be truncated even inside + a quoted field if some (arbitrary) maximum length was reached. + There currently is no way to exactly determine the conditions, + whether this was at a line end, or whether open quotes + would have closed the field before the line end, as even a + ReadUniOrByteStringLine() may return prematurely but the + stream was positioned ahead until the real end of line. + Additionally, due to character encoding conversions, string + length and bytes read don't necessarily match, and + resyncing to a previous position matching the string's + length isn't always possible. As a result, a logical line + with embedded line breaks and more than the maximum length + characters will be spoiled, and a subsequent ReadCsvLine() + may start under false preconditions. + + */ +SC_DLLPUBLIC OUString ReadCsvLine( SvStream &rStream, bool bEmbeddedLineBreak, + OUString& rFieldSeparators, sal_Unicode cFieldQuote, sal_Unicode& rcDetectSep ); + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/inputhdl.hxx b/sc/source/ui/inc/inputhdl.hxx new file mode 100644 index 000000000..9f45e2b9a --- /dev/null +++ b/sc/source/ui/inc/inputhdl.hxx @@ -0,0 +1,329 @@ +/* -*- 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_SC_SOURCE_UI_INC_INPUTHDL_HXX +#define INCLUDED_SC_SOURCE_UI_INC_INPUTHDL_HXX + +#include <global.hxx> +#include <address.hxx> +#include <tools/solar.h> +#include <typedstrdata.hxx> + +#include <tools/fract.hxx> +#include <tools/gen.hxx> +#include <tools/link.hxx> +#include <vcl/vclptr.hxx> +#include <editeng/svxenum.hxx> +#include "viewdata.hxx" + +#include <set> +#include <memory> +#include <vector> + +class ScDocument; +class ScTabViewShell; +class ScInputWindow; +class ScPatternAttr; +class ScEditEngineDefaulter; +class EditView; +class EditTextObject; +class ScInputHdlState; +class ScRangeFindList; +class Timer; +class KeyEvent; +class CommandEvent; +class VclWindowEvent; +namespace vcl { class Window; } +struct ReferenceMark; +struct ESelection; + +// ScInputHandler + +class ScInputHandler final +{ +private: + VclPtr<ScInputWindow> pInputWin; + + std::unique_ptr<ScEditEngineDefaulter> mpEditEngine; ///< Edited data in the sheet (when the user clicks into the sheet, and starts writing there). + EditView* pTableView; // associated active EditView + EditView* pTopView; // EditView in the input row + + std::unique_ptr<ScTypedCaseStrSet> pColumnData; + std::unique_ptr<ScTypedCaseStrSet> pFormulaData; + std::unique_ptr<ScTypedCaseStrSet> pFormulaDataPara; + ScTypedCaseStrSet::const_iterator miAutoPosColumn; + ScTypedCaseStrSet::const_iterator miAutoPosFormula; + + VclPtr<vcl::Window> pTipVisibleParent; + void* nTipVisible; + VclPtr<vcl::Window> pTipVisibleSecParent; + void* nTipVisibleSec; + OUString aManualTip; + OUString aAutoSearch; + + OUString aCurrentText; + + OUString aFormText; // for autopilot function + sal_Int32 nFormSelStart; // Selection for autopilot function + sal_Int32 nFormSelEnd; + + sal_Unicode nCellPercentFormatDecSep; // 0:= no percent format, else which decimal separator + + sal_uInt16 nAutoPar; // autom.parentheses than can be overwritten + + ScAddress aCursorPos; + ScInputMode eMode; + bool bUseTab:1; // Scrolling possible + bool bTextValid:1; // Text is not in edit engine + bool bModified:1; + bool bSelIsRef:1; + bool bFormulaMode:1; + bool bInRangeUpdate:1; + bool bParenthesisShown:1; + bool bCreatingFuncView:1; + bool bInEnterHandler:1; + bool bCommandErrorShown:1; + bool bInOwnChange:1; + + bool bProtected:1; + bool bLastIsSymbol:1; + bool mbDocumentDisposing:1; + sal_uLong nValidation; + SvxCellHorJustify eAttrAdjust; + + Fraction aScaleX; // for ref MapMode + Fraction aScaleY; + + ScTabViewShell* pRefViewSh; + ScTabViewShell* pActiveViewSh; + + const ScPatternAttr* pLastPattern; + std::unique_ptr<SfxItemSet> + pEditDefaults; + + std::unique_ptr<ScInputHdlState> + pLastState; + std::unique_ptr<Timer> pDelayTimer; + + std::unique_ptr<ScRangeFindList> + pRangeFindList; + + static bool bAutoComplete; // from app options + static bool bOptLoaded; + ::std::set< sal_Unicode > maFormulaChar; //fdo 75264 + +private: + void UpdateActiveView(); + void SyncViews( const EditView* pSourceView = nullptr ); + /** + * @param cTyped typed character. If 0, look at existing document content + * for text or number. + * @param bInputActivated true if the cell input mode is activated (via + * F2), false otherwise. + * @param pTopEngine top window input line EditEngine. If not nullptr then + * some default attributes are merged to it from the + * table EditEngine. + * @return true if the new edit mode has been started. + */ + bool StartTable( sal_Unicode cTyped, bool bFromCommand, bool bInputActivated, + ScEditEngineDefaulter* pTopEngine ); + void RemoveSelection(); + void UpdateFormulaMode(); + static void InvalidateAttribs(); + void ImplCreateEditEngine(); + DECL_LINK( DelayTimer, Timer*, void ); + void GetColData(); + void UseColData(); + void NextAutoEntry( bool bBack ); + void UpdateAdjust( sal_Unicode cTyped ); + void GetFormulaData(); + void UseFormulaData(); + void NextFormulaEntry( bool bBack ); + void PasteFunctionData(); + void PasteManualTip(); + EditView* GetFuncEditView(); + void RemoveAdjust(); + void RemoveRangeFinder(); + void DeleteRangeFinder(); + void UpdateParenthesis(); + void UpdateAutoCorrFlag(); + void ResetAutoPar(); + void AutoParAdded(); + bool CursorAtClosingPar(); + void SkipClosingPar(); + bool GetFuncName( OUString& aStart, OUString& aResult ); // fdo75264 + void ShowArgumentsTip( OUString& rSelText ); + DECL_LINK( ModifyHdl, LinkParamNone*, void ); + DECL_LINK( ShowHideTipVisibleParentListener, VclWindowEvent&, void ); + DECL_LINK( ShowHideTipVisibleSecParentListener, VclWindowEvent&, void ); + +public: + ScInputHandler(const ScInputHandler&) = delete; + const ScInputHandler& operator=(const ScInputHandler&) = delete; + + ScInputHandler(); + ~ScInputHandler(); + + void SetMode( ScInputMode eNewMode, const OUString* pInitText = nullptr, + ScEditEngineDefaulter* pTopEngine = nullptr ); + bool IsInputMode() const { return (eMode != SC_INPUT_NONE); } + bool IsEditMode() const { return (eMode != SC_INPUT_NONE && + eMode != SC_INPUT_TYPE); } + bool IsTopMode() const { return (eMode == SC_INPUT_TOP); } + + const OUString& GetEditString(); + const OUString& GetFormString() const { return aFormText; } + + const ScAddress& GetCursorPos() const { return aCursorPos; } + + bool GetTextAndFields( ScEditEngineDefaulter& rDestEngine ); + void MergeLanguageAttributes( ScEditEngineDefaulter& rDestEngine ) const; + + bool KeyInput( const KeyEvent& rKEvt, bool bStartEdit ); + void EnterHandler( ScEnterMode nBlockMode = ScEnterMode::NORMAL ); + void CancelHandler(); + void SetReference( const ScRange& rRef, const ScDocument& rDoc ); + void AddRefEntry(); + + void InputCommand( const CommandEvent& rCEvt ); + + void InsertFunction( const OUString& rFuncName, bool bAddPar = true ); + void ClearText(); + + void InputSelection( const EditView* pView ); + void InputChanged( const EditView* pView, bool bFromNotify ); + + void ViewShellGone(const ScTabViewShell* pViewSh); + void SetRefViewShell(ScTabViewShell* pRefVsh) {pRefViewSh=pRefVsh;} + + void NotifyChange( const ScInputHdlState* pState, bool bForce = false, + ScTabViewShell* pSourceSh = nullptr, + bool bStopEditing = true); + void UpdateCellAdjust( SvxCellHorJustify eJust ); + + void ResetDelayTimer(); //BugId 54702 + + void HideTip(); + void HideTipBelow(); + void ShowTipCursor(); + void ShowTip( const OUString& rText ); // at Cursor + void ShowTipBelow( const OUString& rText ); + void ShowFuncList( const ::std::vector< OUString > & rFuncStrVec ); + + void SetRefScale( const Fraction& rX, const Fraction& rY ); + void UpdateRefDevice(); + + EditView* GetActiveView(); + EditView* GetTableView() { return pTableView; } + EditView* GetTopView() { return pTopView; } + + bool DataChanging( sal_Unicode cTyped = 0, bool bFromCommand = false ); + void DataChanged( bool bFromTopNotify = false, bool bSetModified = true ); + + bool TakesReturn() const { return ( nTipVisible != nullptr ); } + + bool GetModified() const { return bModified; } + void SetModified() { bModified = true; } + + bool GetSelIsRef() const { return bSelIsRef; } + void SetSelIsRef(bool bSet) { bSelIsRef = bSet; } + + void ShowRefFrame(); + + ScRangeFindList* GetRangeFindList() { return pRangeFindList.get(); } + + void UpdateRange( sal_uInt16 nIndex, const ScRange& rNew ); + + // Communication with the autopilot function + void InputGetSelection ( sal_Int32& rStart, sal_Int32& rEnd ); + void InputSetSelection ( sal_Int32 nStart, sal_Int32 nEnd ); + void InputReplaceSelection ( const OUString& rStr ); + void InputTurnOffWinEngine(); + + bool IsFormulaMode() const { return bFormulaMode; } + ScInputWindow* GetInputWindow() { return pInputWin; } + void SetInputWindow( ScInputWindow* pNew ); + void StopInputWinEngine( bool bAll ); + + bool IsInEnterHandler() const { return bInEnterHandler; } + bool IsInOwnChange() const { return bInOwnChange; } + + bool IsModalMode( const SfxObjectShell* pDocSh ); + + void ForgetLastPattern(); + + void UpdateSpellSettings( bool bFromStartTab = false ); + + void FormulaPreview(); + + Size GetTextSize(); // in 1/100mm + + // actually private, public for SID_INPUT_SUM + void InitRangeFinder(const OUString& rFormula); + + void UpdateLokReferenceMarks(); + static void SendReferenceMarks( const SfxViewShell* pViewShell, + const std::vector<ReferenceMark>& rReferenceMarks ); + + void SetDocumentDisposing( bool b ); + + static void SetAutoComplete(bool bSet) { bAutoComplete = bSet; } + + static ReferenceMark GetReferenceMark( ScViewData& rViewData, ScDocShell* pDocSh, + long nX1, long nX2, long nY1, long nY2, + long nTab, const Color& rColor ); + + void LOKPasteFunctionData(const OUString& rFunctionName); +}; + +// ScInputHdlState + +class ScInputHdlState +{ + friend class ScInputHandler; + +public: + ScInputHdlState( const ScAddress& rCurPos, + const ScAddress& rStartPos, + const ScAddress& rEndPos, + const OUString& rString, + const EditTextObject* pData ); + ScInputHdlState( const ScInputHdlState& rCpy ); + ~ScInputHdlState(); + + ScInputHdlState& operator= ( const ScInputHdlState& r ); + bool operator==( const ScInputHdlState& r ) const; + + const ScAddress& GetPos() const { return aCursorPos; } + const ScAddress& GetStartPos() const { return aStartPos; } + const ScAddress& GetEndPos() const { return aEndPos; } + const OUString& GetString() const { return aString; } + const EditTextObject* GetEditData() const { return pEditData.get(); } + +private: + ScAddress aCursorPos; + ScAddress aStartPos; + ScAddress aEndPos; + OUString aString; + std::unique_ptr<EditTextObject> pEditData; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/inputwin.hxx b/sc/source/ui/inc/inputwin.hxx new file mode 100644 index 000000000..c461c8fdb --- /dev/null +++ b/sc/source/ui/inc/inputwin.hxx @@ -0,0 +1,341 @@ +/* -*- 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_SC_SOURCE_UI_INC_INPUTWIN_HXX +#define INCLUDED_SC_SOURCE_UI_INC_INPUTWIN_HXX + +#include <vector> +#include <memory> +#include <vcl/toolbox.hxx> +#include <vcl/InterimItemWindow.hxx> +#include <sfx2/childwin.hxx> +#include <svl/lstner.hxx> +#include <vcl/button.hxx> +#include <vcl/scrbar.hxx> +#include <vcl/window.hxx> +#include <vcl/transfer.hxx> +#include <vcl/menu.hxx> +#include <formula/opcode.hxx> + +class EditView; +class ScAccessibleEditLineTextData; +class ScEditEngineDefaulter; +class ScTextWndGroup; +class ScInputBarGroup; +class ScInputHandler; +class ScTabViewShell; +struct EENotify; + +class ScTextWndBase : public vcl::Window +{ +public: + ScTextWndBase( vcl::Window* pParent, WinBits nStyle ); + virtual void InsertAccessibleTextData( ScAccessibleEditLineTextData& rTextData ) = 0; + virtual void RemoveAccessibleTextData( ScAccessibleEditLineTextData& rTextData ) = 0; + virtual void SetTextString( const OUString& rString ) = 0; + virtual const OUString& GetTextString() const = 0; + virtual void StartEditEngine() = 0; + virtual void StopEditEngine( bool bAll ) = 0; + virtual EditView* GetEditView() = 0; + virtual bool HasEditView() const = 0; + virtual void MakeDialogEditView() = 0; + virtual void SetFormulaMode( bool bSet ) = 0; + virtual bool IsInputActive() = 0; + virtual void TextGrabFocus() = 0; + virtual long GetNumLines() const = 0; +}; + +class ScTextWnd : public ScTextWndBase, public DragSourceHelper // edit window +{ +public: + ScTextWnd(ScTextWndGroup* pParent, ScTabViewShell* pViewSh); + virtual ~ScTextWnd() override; + virtual void dispose() override; + + virtual void SetTextString( const OUString& rString ) override; + virtual const OUString& GetTextString() const override; + + bool IsInputActive() override; + virtual EditView* GetEditView() override; + virtual bool HasEditView() const override; + + // for function autopilots + virtual void MakeDialogEditView() override; + + virtual void StartEditEngine() override; + virtual void StopEditEngine( bool bAll ) override; + + virtual void TextGrabFocus() override; + + virtual void DataChanged(const DataChangedEvent& rDCEvt) override; + + virtual void SetFormulaMode( bool bSet ) override; + + virtual css::uno::Reference< css::accessibility::XAccessible > CreateAccessible() override; + + virtual void InsertAccessibleTextData( ScAccessibleEditLineTextData& rTextData ) override; + virtual void RemoveAccessibleTextData( ScAccessibleEditLineTextData& rTextData ) override; + + virtual void Resize() override; + + long GetPixelHeightForLines(long nLines); + long GetEditEngTxtHeight() const; + + virtual long GetNumLines() const override { return mnLines; } + void SetNumLines(long nLines); + long GetLastNumExpandedLines() const { return mnLastExpandedLines; } + + void DoScroll(); + + DECL_LINK(NotifyHdl, EENotify&, void); + DECL_LINK(ModifyHdl, LinkParamNone*, void); + +protected: + virtual void Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect ) override; + + virtual void MouseMove( const MouseEvent& rMEvt ) override; + virtual void MouseButtonDown( const MouseEvent& rMEvt ) override; + virtual void MouseButtonUp( const MouseEvent& rMEvt ) override; + virtual void Command( const CommandEvent& rCEvt ) override; + virtual void KeyInput(const KeyEvent& rKEvt) override; + virtual void GetFocus() override; + virtual void LoseFocus() override; + + virtual void StartDrag( sal_Int8 nAction, const Point& rPosPixel ) override; + + virtual OUString GetText() const override; + +private: + void ImplInitSettings(); + void UpdateAutoCorrFlag(); + + void SetScrollBarRange(); + + void InitEditEngine(); + + typedef ::std::vector< ScAccessibleEditLineTextData* > AccTextDataVector; + + OUString aString; + vcl::Font aTextFont; + std::unique_ptr<ScEditEngineDefaulter> mpEditEngine; // only created when needed + std::unique_ptr<EditView> mpEditView; + AccTextDataVector maAccTextDatas; // #i105267# text data may be cloned, remember all copies + bool bIsRTL; + bool bIsInsertMode; + bool bFormulaMode; + + // #102710#; this flag should be true if a key input or a command is handled + // it prevents the call of InputChanged in the ModifyHandler of the EditEngine + bool bInputMode; + + ScTabViewShell* mpViewShell; + ScTextWndGroup& mrGroupBar; + long mnLines; + long mnLastExpandedLines; + bool mbInvalidate; +}; + +class ScPosWnd final : public InterimItemWindow, public SfxListener // Display position +{ +private: + std::unique_ptr<weld::ComboBox> m_xWidget; + + ImplSVEvent* m_nAsyncGetFocusId; + + OUString aPosStr; + void* nTipVisible; + bool bFormulaMode; + +public: + ScPosWnd( vcl::Window* pParent ); + virtual ~ScPosWnd() override; + virtual void dispose() override; + virtual void GetFocus() override; + + void SetPos( const OUString& rPosStr ); // Displayed Text + void SetFormulaMode( bool bSet ); + +private: + DECL_LINK(OnAsyncGetFocus, void*, void); + DECL_LINK(KeyInputHdl, const KeyEvent&, bool); + DECL_LINK(ActivateHdl, weld::ComboBox&, bool); + DECL_LINK(ModifyHdl, weld::ComboBox&, void); + DECL_LINK(FocusInHdl, weld::Widget&, void); + DECL_LINK(FocusOutHdl, weld::Widget&, void); + + virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override; + +private: + void FillRangeNames(); + void FillFunctions(); + void DoEnter(); + void HideTip(); + + void ReleaseFocus_Impl(); +}; + +class ScTextWndGroup : public ScTextWndBase +{ +public: + ScTextWndGroup(vcl::Window* pParent, ScTabViewShell* pViewSh); + virtual ~ScTextWndGroup() override; + virtual void dispose() override; + + virtual void InsertAccessibleTextData(ScAccessibleEditLineTextData& rTextData) override; + virtual EditView* GetEditView() override; + long GetLastNumExpandedLines() const; + virtual long GetNumLines() const override; + long GetPixelHeightForLines(long nLines); + ScrollBar& GetScrollBar(); + virtual const OUString& GetTextString() const override; + virtual bool HasEditView() const override; + virtual bool IsInputActive() override; + virtual void MakeDialogEditView() override; + virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) override; + virtual void RemoveAccessibleTextData(ScAccessibleEditLineTextData& rTextData) override; + virtual void Resize() override; + void SetNumLines(long nLines); + virtual void SetFormulaMode(bool bSet) override; + virtual void SetTextString(const OUString& rString) override; + virtual void StartEditEngine() override; + virtual void StopEditEngine(bool bAll) override; + virtual void TextGrabFocus() override; + +private: + VclPtr<ScTextWnd> maTextWnd; + VclPtr<ScrollBar> maScrollBar; + + DECL_LINK(Impl_ScrollHdl, ScrollBar*, void); +}; + +class ScInputBarGroup : public ScTextWndBase +{ +public: + ScInputBarGroup(vcl::Window* Parent, ScTabViewShell* pViewSh); + virtual ~ScInputBarGroup() override; + virtual void dispose() override; + virtual void InsertAccessibleTextData(ScAccessibleEditLineTextData& rTextData) override; + virtual void RemoveAccessibleTextData(ScAccessibleEditLineTextData& rTextData) override; + void SetTextString(const OUString& rString) override; + void StartEditEngine() override; + virtual EditView* GetEditView() override; + virtual bool HasEditView() const override; + virtual void Resize() override; + virtual const OUString& GetTextString() const override; + virtual void StopEditEngine(bool bAll) override; + virtual void TextGrabFocus() override; + void SetFormulaMode(bool bSet) override; + void MakeDialogEditView() override; + bool IsInputActive() override; + void IncrementVerticalSize(); + void DecrementVerticalSize(); + virtual long GetNumLines() const override { return maTextWndGroup->GetNumLines(); } + long GetVertOffset() const { return mnVertOffset; } + +private: + void TriggerToolboxLayout(); + + VclPtr<ScTextWndGroup> maTextWndGroup; + VclPtr<ImageButton> maButton; + long mnVertOffset; + + DECL_LINK(ClickHdl, Button*, void); +}; + +class ScInputWindow final : public ToolBox // Parent toolbox +{ +public: + ScInputWindow( vcl::Window* pParent, const SfxBindings* pBind ); + virtual ~ScInputWindow() override; + virtual void dispose() override; + + virtual void Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect ) override; + virtual void PixelInvalidate(const tools::Rectangle* pRectangle) override; + virtual void SetSizePixel( const Size& rNewSize ) override; + virtual void Resize() override; + virtual void Select() override; + + void SetFuncString( const OUString& rString, bool bDoEdit = true ); + void SetPosString( const OUString& rStr ); + void SetTextString( const OUString& rString ); + + void SetOkCancelMode(); + void SetSumAssignMode(); + void EnableButtons( bool bEnable ); + + void SetFormulaMode( bool bSet ); + + bool IsInputActive(); + EditView* GetEditView(); + + void TextGrabFocus(); + void TextInvalidate(); + void SwitchToTextWin(); + + void PosGrabFocus(); + + // For function autopilots + void MakeDialogEditView(); + + void StopEditEngine( bool bAll ); + + void SetInputHandler( ScInputHandler* pNew ); + + ScInputHandler* GetInputHandler(){ return pInputHdl;} + + void StateChanged( StateChangedType nType ) override; + virtual void DataChanged( const DataChangedEvent& rDCEvt ) override; + virtual void MouseButtonUp( const MouseEvent& rMEvt ) override; + virtual void MouseButtonDown( const MouseEvent& rMEvt ) override; + virtual void MouseMove( const MouseEvent& rMEvt ) override; + + void NotifyLOKClient(); + + DECL_LINK( MenuHdl, Menu *, bool ); + DECL_LINK( DropdownClickHdl, ToolBox*, void ); + + void AutoSum( bool& bRangeFinder, bool& bSubTotal, OpCode eCode ); + +private: + bool IsPointerAtResizePos(); + + VclPtr<ScPosWnd> aWndPos; + VclPtr<ScTextWndBase> pRuntimeWindow; + ScTextWndBase& aTextWindow; + ScInputHandler* pInputHdl; + ScTabViewShell* mpViewShell; + long mnMaxY; + bool bIsOkCancelMode; + bool bInResize; +}; + +class ScInputWindowWrapper : public SfxChildWindow +{ +public: + ScInputWindowWrapper( vcl::Window* pParent, + sal_uInt16 nId, + SfxBindings* pBindings, + SfxChildWinInfo* pInfo ); + + SFX_DECL_CHILDWINDOW_WITHID(ScInputWindowWrapper); +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/inscldlg.hxx b/sc/source/ui/inc/inscldlg.hxx new file mode 100644 index 000000000..84f978f7c --- /dev/null +++ b/sc/source/ui/inc/inscldlg.hxx @@ -0,0 +1,44 @@ +/* -*- 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_SC_SOURCE_UI_INC_INSCLDLG_HXX +#define INCLUDED_SC_SOURCE_UI_INC_INSCLDLG_HXX + +#include <vcl/weld.hxx> + +#include <global.hxx> + +class ScInsertCellDlg : public weld::GenericDialogController +{ +private: + std::unique_ptr<weld::RadioButton> m_xBtnCellsDown; + std::unique_ptr<weld::RadioButton> m_xBtnCellsRight; + std::unique_ptr<weld::RadioButton> m_xBtnInsRow; + std::unique_ptr<weld::RadioButton> m_xBtnInsCol; + +public: + ScInsertCellDlg(weld::Window* pParent, bool bDisallowCellMove); + virtual ~ScInsertCellDlg() override; + + InsCellCmd GetInsCellCmd() const; +}; + +#endif // INCLUDED_SC_SOURCE_UI_INC_INSCLDLG_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/inscodlg.hxx b/sc/source/ui/inc/inscodlg.hxx new file mode 100644 index 000000000..9f23194c6 --- /dev/null +++ b/sc/source/ui/inc/inscodlg.hxx @@ -0,0 +1,103 @@ +/* -*- 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_SC_SOURCE_UI_INC_INSCODLG_HXX +#define INCLUDED_SC_SOURCE_UI_INC_INSCODLG_HXX + +#include <vcl/weld.hxx> +#include <global.hxx> + +#include "scui_def.hxx" + +class ScInsertContentsDlg : public weld::GenericDialogController +{ +public: + ScInsertContentsDlg( weld::Window* pParent, + const OUString* pStrTitle ); + virtual ~ScInsertContentsDlg() override; + + InsertDeleteFlags GetInsContentsCmdBits() const; + ScPasteFunc GetFormulaCmdBits() const; + bool IsSkipEmptyCells() const; + bool IsTranspose() const; + bool IsLink() const; + InsCellCmd GetMoveMode() const; + + void SetOtherDoc( bool bSet ); + void SetFillMode( bool bSet ); + void SetChangeTrack( bool bSet ); + void SetCellShiftDisabled( CellShiftDisabledFlags nDisable ); + +private: + bool bOtherDoc; + bool bFillMode; + bool bChangeTrack; + bool bMoveDownDisabled; + bool bMoveRightDisabled; + bool bUsedShortCut; + + InsertDeleteFlags nShortCutInsContentsCmdBits; + bool bShortCutTranspose; + + + std::unique_ptr<weld::CheckButton> mxBtnInsAll; + std::unique_ptr<weld::CheckButton> mxBtnInsStrings; + std::unique_ptr<weld::CheckButton> mxBtnInsNumbers; + std::unique_ptr<weld::CheckButton> mxBtnInsDateTime; + std::unique_ptr<weld::CheckButton> mxBtnInsFormulas; + std::unique_ptr<weld::CheckButton> mxBtnInsNotes; + std::unique_ptr<weld::CheckButton> mxBtnInsAttrs; + std::unique_ptr<weld::CheckButton> mxBtnInsObjects; + + std::unique_ptr<weld::CheckButton> mxBtnSkipEmptyCells; + std::unique_ptr<weld::CheckButton> mxBtnTranspose; + std::unique_ptr<weld::CheckButton> mxBtnLink; + + std::unique_ptr<weld::RadioButton> mxRbNoOp; + std::unique_ptr<weld::RadioButton> mxRbAdd; + std::unique_ptr<weld::RadioButton> mxRbSub; + std::unique_ptr<weld::RadioButton> mxRbMul; + std::unique_ptr<weld::RadioButton> mxRbDiv; + + std::unique_ptr<weld::RadioButton> mxRbMoveNone; + std::unique_ptr<weld::RadioButton> mxRbMoveDown; + std::unique_ptr<weld::RadioButton> mxRbMoveRight; + + std::unique_ptr<weld::Button> mxBtnShortCutPasteValuesOnly; + std::unique_ptr<weld::Button> mxBtnShortCutPasteValuesFormats; + std::unique_ptr<weld::Button> mxBtnShortCutPasteTranspose; + + static bool bPreviousAllCheck; + static InsertDeleteFlags nPreviousChecks; + static InsertContentsFlags nPreviousChecks2; + static ScPasteFunc nPreviousFormulaChecks; + static sal_uInt16 nPreviousMoveMode; // enum InsCellCmd + + void DisableChecks( bool bInsAllChecked ); + void TestModes(); + + // Handler + DECL_LINK( InsAllHdl, weld::ToggleButton&, void ); + DECL_LINK( LinkBtnHdl, weld::ToggleButton&, void ); + DECL_LINK( ShortCutHdl, weld::Button&, void ); +}; + +#endif // INCLUDED_SC_SOURCE_UI_INC_INSCODLG_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/instbdlg.hxx b/sc/source/ui/inc/instbdlg.hxx new file mode 100644 index 000000000..449ec75e2 --- /dev/null +++ b/sc/source/ui/inc/instbdlg.hxx @@ -0,0 +1,96 @@ +/* -*- 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_SC_SOURCE_UI_INC_INSTBDLG_HXX +#define INCLUDED_SC_SOURCE_UI_INC_INSTBDLG_HXX + +#include <sfx2/objsh.hxx> +#include <vcl/weld.hxx> +#include <types.hxx> + +class ScViewData; +class ScDocument; +class ScDocShell; + +namespace sfx2 { class DocumentInserter; } +namespace sfx2 { class FileDialogHelper; } + +class ScInsertTableDlg : public weld::GenericDialogController +{ +public: + ScInsertTableDlg(weld::Window* pParent, ScViewData& rViewData, SCTAB nTabCount, bool bFromFile); + virtual ~ScInsertTableDlg() override; + + virtual short run() override; // override to set parent dialog + + bool GetTablesFromFile() const { return m_xBtnFromFile->get_active(); } + bool GetTablesAsLink() const { return m_xBtnLink->get_active(); } + + const OUString* GetFirstTable( sal_uInt16* pN ); + const OUString* GetNextTable( sal_uInt16* pN ); + ScDocShell* GetDocShellTables() { return pDocShTables; } + bool IsTableBefore() const { return m_xBtnBefore->get_active(); } + SCTAB GetTableCount() const { return nTableCount;} + +private: + Timer aBrowseTimer; + ScViewData& rViewData; + ScDocument& rDoc; + ScDocShell* pDocShTables; + std::unique_ptr<sfx2::DocumentInserter> pDocInserter; + SfxObjectShellRef aDocShTablesRef; + + bool bMustClose; + sal_uInt16 nSelTabIndex; // for GetFirstTable() / GetNextTable() + OUString aStrCurSelTable; + SCTAB nTableCount; + OUString m_sSheetDotDotDot; + + std::unique_ptr<weld::RadioButton> m_xBtnBefore; + std::unique_ptr<weld::RadioButton> m_xBtnBehind; + std::unique_ptr<weld::RadioButton> m_xBtnNew; + std::unique_ptr<weld::RadioButton> m_xBtnFromFile; + std::unique_ptr<weld::Label> m_xFtCount; + std::unique_ptr<weld::SpinButton> m_xNfCount; + std::unique_ptr<weld::Label> m_xFtName; + std::unique_ptr<weld::Entry> m_xEdName; + std::unique_ptr<weld::TreeView> m_xLbTables; + std::unique_ptr<weld::Label> m_xFtPath; + std::unique_ptr<weld::Button> m_xBtnBrowse; + std::unique_ptr<weld::CheckButton> m_xBtnLink; + std::unique_ptr<weld::Button> m_xBtnOk; + + void Init_Impl( bool bFromFile ); + void SetNewTable_Impl(); + void SetFromTo_Impl(); + void FillTables_Impl( const ScDocument* pSrcDoc ); + void DoEnable_Impl(); + + DECL_LINK( BrowseHdl_Impl, weld::Button&, void ); + DECL_LINK( ChoiceHdl_Impl, weld::Button&, void ); + DECL_LINK( SelectHdl_Impl, weld::TreeView&, void ); + DECL_LINK( CountHdl_Impl, weld::SpinButton&, void ); + DECL_LINK( DoEnterHdl, weld::Button&, void ); + DECL_LINK( BrowseTimeoutHdl, Timer *, void ); + DECL_LINK( DialogClosedHdl, sfx2::FileDialogHelper*, void ); +}; + +#endif // INCLUDED_SC_SOURCE_UI_INC_INSTBDLG_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/invmerge.hxx b/sc/source/ui/inc/invmerge.hxx new file mode 100644 index 000000000..695261434 --- /dev/null +++ b/sc/source/ui/inc/invmerge.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_SC_SOURCE_UI_INC_INVMERGE_HXX +#define INCLUDED_SC_SOURCE_UI_INC_INVMERGE_HXX + +#include <tools/gen.hxx> + +#include <vector> + +class ScInvertMerger +{ +private: + ::std::vector< tools::Rectangle >* pRects; + tools::Rectangle aTotalRect; + tools::Rectangle aLineRect; + + void FlushLine(); + void FlushTotal(); + +public: + ScInvertMerger( ::std::vector< tools::Rectangle >* pRectangles ); + ~ScInvertMerger(); + + void AddRect( const tools::Rectangle& rRect ); + void Flush(); +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/lbseldlg.hxx b/sc/source/ui/inc/lbseldlg.hxx new file mode 100644 index 000000000..84699d555 --- /dev/null +++ b/sc/source/ui/inc/lbseldlg.hxx @@ -0,0 +1,41 @@ +/* -*- 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_SC_SOURCE_UI_INC_LBSELDLG_HXX +#define INCLUDED_SC_SOURCE_UI_INC_LBSELDLG_HXX + +#include <vcl/weld.hxx> + +class ScSelEntryDlg : public weld::GenericDialogController +{ +private: + std::unique_ptr<weld::TreeView> m_xLb; + + DECL_LINK(DblClkHdl, weld::TreeView&, bool); + +public: + ScSelEntryDlg(weld::Window* pParent, const std::vector<OUString>& rEntryList); + virtual ~ScSelEntryDlg() override; + + OUString GetSelectedEntry() const; +}; + +#endif // INCLUDED_SC_SOURCE_UI_INC_LBSELDLG_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/linkarea.hxx b/sc/source/ui/inc/linkarea.hxx new file mode 100644 index 000000000..85cf87f06 --- /dev/null +++ b/sc/source/ui/inc/linkarea.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_SC_SOURCE_UI_INC_LINKAREA_HXX +#define INCLUDED_SC_SOURCE_UI_INC_LINKAREA_HXX + +#include <sfx2/objsh.hxx> +#include <tools/solar.h> +#include <vcl/weld.hxx> + +namespace sfx2 { class DocumentInserter; } +namespace sfx2 { class FileDialogHelper; } + +class ScDocShell; +class SvtURLBox; + +class ScLinkedAreaDlg : public weld::GenericDialogController +{ +private: + ScDocShell* m_pSourceShell; + std::unique_ptr<sfx2::DocumentInserter> m_xDocInserter; + SfxObjectShellRef aSourceRef; + + std::unique_ptr<SvtURLBox> m_xCbUrl; + std::unique_ptr<weld::Button> m_xBtnBrowse; + std::unique_ptr<weld::TreeView> m_xLbRanges; + std::unique_ptr<weld::CheckButton> m_xBtnReload; + std::unique_ptr<weld::SpinButton> m_xNfDelay; + std::unique_ptr<weld::Label> m_xFtSeconds; + std::unique_ptr<weld::Button> m_xBtnOk; + + DECL_LINK(FileHdl, weld::ComboBox&, bool); + DECL_LINK(BrowseHdl, weld::Button&, void); + DECL_LINK(RangeHdl, weld::TreeView&, void); + DECL_LINK(ReloadHdl, weld::Button&, void); + DECL_LINK(DialogClosedHdl, sfx2::FileDialogHelper*, void); + + void UpdateSourceRanges(); + void UpdateEnable(); + void LoadDocument( const OUString& rFile, const OUString& rFilter, + const OUString& rOptions ); + +public: + ScLinkedAreaDlg(weld::Window* pParent); + virtual ~ScLinkedAreaDlg() override; + + void InitFromOldLink( const OUString& rFile, const OUString& rFilter, + const OUString& rOptions, const OUString& rSource, + sal_uLong nRefresh ); + + OUString GetURL() const; + OUString GetFilter() const; // may be empty + OUString GetOptions() const; // filter options + OUString GetSource() const; // separated by ";" + sal_uLong GetRefresh() const; // 0 if disabled +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/lnktrans.hxx b/sc/source/ui/inc/lnktrans.hxx new file mode 100644 index 000000000..208bfaa67 --- /dev/null +++ b/sc/source/ui/inc/lnktrans.hxx @@ -0,0 +1,45 @@ +/* -*- 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_SC_SOURCE_UI_INC_LNKTRANS_HXX +#define INCLUDED_SC_SOURCE_UI_INC_LNKTRANS_HXX + +#include <vcl/transfer.hxx> +#include <rtl/ustring.hxx> + +class ScLinkTransferObj : public TransferDataContainer +{ +private: + OUString aLinkURL; + OUString aLinkText; + +public: + ScLinkTransferObj(); + virtual ~ScLinkTransferObj() override; + + void SetLinkURL( const OUString& rURL, const OUString& rText ); + + virtual void AddSupportedFormats() override; + virtual bool GetData( const css::datatransfer::DataFlavor& rFlavor, const OUString& rDestDoc ) override; + virtual void DragFinished( sal_Int8 nDropAction ) override; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/mediash.hxx b/sc/source/ui/inc/mediash.hxx new file mode 100644 index 000000000..6d75a4b68 --- /dev/null +++ b/sc/source/ui/inc/mediash.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_SC_SOURCE_UI_INC_MEDIASH_HXX +#define INCLUDED_SC_SOURCE_UI_INC_MEDIASH_HXX + +#include <sfx2/shell.hxx> +#include <shellids.hxx> + +class ScViewData; +class SfxModule; + +#include "drawsh.hxx" + +class ScMediaShell : public ScDrawShell +{ +public: + SFX_DECL_INTERFACE(SCID_MEDIA_SHELL) + +private: + /// SfxInterface initializer. + static void InitInterface_Impl(); + +public: + ScMediaShell(ScViewData* pData); + virtual ~ScMediaShell() override; + + void ExecuteMedia(const SfxRequest& rReq); + void GetMediaState(SfxItemSet& rSet); +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/mergecellsdialog.hxx b/sc/source/ui/inc/mergecellsdialog.hxx new file mode 100644 index 000000000..6dde67680 --- /dev/null +++ b/sc/source/ui/inc/mergecellsdialog.hxx @@ -0,0 +1,38 @@ +/* -*- 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_SC_SOURCE_UI_INC_MERGECELLSDIALOG_HXX +#define INCLUDED_SC_SOURCE_UI_INC_MERGECELLSDIALOG_HXX + +#include <vcl/weld.hxx> + +enum ScMergeCellsOption +{ + MoveContentHiddenCells, + KeepContentHiddenCells, + EmptyContentHiddenCells +}; + +class ScMergeCellsDialog : public weld::GenericDialogController +{ + std::unique_ptr<weld::RadioButton> m_xRBMoveContent; + std::unique_ptr<weld::RadioButton> m_xRBKeepContent; + std::unique_ptr<weld::RadioButton> m_xRBEmptyContent; + +public: + ScMergeCellsDialog(weld::Window* pParent); + virtual ~ScMergeCellsDialog() override; + + ScMergeCellsOption GetMergeCellsOption() const; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/msgpool.hxx b/sc/source/ui/inc/msgpool.hxx new file mode 100644 index 000000000..974b267e1 --- /dev/null +++ b/sc/source/ui/inc/msgpool.hxx @@ -0,0 +1,60 @@ +/* -*- 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_SC_SOURCE_UI_INC_MSGPOOL_HXX +#define INCLUDED_SC_SOURCE_UI_INC_MSGPOOL_HXX + +#include <svl/srchitem.hxx> + +#include <svl/itempool.hxx> +#include <svl/stritem.hxx> + +#include "uiitems.hxx" +#include "condformatdlgitem.hxx" + +class ScDocumentPool; + +class ScMessagePool: public SfxItemPool +{ + SfxStringItem aGlobalStringItem; + SvxSearchItem aGlobalSearchItem; + ScSortItem aGlobalSortItem; + ScQueryItem aGlobalQueryItem; + ScSubTotalItem aGlobalSubTotalItem; + ScConsolidateItem aGlobalConsolidateItem; + ScPivotItem aGlobalPivotItem; + ScSolveItem aGlobalSolveItem; + ScUserListItem aGlobalUserListItem; + ScCondFormatDlgItem aCondFormatDlgItem; + + std::vector<SfxPoolItem*> mvPoolDefaults; + ScDocumentPool* pDocPool; + +public: + ScMessagePool(); +protected: + virtual ~ScMessagePool() override; +public: + + virtual MapUnit GetMetric( sal_uInt16 nWhich ) const override; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/mtrindlg.hxx b/sc/source/ui/inc/mtrindlg.hxx new file mode 100644 index 000000000..59b41f225 --- /dev/null +++ b/sc/source/ui/inc/mtrindlg.hxx @@ -0,0 +1,52 @@ +/* -*- 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_SC_SOURCE_UI_INC_MTRINDLG_HXX +#define INCLUDED_SC_SOURCE_UI_INC_MTRINDLG_HXX + +#include <vcl/weld.hxx> + +class ScMetricInputDlg : public weld::GenericDialogController +{ +public: + ScMetricInputDlg( weld::Window* pParent, + const OString& sDialogName, + long nCurrent, + long nDefault, + FieldUnit eFUnit, + sal_uInt16 nDecimals, + long nMaximum, + long nMinimum); + virtual ~ScMetricInputDlg() override; + + int GetInputValue() const; + +private: + std::unique_ptr<weld::MetricSpinButton> m_xEdValue; + std::unique_ptr<weld::CheckButton> m_xBtnDefVal; + int nDefaultValue; + int nCurrentValue; + + DECL_LINK(SetDefValHdl, weld::Button&, void); + DECL_LINK(ModifyHdl, weld::MetricSpinButton&, void); +}; + +#endif // INCLUDED_SC_SOURCE_UI_INC_MTRINDLG_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/mvtabdlg.hxx b/sc/source/ui/inc/mvtabdlg.hxx new file mode 100644 index 000000000..9836cc544 --- /dev/null +++ b/sc/source/ui/inc/mvtabdlg.hxx @@ -0,0 +1,85 @@ +/* -*- 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_SC_SOURCE_UI_INC_MVTABDLG_HXX +#define INCLUDED_SC_SOURCE_UI_INC_MVTABDLG_HXX + +#include <types.hxx> +#include <vcl/weld.hxx> + +class ScDocument; + +class ScMoveTableDlg : public weld::GenericDialogController +{ +public: + ScMoveTableDlg(weld::Window* pParent, const OUString& rDefault); + virtual ~ScMoveTableDlg() override; + + sal_uInt16 GetSelectedDocument () const { return nDocument; } + SCTAB GetSelectedTable () const { return nTable; } + bool GetCopyTable () const { return bCopyTable; } + bool GetRenameTable () const { return bRenameTable; } + void GetTabNameString( OUString& rString ) const; + void SetForceCopyTable (); + void EnableRenameTable (bool bFlag); + +private: + void ResetRenameInput(); + void CheckNewTabName(); + ScDocument* GetSelectedDoc(); + +private: + OUString msCurrentDoc; + OUString msNewDoc; + + OUString msStrTabNameUsed; + OUString msStrTabNameEmpty; + OUString msStrTabNameInvalid; + + const OUString maDefaultName; + + sal_uInt16 mnCurrentDocPos; + sal_uInt16 nDocument; + SCTAB nTable; + bool bCopyTable:1; + bool bRenameTable:1; + bool mbEverEdited:1; + + std::unique_ptr<weld::RadioButton> m_xBtnMove; + std::unique_ptr<weld::RadioButton> m_xBtnCopy; + std::unique_ptr<weld::ComboBox> m_xLbDoc; + std::unique_ptr<weld::TreeView> m_xLbTable; + std::unique_ptr<weld::Entry> m_xEdTabName; + std::unique_ptr<weld::Label> m_xFtWarn; + std::unique_ptr<weld::Button> m_xBtnOk; + std::unique_ptr<weld::Label> m_xUnusedLabel; + std::unique_ptr<weld::Label> m_xEmptyLabel; + std::unique_ptr<weld::Label> m_xInvalidLabel; + + void Init (); + void InitDocListBox (); + DECL_LINK(OkHdl, weld::Button&, void); + DECL_LINK(SelHdl, weld::ComboBox&, void); + DECL_LINK(CheckBtnHdl, weld::ToggleButton&, void); + DECL_LINK(CheckNameHdl, weld::Entry&, void); +}; + +#endif // INCLUDED_SC_SOURCE_UI_INC_MVTABDLG_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/namecrea.hxx b/sc/source/ui/inc/namecrea.hxx new file mode 100644 index 000000000..c5d6d8892 --- /dev/null +++ b/sc/source/ui/inc/namecrea.hxx @@ -0,0 +1,41 @@ +/* -*- 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_SC_SOURCE_UI_INC_NAMECREA_HXX +#define INCLUDED_SC_SOURCE_UI_INC_NAMECREA_HXX + +#include <vcl/weld.hxx> +#include "scui_def.hxx" + +class ScNameCreateDlg final : public weld::GenericDialogController +{ + std::unique_ptr<weld::CheckButton> m_xTopBox; + std::unique_ptr<weld::CheckButton> m_xLeftBox; + std::unique_ptr<weld::CheckButton> m_xBottomBox; + std::unique_ptr<weld::CheckButton> m_xRightBox; + +public: + ScNameCreateDlg(weld::Window* pParent, CreateNameFlags nFlags); + virtual ~ScNameCreateDlg() override; + CreateNameFlags GetFlags() const; +}; + +#endif // INCLUDED_SC_SOURCE_UI_INC_NAMECREA_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/namedefdlg.hxx b/sc/source/ui/inc/namedefdlg.hxx new file mode 100644 index 000000000..7225f592d --- /dev/null +++ b/sc/source/ui/inc/namedefdlg.hxx @@ -0,0 +1,92 @@ +/* -*- 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_SC_SOURCE_UI_INC_NAMEDEFDLG_HXX +#define INCLUDED_SC_SOURCE_UI_INC_NAMEDEFDLG_HXX + +#include "anyrefdg.hxx" + +#include <map> + +class ScRangeName; +class ScDocument; +class ScDocShell; +class ScViewData; + +class ScNameDefDlg : public ScAnyRefDlgController +{ +private: + bool mbUndo; //if true we need to add an undo action after creating a range name + ScDocument& mrDoc; + ScDocShell* mpDocShell; + + ScAddress maCursorPos; + OUString maStrInfoDefault; + const OUString maGlobalNameStr; + const OUString maErrInvalidNameStr; + const OUString maErrInvalidNameCellRefStr; + const OUString maErrNameInUse; + + //hack to call this dialog from Manage Names + OUString maName; + OUString maScope; + + std::map<OUString, ScRangeName*> maRangeMap; + + std::unique_ptr<weld::Entry> m_xEdName; + + std::unique_ptr<formula::RefEdit> m_xEdRange; + std::unique_ptr<formula::RefButton> m_xRbRange; + + std::unique_ptr<weld::ComboBox> m_xLbScope; + + std::unique_ptr<weld::CheckButton> m_xBtnRowHeader; + std::unique_ptr<weld::CheckButton> m_xBtnColHeader; + std::unique_ptr<weld::CheckButton> m_xBtnPrintArea; + std::unique_ptr<weld::CheckButton> m_xBtnCriteria; + + std::unique_ptr<weld::Button> m_xBtnAdd; + std::unique_ptr<weld::Button> m_xBtnCancel; + std::unique_ptr<weld::Label> m_xFtInfo; + std::unique_ptr<weld::Expander> m_xExpander; + std::unique_ptr<weld::Label> m_xFtRange; + + void CancelPushed(); + void AddPushed(); + + bool IsNameValid(); + bool IsFormulaValid(); + + DECL_LINK( CancelBtnHdl, weld::Button&, void ); + DECL_LINK( AddBtnHdl, weld::Button&, void ); + DECL_LINK( NameModifyHdl, weld::Entry&, void ); + DECL_LINK( AssignGetFocusHdl, formula::RefEdit&, void ); + +protected: + virtual void RefInputDone( bool bForced = false ) override; + +public: + ScNameDefDlg( SfxBindings* pB, SfxChildWindow* pCW, weld::Window* pParent, + const ScViewData* pViewData, const std::map<OUString, ScRangeName*>& aRangeMap, + const ScAddress& aCursorPos, const bool bUndo); + + virtual ~ScNameDefDlg() override; + + virtual void SetReference( const ScRange& rRef, ScDocument& rDoc ) override; + virtual bool IsRefInputMode() const override; + + virtual void SetActive() override; + virtual void Close() override; + + void GetNewData( OUString& rName, OUString& rScope ); +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/namedlg.hxx b/sc/source/ui/inc/namedlg.hxx new file mode 100644 index 000000000..e7bb0a1df --- /dev/null +++ b/sc/source/ui/inc/namedlg.hxx @@ -0,0 +1,128 @@ +/* -*- 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_SC_SOURCE_UI_INC_NAMEDLG_HXX +#define INCLUDED_SC_SOURCE_UI_INC_NAMEDLG_HXX + +#include "anyrefdg.hxx" +#include "namemgrtable.hxx" + +#include <memory> +#include <map> + +class ScViewData; +class ScDocument; + +//logic behind the manage names dialog +class ScNameDlg : public ScAnyRefDlgController +{ +private: + const OUString maGlobalNameStr; + const OUString maErrInvalidNameStr; + const OUString maErrNameInUse; + const OUString maStrMultiSelect; + OUString maStrInfoDefault; + + ScViewData* mpViewData; + ScDocument* mpDoc; + const ScAddress maCursorPos; + + bool mbDataChanged; + //ugly hack to call DefineNames from ManageNames + bool mbCloseWithoutUndo; + + typedef std::map<OUString, std::unique_ptr<ScRangeName>> RangeNameContainer; + + RangeNameContainer m_RangeMap; + + std::unique_ptr<weld::Entry> m_xEdName; + std::unique_ptr<weld::Label> m_xFtAssign; + std::unique_ptr<formula::RefEdit> m_xEdAssign; + std::unique_ptr<formula::RefButton> m_xRbAssign; + std::unique_ptr<weld::ComboBox> m_xLbScope; + + std::unique_ptr<weld::CheckButton> m_xBtnPrintArea; + std::unique_ptr<weld::CheckButton> m_xBtnColHeader; + std::unique_ptr<weld::CheckButton> m_xBtnCriteria; + std::unique_ptr<weld::CheckButton> m_xBtnRowHeader; + + std::unique_ptr<weld::Button> m_xBtnAdd; + std::unique_ptr<weld::Button> m_xBtnDelete; + std::unique_ptr<weld::Button> m_xBtnOk; + std::unique_ptr<weld::Button> m_xBtnCancel; + + std::unique_ptr<weld::Label> m_xFtInfo; + + std::unique_ptr<weld::Expander> m_xExpander; + + std::unique_ptr<ScRangeManagerTable> m_xRangeManagerTable; + +private: + void Init(); + void UpdateChecks(const ScRangeData* pData); + void ShowOptions(const ScRangeNameLine& rLine); + + bool IsNameValid(); + bool IsFormulaValid(); + void CheckForEmptyTable(); + + ScRangeName* GetRangeName(const OUString& rScope); + + void AddPushed(); + void RemovePushed(); + void ScopeChanged(); + void NameModified(); + + void SelectionChanged(); + + // Handler: + DECL_LINK( OkBtnHdl, weld::Button&, void ); + DECL_LINK( CancelBtnHdl, weld::Button&, void ); + DECL_LINK( AddBtnHdl, weld::Button&, void ); + DECL_LINK( RemoveBtnHdl, weld::Button&, void ); + DECL_LINK( EdModifyHdl, weld::Entry&, void ); + DECL_LINK( RefEdModifyHdl, formula::RefEdit&, void ); + DECL_LINK( EdModifyCheckBoxHdl, weld::ToggleButton&, void ); + DECL_LINK( AssignGetFocusHdl, formula::RefEdit&, void ); + DECL_LINK( SelectionChangedHdl_Impl, weld::TreeView&, void ); + DECL_LINK( ScopeChangedHdl, weld::ComboBox&, void ); + +protected: + virtual void RefInputDone( bool bForced = false ) override; + +public: + ScNameDlg( SfxBindings* pB, SfxChildWindow* pCW, weld::Window* pParent, + ScViewData* ptrViewData, + const ScAddress& aCursorPos, + std::map<OUString, std::unique_ptr<ScRangeName>>* pRangeMap = nullptr); + virtual ~ScNameDlg() override; + + virtual void SetReference( const ScRange& rRef, ScDocument& rDoc ) override; + virtual bool IsRefInputMode() const override; + + virtual void SetActive() override; + virtual void Close() override; + + void GetRangeNames(std::map<OUString, std::unique_ptr<ScRangeName>>& rRangeMap); + void SetEntry(const OUString& rName, const OUString& rScope); +}; + +#endif // INCLUDED_SC_SOURCE_UI_INC_NAMEDLG_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/namemgrtable.hxx b/sc/source/ui/inc/namemgrtable.hxx new file mode 100644 index 000000000..d092f7d18 --- /dev/null +++ b/sc/source/ui/inc/namemgrtable.hxx @@ -0,0 +1,94 @@ +/* -*- 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_SC_SOURCE_UI_INC_NAMEMGRTABLE_HXX +#define INCLUDED_SC_SOURCE_UI_INC_NAMEMGRTABLE_HXX + +#include <vcl/weld.hxx> + +#include <address.hxx> + +#include <memory> +#include <vector> +#include <map> + +class ScRangeName; +class ScRangeData; + +struct ScRangeNameLine +{ + OUString aName; + OUString aExpression; + OUString aScope; +}; + +class SC_DLLPUBLIC ScRangeManagerTable +{ +private: + std::unique_ptr<weld::TreeView> m_xTreeView; + + OUString maGlobalString; + + // should be const because we should not modify it here + const std::map<OUString, std::unique_ptr<ScRangeName>>& m_RangeMap; + // for performance, save which entries already have the formula entry + // otherwise opening the dialog with a lot of range names is extremely slow because + // we would calculate all formula strings during opening + std::map<OUString, bool> maCalculatedFormulaEntries; + const ScAddress maPos; + + int m_nId; + + bool mbNeedUpdate; + + void GetLine(ScRangeNameLine& aLine, const weld::TreeIter& rEntry); + void Init(); + const ScRangeData* findRangeData(const ScRangeNameLine& rLine); + + DECL_LINK(SizeAllocHdl, const Size&, void); + DECL_LINK(VisRowsScrolledHdl, weld::TreeView&, void); + +public: + ScRangeManagerTable(std::unique_ptr<weld::TreeView>, + const std::map<OUString, std::unique_ptr<ScRangeName>>& rTabRangeNames, + const ScAddress& rPos); + + void CheckForFormulaString(); + + int n_children() const { return m_xTreeView->n_children(); } + void connect_changed(const Link<weld::TreeView&, void>& rLink) { m_xTreeView->connect_changed(rLink); } + void set_cursor(int nPos) { m_xTreeView->set_cursor(nPos); } + + void addEntry(const ScRangeNameLine& rLine, bool bSetCurEntry); + void DeleteSelectedEntries(); + void SetEntry( const ScRangeNameLine& rLine ); + + void GetCurrentLine(ScRangeNameLine& rLine); + bool IsMultiSelection() const; + std::vector<ScRangeNameLine> GetSelectedEntries(); + + void BlockUpdate() + { + mbNeedUpdate = false; + } + + bool UpdatesBlocked() const + { + return !mbNeedUpdate; + } + + void UnblockUpdate() + { + mbNeedUpdate = true; + } +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/namepast.hxx b/sc/source/ui/inc/namepast.hxx new file mode 100644 index 000000000..b5f09be8b --- /dev/null +++ b/sc/source/ui/inc/namepast.hxx @@ -0,0 +1,55 @@ +/* -*- 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_SC_SOURCE_UI_INC_NAMEPAST_HXX +#define INCLUDED_SC_SOURCE_UI_INC_NAMEPAST_HXX + +#include <vcl/weld.hxx> +#include "namemgrtable.hxx" +#include <memory> +#include <vector> +#include <map> + +class ScRangeName; +class ScDocShell; + +class ScNamePasteDlg : public weld::GenericDialogController +{ + DECL_LINK(ButtonHdl, weld::Button&, void); + +private: + std::unique_ptr<weld::Button> m_xBtnPasteAll; + std::unique_ptr<weld::Button> m_xBtnPaste; + std::unique_ptr<weld::Button> m_xBtnClose; + std::unique_ptr<ScRangeManagerTable> m_xTable; + + std::vector<OUString> maSelectedNames; + std::map<OUString, std::unique_ptr<ScRangeName>> m_RangeMap; + +public: + ScNamePasteDlg(weld::Window* pParent, ScDocShell* pShell); + + virtual ~ScNamePasteDlg() override; + + const std::vector<OUString>& GetSelectedNames() const; +}; + +#endif // INCLUDED_SC_SOURCE_UI_INC_NAMEPAST_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/navcitem.hxx b/sc/source/ui/inc/navcitem.hxx new file mode 100644 index 000000000..e3b2fe9b6 --- /dev/null +++ b/sc/source/ui/inc/navcitem.hxx @@ -0,0 +1,43 @@ +/* -*- 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_SC_SOURCE_UI_INC_NAVCITEM_HXX +#define INCLUDED_SC_SOURCE_UI_INC_NAVCITEM_HXX + +#include <sfx2/ctrlitem.hxx> + +class ScNavigatorDlg; + +class ScNavigatorControllerItem : public SfxControllerItem +{ +public: + ScNavigatorControllerItem( sal_uInt16 nId, + ScNavigatorDlg& rDlg, + SfxBindings& rBindings ); +protected: + virtual void StateChanged( sal_uInt16 nSID, SfxItemState eState, + const SfxPoolItem* pItem ) override; + +private: + ScNavigatorDlg& rNavigatorDlg; +}; + +#endif // INCLUDED_SC_SOURCE_UI_INC_NAVCITEM_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/navipi.hxx b/sc/source/ui/inc/navipi.hxx new file mode 100644 index 000000000..d93642cfc --- /dev/null +++ b/sc/source/ui/inc/navipi.hxx @@ -0,0 +1,201 @@ +/* -*- 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_SC_SOURCE_UI_INC_NAVIPI_HXX +#define INCLUDED_SC_SOURCE_UI_INC_NAVIPI_HXX + +#include <vector> +#include <vcl/idle.hxx> +#include <svl/lstner.hxx> +#include <sfx2/childwin.hxx> +#include <sfx2/sidebar/PanelLayout.hxx> +#include "content.hxx" + +class SfxPoolItem; +class ScTabViewShell; +class ScViewData; +class ScArea; +class ScScenarioWindow; +class ScNavigatorControllerItem; +class ScNavigatorDlg; +class ScNavigatorSettings; + +#define SC_DROPMODE_URL 0 +#define SC_DROPMODE_LINK 1 +#define SC_DROPMODE_COPY 2 + +enum NavListMode { NAV_LMODE_NONE = 0x4000, + NAV_LMODE_AREAS = 0x2000, + NAV_LMODE_SCENARIOS = 0x400 }; + +class ScScenarioWindow +{ +public: + ScScenarioWindow(weld::Builder& rBuilder, const OUString& rQH_List, const OUString& rQH_Comment); + ~ScScenarioWindow(); + void NotifyState(const SfxPoolItem* pState); + void SetComment(const OUString& rComment) + { + m_xEdComment->set_text(rComment); + } + +private: + std::unique_ptr<weld::TreeView> m_xLbScenario; + std::unique_ptr<weld::TextView> m_xEdComment; + + struct ScenarioEntry + { + OUString maName; + OUString maComment; + bool mbProtected; + + explicit ScenarioEntry() : mbProtected( false ) {} + }; + typedef ::std::vector< ScenarioEntry > ScenarioList; + + ScenarioList m_aEntries; + + void UpdateEntries(const std::vector<OUString> &rNewEntryList); + void SelectScenario(); + void ExecuteScenarioSlot(sal_uInt16 nSlotId); + void EditScenario(); + void DeleteScenario(); + const ScenarioEntry* GetSelectedScenarioEntry() const; + + DECL_LINK(SelectHdl, weld::TreeView&, void); + DECL_LINK(DoubleClickHdl, weld::TreeView&, bool); + DECL_LINK(KeyInputHdl, const KeyEvent&, bool); + DECL_LINK(ContextMenuHdl, const CommandEvent&, bool); +}; + +class ScNavigatorDlg : public PanelLayout, public SfxListener +{ +friend class ScNavigatorControllerItem; +friend class ScNavigatorDialogWrapper; +friend class ScContentTree; +friend class ScNavigatorDlgUIObject; + +private: + static constexpr int CTRL_ITEMS = 4; + + SfxBindings& rBindings; // must be first member + + std::unique_ptr<weld::SpinButton> m_xEdCol; + std::unique_ptr<weld::SpinButton> m_xEdRow; + std::unique_ptr<weld::Toolbar> m_xTbxCmd1; + std::unique_ptr<weld::Toolbar> m_xTbxCmd2; + std::unique_ptr<ScContentTree> m_xLbEntries; + std::unique_ptr<weld::Widget> m_xScenarioBox; + std::unique_ptr<ScScenarioWindow> m_xWndScenarios; + std::unique_ptr<weld::ComboBox> m_xLbDocuments; + std::unique_ptr<weld::Menu> m_xDragModeMenu; + + Size aExpandedSize; + Idle aContentIdle; + + OUString aStrActive; + OUString aStrNotActive; + OUString aStrHidden; + OUString aStrActiveWin; + + std::unique_ptr<ScArea> pMarkArea; + ScViewData* pViewData; + + NavListMode eListMode; + sal_uInt16 nDropMode; + SCCOL nCurCol; + SCROW nCurRow; + SCTAB nCurTab; + + std::array<std::unique_ptr<ScNavigatorControllerItem>,CTRL_ITEMS> mvBoundItems; + + DECL_LINK(TimeHdl, Timer*, void); + DECL_LINK(DocumentSelectHdl, weld::ComboBox&, void); + DECL_LINK(ExecuteRowHdl, weld::Entry&, bool); + DECL_LINK(ExecuteColHdl, weld::Entry&, bool); + DECL_LINK(ToolBoxSelectHdl, const OString&, void); + DECL_LINK(ToolBoxDropdownClickHdl, const OString&, void); + DECL_LINK(MenuSelectHdl, const OString&, void); + DECL_LINK(FormatRowOutputHdl, weld::SpinButton&, void); + DECL_LINK(ParseRowInputHdl, int*, bool); + + void UpdateButtons(); + void SetCurrentCell( SCCOL nCol, SCROW Row ); + void SetCurrentCellStr( const OUString& rName ); + void SetCurrentTable( SCTAB nTab ); + void SetCurrentTableStr( const OUString& rName ); + void SetCurrentObject( const OUString& rName ); + void SetCurrentDoc( const OUString& rDocName ); + void UpdateSelection(); + + static ScTabViewShell* GetTabViewShell(); + static ScNavigatorSettings* GetNavigatorSettings(); + ScViewData* GetViewData(); + + + void UpdateColumn ( const SCCOL* pCol = nullptr ); + void UpdateRow ( const SCROW* pRow = nullptr ); + void UpdateTable ( const SCTAB* pTab ); + void UpdateAll (); + + void GetDocNames(const OUString* pSelEntry); + + void SetListMode(NavListMode eMode); + void ShowList(bool bShow); + void ShowScenarios(); + + void SetDropMode(sal_uInt16 nNew); + sal_uInt16 GetDropMode() const { return nDropMode; } + + void MarkDataArea (); + void UnmarkDataArea (); + void StartOfDataArea (); + void EndOfDataArea (); + + static void ReleaseFocus(); + +public: + ScNavigatorDlg(SfxBindings* pB, vcl::Window* pParent); + virtual ~ScNavigatorDlg() override; + virtual void dispose() override; + + virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override; + + virtual void StateChanged(StateChangedType nStateChange) override; + + FactoryFunction GetUITestFactory() const override; +}; + +class ScNavigatorDialogWrapper: public SfxChildWindowContext +{ +public: + ScNavigatorDialogWrapper( vcl::Window* pParent, + sal_uInt16 nId, + SfxBindings* pBindings, + SfxChildWinInfo* pInfo ); + + SFX_DECL_CHILDWINDOWCONTEXT(ScNavigatorDialogWrapper) + +private: + VclPtr<ScNavigatorDlg> pNavigator; +}; + +#endif // INCLUDED_SC_SOURCE_UI_INC_NAVIPI_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/navsett.hxx b/sc/source/ui/inc/navsett.hxx new file mode 100644 index 000000000..9dbf8422a --- /dev/null +++ b/sc/source/ui/inc/navsett.hxx @@ -0,0 +1,52 @@ +/* -*- 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_SC_SOURCE_UI_INC_NAVSETT_HXX +#define INCLUDED_SC_SOURCE_UI_INC_NAVSETT_HXX + +#include <tools/solar.h> + +#include <o3tl/enumarray.hxx> +#include "content.hxx" + +/** Contains settings of the navigator listbox. This includes the expand state + of each listbox entry and the index of the selected entry and sub entry. */ +class ScNavigatorSettings +{ +private: + o3tl::enumarray<ScContentId,bool> maExpandedVec; /// Array of Booleans for expand state. + ScContentId mnRootSelected; /// Index of selected root entry. + sal_uLong mnChildSelected; /// Index of selected child entry. + +public: + ScNavigatorSettings(); + + void SetExpanded( ScContentId nIndex, bool bExpand ) { maExpandedVec[ nIndex ] = bExpand; } + bool IsExpanded( ScContentId nIndex ) const { return maExpandedVec[ nIndex ]; } + + void SetRootSelected( ScContentId nIndex ) { mnRootSelected = nIndex; } + ScContentId GetRootSelected() const { return mnRootSelected; } + + void SetChildSelected( sal_uLong nIndex ) { mnChildSelected = nIndex; } + sal_uLong GetChildSelected() const { return mnChildSelected; } +}; + +#endif // INCLUDED_SC_SOURCE_UI_INC_NAVSETT_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/notemark.hxx b/sc/source/ui/inc/notemark.hxx new file mode 100644 index 000000000..11297e42a --- /dev/null +++ b/sc/source/ui/inc/notemark.hxx @@ -0,0 +1,72 @@ +/* -*- 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_SC_SOURCE_UI_INC_NOTEMARK_HXX +#define INCLUDED_SC_SOURCE_UI_INC_NOTEMARK_HXX + +#include <vcl/mapmod.hxx> +#include <vcl/timer.hxx> +#include <vcl/vclptr.hxx> +#include <tools/gen.hxx> +#include <address.hxx> +#include <postit.hxx> + +namespace vcl { class Window; } + +class SdrModel; +class SdrCaptionObj; + +class ScNoteMarker +{ +private: + VclPtr<vcl::Window> m_pWindow; + VclPtr<vcl::Window> m_pRightWin; + VclPtr<vcl::Window> m_pBottomWin; + VclPtr<vcl::Window> m_pDiagWin; + ScDocument* m_pDoc; + ScAddress m_aDocPos; + OUString m_aUserText; + tools::Rectangle m_aVisRect; + Timer m_aTimer; + MapMode m_aMapMode; + bool m_bLeft; + bool m_bByKeyboard; + + tools::Rectangle m_aRect; + std::unique_ptr<SdrModel> m_pModel; + ScCaptionPtr m_xObject; + bool m_bVisible; + DECL_LINK( TimeHdl, Timer*, void ); + +public: + ScNoteMarker( vcl::Window* pWin, vcl::Window* pRight, vcl::Window* pBottom, vcl::Window* pDiagonal, + ScDocument* pD, const ScAddress& aPos, const OUString& rUser, + const MapMode& rMap, bool bLeftEdge, bool bForce, bool bKeyboard); + ~ScNoteMarker(); + + void Draw(); + void InvalidateWin(); + + const ScAddress& GetDocPos() const { return m_aDocPos; } + bool IsByKeyboard() const { return m_bByKeyboard; } +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/oleobjsh.hxx b/sc/source/ui/inc/oleobjsh.hxx new file mode 100644 index 000000000..07daf4215 --- /dev/null +++ b/sc/source/ui/inc/oleobjsh.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_SC_SOURCE_UI_INC_OLEOBJSH_HXX +#define INCLUDED_SC_SOURCE_UI_INC_OLEOBJSH_HXX + +#include <sfx2/shell.hxx> +#include <shellids.hxx> + +class ScViewData; +class SfxModule; + +#include "drawsh.hxx" + +class ScOleObjectShell : public ScDrawShell +{ +public: + SFX_DECL_INTERFACE(SCID_OLEOBJECT_SHELL) + +private: + /// SfxInterface initializer. + static void InitInterface_Impl(); + +public: + ScOleObjectShell(ScViewData* pData); + virtual ~ScOleObjectShell() override; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/olinefun.hxx b/sc/source/ui/inc/olinefun.hxx new file mode 100644 index 000000000..e29f7df4c --- /dev/null +++ b/sc/source/ui/inc/olinefun.hxx @@ -0,0 +1,55 @@ +/* -*- 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_SC_SOURCE_UI_INC_OLINEFUN_HXX +#define INCLUDED_SC_SOURCE_UI_INC_OLINEFUN_HXX + +#include <types.hxx> + +class ScDocShell; +class ScRange; + +class ScOutlineDocFunc +{ +private: + ScDocShell& rDocShell; + +public: + ScOutlineDocFunc( ScDocShell& rDocSh ): rDocShell(rDocSh) {} + + void MakeOutline( const ScRange& rRange, bool bColumns, bool bRecord, bool bApi ); + void RemoveOutline( const ScRange& rRange, bool bColumns, bool bRecord, bool bApi ); + bool RemoveAllOutlines( SCTAB nTab, bool bRecord ); + void AutoOutline( const ScRange& rRange, bool bRecord ); + + bool SelectLevel( SCTAB nTab, bool bColumns, sal_uInt16 nLevel, + bool bRecord, bool bPaint ); + + bool ShowMarkedOutlines( const ScRange& rRange, bool bRecord ); + bool HideMarkedOutlines( const ScRange& rRange, bool bRecord ); + + void ShowOutline( SCTAB nTab, bool bColumns, sal_uInt16 nLevel, sal_uInt16 nEntry, + bool bRecord, bool bPaint ); + bool HideOutline( SCTAB nTab, bool bColumns, sal_uInt16 nLevel, sal_uInt16 nEntry, + bool bRecord, bool bPaint ); +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/olinewin.hxx b/sc/source/ui/inc/olinewin.hxx new file mode 100644 index 000000000..806960cc7 --- /dev/null +++ b/sc/source/ui/inc/olinewin.hxx @@ -0,0 +1,228 @@ +/* -*- 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_SC_SOURCE_UI_INC_OLINEWIN_HXX +#define INCLUDED_SC_SOURCE_UI_INC_OLINEWIN_HXX + +#include <vcl/window.hxx> +#include "viewdata.hxx" + +class ScOutlineEntry; +class ScOutlineArray; + +enum ScOutlineMode { SC_OUTLINE_HOR, SC_OUTLINE_VER }; + +/** The window left of or above the spreadsheet containing the outline groups + and controls to expand/collapse them. */ +class ScOutlineWindow : public vcl::Window +{ +private: + ScViewData& mrViewData; /// View data containing the document. + ScSplitPos meWhich; /// Which area in split window. + bool mbHoriz; /// true = Horizontal orientation. + bool mbMirrorEntries; /// true = mirror the order of entries (including header) + bool mbMirrorLevels; /// true = mirror the order of levels, including the border + + Color maLineColor; /// Line color for expanded groups. + long mnHeaderSize; /// Size of the header area in entry direction. + long mnHeaderPos; /// Position of the header area in entry direction. + long mnMainFirstPos; /// First position of main area in entry direction. + long mnMainLastPos; /// Last position of main area in entry direction. + + size_t mnMTLevel; /// Mouse tracking: Level of active button. + size_t mnMTEntry; /// Mouse tracking: Entry index of active button. + bool mbMTActive; /// Mouse tracking active? + bool mbMTPressed; /// Mouse tracking: Button currently drawn pressed? + + tools::Rectangle maFocusRect; /// Focus rectangle on screen. + size_t mnFocusLevel; /// Level of focused button. + size_t mnFocusEntry; /// Entry index of focused button. + bool mbDontDrawFocus; /// Do not redraw focus in next Paint(). + +public: + ScOutlineWindow( + vcl::Window* pParent, + ScOutlineMode eMode, + ScViewData* pViewData, + ScSplitPos eWhich ); + virtual ~ScOutlineWindow() override; + virtual void dispose() override; + + /** Sets the size of the header area (width/height dep. on window type). */ + void SetHeaderSize( long nNewSize ); + /** Returns the width/height the window needs to show all levels. */ + long GetDepthSize() const; + + /** Scrolls the window content by the specified amount of pixels. */ + void ScrollPixel( long nDiff ); + + using Window::ShowFocus; + +private: + /** Initializes color and image settings. */ + void InitSettings(); + + /** Returns the calc document. */ + ScDocument& GetDoc() const { return *mrViewData.GetDocument(); } + /** Returns the current sheet index. */ + SCTAB GetTab() const { return mrViewData.GetTabNo(); } + /** Returns the outline array of the corresponding document. */ + const ScOutlineArray* GetOutlineArray() const; + /** Returns the specified outline entry. */ + const ScOutlineEntry* GetOutlineEntry( size_t nLevel, size_t nEntry ) const; + + /** Returns true, if the column/row is hidden. */ + bool IsHidden( SCCOLROW nColRowIndex ) const; + /** Returns true, if the column/row is filtered. */ + bool IsFiltered( SCCOLROW nColRowIndex ) const; + /** Returns true, if all columns/rows before nColRowIndex are hidden. */ + bool IsFirstVisible( SCCOLROW nColRowIndex ) const; + /** Returns the currently visible column/row range. */ + void GetVisibleRange( SCCOLROW& rnColRowStart, SCCOLROW& rnColRowEnd ) const; + + /** Returns the point in the window of the specified position. */ + Point GetPoint( long nLevelPos, long nEntryPos ) const; + /** Returns the rectangle in the window of the specified position. */ + tools::Rectangle GetRectangle( + long nLevelStart, long nEntryStart, + long nLevelEnd, long nEntryEnd ) const; + + /** Returns the window size for the level coordinate. */ + long GetOutputSizeLevel() const; + /** Returns the window size for the entry coordinate. */ + long GetOutputSizeEntry() const; + + /** Returns the count of levels of the outline array. 0 means no outlines. */ + size_t GetLevelCount() const; + /** Returns the pixel position of the specified level. */ + long GetLevelPos( size_t nLevel ) const; + /** Returns the level of the passed pixel position. */ + size_t GetLevelFromPos( long nLevelPos ) const; + + /** Returns the start coordinate of the specified column/row in the window. */ + long GetColRowPos( SCCOLROW nColRowIndex ) const; + /** Returns the entry position of header images. */ + long GetHeaderEntryPos() const; + /** Calculates the coordinates the outline entry takes in the window. + @return false = no part of the group is visible (outside window or collapsed by parent group). */ + bool GetEntryPos( + size_t nLevel, size_t nEntry, + long& rnStartPos, long& rnEndPos, long& rnImagePos ) const; + /** Calculates the absolute position of the image of the specified outline entry. + @param nLevel The level of the entry. + @param nEntry The entry index or SC_OL_HEADERENTRY for the header image. + @return false = image is not visible. */ + bool GetImagePos( size_t nLevel, size_t nEntry, Point& rPos ) const; + /** Returns true, if the button of the specified entry is visible in the window. */ + bool IsButtonVisible( size_t nLevel, size_t nEntry ) const; + + /** Returns true, if rPos is inside of a button or over the line of an expanded + group. The outline entry data is stored in the passed variables. */ + bool ItemHit( const Point& rPos, size_t& rnLevel, size_t& rnEntry, bool& rbButton ) const; + /** Returns true, if rPos is inside of a button. + The button data is stored in the passed variables. */ + bool ButtonHit( const Point& rPos, size_t& rnLevel, size_t& rnEntry ) const; + /** Returns true, if rPos is over the line of an expanded group. + The outline entry data is stored in the passed variables. */ + bool LineHit( const Point& rPos, size_t& rnLevel, size_t& rnEntry ) const; + + /** Performs an action with the specified item. + @param nLevel The level of the entry. + @param nEntry The entry index or SC_OL_HEADERENTRY for the header entry. */ + void DoFunction( size_t nLevel, size_t nEntry ) const; + /** Expands the specified entry (does nothing with header entries). */ + void DoExpand( size_t nLevel, size_t nEntry ) const; + /** Collapses the specified entry (does nothing with header entries). */ + void DoCollapse( size_t nLevel, size_t nEntry ) const; + + /** Returns true, if the focused button is visible in the window. */ + bool IsFocusButtonVisible() const; + + /** Calculates index of next/previous focus button in the current level (no paint). + @param bFindVisible true = repeats until a visible button has been found. + @return true = focus wrapped from end to start or vice versa. */ + bool ImplMoveFocusByEntry( bool bForward, bool bFindVisible ); + /** Calculates position of focus button in next/previous level (no paint). + @return true = focus wrapped from end to start or vice versa. */ + bool ImplMoveFocusByLevel( bool bForward ); + /** Calculates position of focus button in tab order. + Repeats until a visible button has been found. + @return true = focus wrapped from end to start or vice versa. */ + bool ImplMoveFocusByTabOrder( bool bForward ); + + /** If the focused entry is invisible, tries to move to visible position. */ + void ImplMoveFocusToVisible( bool bForward ); + + /** Focuses next/previous button in the current level. */ + void MoveFocusByEntry( bool bForward ); + /** Focuses button in next/previous level. */ + void MoveFocusByLevel( bool bForward ); + /** Focuses next/previous button in tab order. */ + void MoveFocusByTabOrder( bool bForward ); + + /** Starts mouse tracking after click on a button. */ + void StartMouseTracking( size_t nLevel, size_t nEntry ); + /** Returns whether mouse tracking mode is active. */ + bool IsMouseTracking() const { return mbMTActive; } + /** Ends mouse tracking. */ + void EndMouseTracking(); + + /** Sets a clip region for the window area without header. */ + void SetEntryAreaClipRegion(); + /** Converts coordinates to real window points and draws the line. */ + void DrawLineRel( + long nLevelStart, long nEntryStart, + long nLevelEnd, long nEntryEnd ); + /** Converts coordinates to real window points and draws the rectangle. */ + void DrawRectRel( + long nLevelStart, long nEntryStart, + long nLevelEnd, long nEntryEnd ); + /** Draws the specified image unpressed. */ + void DrawImageRel(long nLevelPos, long nEntryPos, const OUString& rId); + /** Draws a pressed or unpressed border. */ + void DrawBorderRel(size_t nLevel, size_t nEntry, bool bPressed); + + /** Draws the focus rectangle into the focused button. */ + void ShowFocus(); + /** Erases the focus rectangle from the focused button. */ + void HideFocus(); + + /** Scrolls the specified range of the window in entry-relative direction. */ + void ScrollRel( long nEntryDiff, long nEntryStart, long nEntryEnd ); + +protected: + virtual void Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect ) override; + + virtual void Resize() override; + virtual void GetFocus() override; + virtual void LoseFocus() override; + + virtual void MouseMove( const MouseEvent& rMEvt ) override; + virtual void MouseButtonUp( const MouseEvent& rMEvt ) override; + virtual void MouseButtonDown( const MouseEvent& rMEvt ) override; + + virtual void KeyInput( const KeyEvent& rKEvt ) override; + +public: + virtual void DataChanged( const DataChangedEvent& rDCEvt ) override; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/opredlin.hxx b/sc/source/ui/inc/opredlin.hxx new file mode 100644 index 000000000..47abb2071 --- /dev/null +++ b/sc/source/ui/inc/opredlin.hxx @@ -0,0 +1,43 @@ +/* -*- 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_SC_SOURCE_UI_INC_OPREDLIN_HXX +#define INCLUDED_SC_SOURCE_UI_INC_OPREDLIN_HXX + +#include <sfx2/tabdlg.hxx> + +class ColorListBox; + +class ScRedlineOptionsTabPage : public SfxTabPage +{ + std::unique_ptr<ColorListBox> m_xContentColorLB; + std::unique_ptr<ColorListBox> m_xRemoveColorLB; + std::unique_ptr<ColorListBox> m_xInsertColorLB; + std::unique_ptr<ColorListBox> m_xMoveColorLB; + +public: + ScRedlineOptionsTabPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet ); + static std::unique_ptr<SfxTabPage> Create( weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rAttrSet ); + virtual ~ScRedlineOptionsTabPage() override; + + virtual bool FillItemSet( SfxItemSet* rSet ) override; + virtual void Reset( const SfxItemSet* rSet ) override; +}; +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/optsolver.hxx b/sc/source/ui/inc/optsolver.hxx new file mode 100644 index 000000000..313a7e23b --- /dev/null +++ b/sc/source/ui/inc/optsolver.hxx @@ -0,0 +1,246 @@ +/* -*- 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_SC_SOURCE_UI_INC_OPTSOLVER_HXX +#define INCLUDED_SC_SOURCE_UI_INC_OPTSOLVER_HXX + +#include <address.hxx> +#include "anyrefdg.hxx" +#include <com/sun/star/uno/Sequence.hxx> + +#include <vector> + +namespace com::sun::star { + namespace beans { struct PropertyValue; } +} + +class ScCursorRefEdit : public formula::RefEdit +{ + Link<ScCursorRefEdit&,void> maCursorUpLink; + Link<ScCursorRefEdit&,void> maCursorDownLink; + +public: + ScCursorRefEdit(std::unique_ptr<weld::Entry> xEntry); + void SetCursorLinks( const Link<ScCursorRefEdit&,void>& rUp, const Link<ScCursorRefEdit&,void>& rDown ); + +protected: + DECL_LINK(KeyInputHdl, const KeyEvent&, bool); +}; + +/// The dialog's content for a row, not yet parsed +struct ScOptConditionRow +{ + OUString aLeftStr; + sal_uInt16 nOperator; + OUString aRightStr; + + ScOptConditionRow() : nOperator(0) {} + bool IsDefault() const { return aLeftStr.isEmpty() && aRightStr.isEmpty() && nOperator == 0; } +}; + +/// All settings from the dialog, saved with the DocShell for the next call +class ScOptSolverSave +{ + OUString maObjective; + bool mbMax; + bool mbMin; + bool mbValue; + OUString maTarget; + OUString maVariable; + std::vector<ScOptConditionRow> maConditions; + OUString maEngine; + css::uno::Sequence<css::beans::PropertyValue> maProperties; + +public: + ScOptSolverSave( const OUString& rObjective, bool bMax, bool bMin, bool bValue, + const OUString& rTarget, const OUString& rVariable, + const std::vector<ScOptConditionRow>& rConditions, + const OUString& rEngine, + const css::uno::Sequence<css::beans::PropertyValue>& rProperties ); + + const OUString& GetObjective() const { return maObjective; } + bool GetMax() const { return mbMax; } + bool GetMin() const { return mbMin; } + bool GetValue() const { return mbValue; } + const OUString& GetTarget() const { return maTarget; } + const OUString& GetVariable() const { return maVariable; } + const std::vector<ScOptConditionRow>& GetConditions() const { return maConditions; } + const OUString& GetEngine() const { return maEngine; } + const css::uno::Sequence<css::beans::PropertyValue>& GetProperties() const + { return maProperties; } +}; + +class ScSolverOptionsDialog; + +class ScOptSolverDlg : public ScAnyRefDlgController +{ +public: + ScOptSolverDlg( SfxBindings* pB, SfxChildWindow* pCW, weld::Window* pParent, + ScDocShell* pDocSh, const ScAddress& aCursorPos ); + virtual ~ScOptSolverDlg() override; + + virtual void SetReference( const ScRange& rRef, ScDocument& rDoc ) override; + virtual bool IsRefInputMode() const override; + virtual void SetActive() override; + virtual void Close() override; + +private: + OUString maInputError; + OUString maConditionError; + + ScDocShell* mpDocShell; + ScDocument& mrDoc; + const SCTAB mnCurTab; + bool mbDlgLostFocus; + + std::vector<ScOptConditionRow> maConditions; + long nScrollPos; + + css::uno::Sequence<OUString> maImplNames; + css::uno::Sequence<OUString> maDescriptions; + OUString maEngine; + css::uno::Sequence<css::beans::PropertyValue> maProperties; + + static const sal_uInt16 EDIT_ROW_COUNT = 4; + ScCursorRefEdit* mpLeftEdit[EDIT_ROW_COUNT]; + formula::RefButton* mpLeftButton[EDIT_ROW_COUNT]; + ScCursorRefEdit* mpRightEdit[EDIT_ROW_COUNT]; + formula::RefButton* mpRightButton[EDIT_ROW_COUNT]; + weld::ComboBox* mpOperator[EDIT_ROW_COUNT]; + weld::Button* mpDelButton[EDIT_ROW_COUNT]; + + formula::RefEdit* mpEdActive; + + std::unique_ptr<weld::Label> m_xFtObjectiveCell; + std::unique_ptr<formula::RefEdit> m_xEdObjectiveCell; + std::unique_ptr<formula::RefButton> m_xRBObjectiveCell; + + std::unique_ptr<weld::RadioButton> m_xRbMax; + std::unique_ptr<weld::RadioButton> m_xRbMin; + std::unique_ptr<weld::RadioButton> m_xRbValue; + std::unique_ptr<formula::RefEdit> m_xEdTargetValue; + std::unique_ptr<formula::RefButton> m_xRBTargetValue; + + std::unique_ptr<weld::Label> m_xFtVariableCells; + std::unique_ptr<formula::RefEdit> m_xEdVariableCells; + std::unique_ptr<formula::RefButton> m_xRBVariableCells; + + std::unique_ptr<weld::Label> m_xFtCellRef; // labels are together with controls for the first row + std::unique_ptr<ScCursorRefEdit> m_xEdLeft1; + std::unique_ptr<formula::RefButton> m_xRBLeft1; + std::unique_ptr<weld::Label> m_xFtOperator; + std::unique_ptr<weld::ComboBox> m_xLbOp1; + std::unique_ptr<weld::Label> m_xFtConstraint; + std::unique_ptr<ScCursorRefEdit> m_xEdRight1; + std::unique_ptr<formula::RefButton> m_xRBRight1; + std::unique_ptr<weld::Button> m_xBtnDel1; + + std::unique_ptr<ScCursorRefEdit> m_xEdLeft2; + std::unique_ptr<formula::RefButton> m_xRBLeft2; + std::unique_ptr<weld::ComboBox> m_xLbOp2; + std::unique_ptr<ScCursorRefEdit> m_xEdRight2; + std::unique_ptr<formula::RefButton> m_xRBRight2; + std::unique_ptr<weld::Button> m_xBtnDel2; + + std::unique_ptr<ScCursorRefEdit> m_xEdLeft3; + std::unique_ptr<formula::RefButton> m_xRBLeft3; + std::unique_ptr<weld::ComboBox> m_xLbOp3; + std::unique_ptr<ScCursorRefEdit> m_xEdRight3; + std::unique_ptr<formula::RefButton> m_xRBRight3; + std::unique_ptr<weld::Button> m_xBtnDel3; + + std::unique_ptr<ScCursorRefEdit> m_xEdLeft4; + std::unique_ptr<formula::RefButton> m_xRBLeft4; + std::unique_ptr<weld::ComboBox> m_xLbOp4; + std::unique_ptr<ScCursorRefEdit> m_xEdRight4; + std::unique_ptr<formula::RefButton> m_xRBRight4; + std::unique_ptr<weld::Button> m_xBtnDel4; + + std::unique_ptr<weld::ScrolledWindow> m_xScrollBar; + + std::unique_ptr<weld::Button> m_xBtnOpt; + std::unique_ptr<weld::Button> m_xBtnCancel; + std::unique_ptr<weld::Button> m_xBtnSolve; + + std::unique_ptr<weld::Label> m_xResultFT; + std::unique_ptr<weld::Widget> m_xContents; + + std::shared_ptr<ScSolverOptionsDialog> m_xOptDlg; + + void Init(const ScAddress& rCursorPos); + bool CallSolver(); + void ReadConditions(); + void ShowConditions(); + void EnableButtons(); + bool ParseRef( ScRange& rRange, const OUString& rInput, bool bAllowRange ); + bool FindTimeout( sal_Int32& rTimeout ); + void ShowError( bool bCondition, formula::RefEdit* pFocus ); + + DECL_LINK( BtnHdl, weld::Button&, void ); + DECL_LINK( DelBtnHdl, weld::Button&, void ); + DECL_LINK( GetEditFocusHdl, formula::RefEdit&, void ); + DECL_LINK( GetButtonFocusHdl, formula::RefButton&, void ); + DECL_LINK( GetFocusHdl, weld::Widget&, void ); + DECL_LINK( LoseEditFocusHdl, formula::RefEdit&, void ); + DECL_LINK( LoseButtonFocusHdl, formula::RefButton&, void ); + DECL_LINK( ScrollHdl, weld::ScrolledWindow&, void); + DECL_LINK( CursorUpHdl, ScCursorRefEdit&, void ); + DECL_LINK( CursorDownHdl, ScCursorRefEdit&, void ); + DECL_LINK( CondModifyHdl, formula::RefEdit&, void ); + DECL_LINK( TargetModifyHdl, formula::RefEdit&, void ); + DECL_LINK( SelectHdl, weld::ComboBox&, void ); +}; + +class ScSolverProgressDialog : public weld::GenericDialogController +{ + std::unique_ptr<weld::Label> m_xFtTime; + +public: + ScSolverProgressDialog(weld::Window* pParent); + virtual ~ScSolverProgressDialog() override; + + void HideTimeLimit(); + void SetTimeLimit( sal_Int32 nSeconds ); +}; + +class ScSolverNoSolutionDialog : public weld::GenericDialogController +{ + std::unique_ptr<weld::Label> m_xFtErrorText; + +public: + ScSolverNoSolutionDialog(weld::Window* pParent, const OUString& rErrorText); + virtual ~ScSolverNoSolutionDialog() override; +}; + +class ScSolverSuccessDialog : public weld::GenericDialogController +{ + std::unique_ptr<weld::Label> m_xFtResult; + std::unique_ptr<weld::Button> m_xBtnOk; + std::unique_ptr<weld::Button> m_xBtnCancel; + + DECL_LINK(ClickHdl, weld::Button&, void); + +public: + ScSolverSuccessDialog(weld::Window* pParent, const OUString& rSolution); + virtual ~ScSolverSuccessDialog() override; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/output.hxx b/sc/source/ui/inc/output.hxx new file mode 100644 index 000000000..7f84f00d4 --- /dev/null +++ b/sc/source/ui/inc/output.hxx @@ -0,0 +1,387 @@ +/* -*- 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_SC_SOURCE_UI_INC_OUTPUT_HXX +#define INCLUDED_SC_SOURCE_UI_INC_OUTPUT_HXX + +#include <address.hxx> +#include <cellvalue.hxx> +#include <tools/color.hxx> +#include <tools/fract.hxx> +#include <tools/gen.hxx> +#include <editeng/svxenum.hxx> +#include <vcl/outdev.hxx> +#include <o3tl/deleter.hxx> + +namespace sc { + struct SpellCheckContext; +} + +namespace editeng { + struct MisspellRanges; +} +namespace drawinglayer::processor2d { class BaseProcessor2D; } + +namespace vcl { class Font; } +class EditEngine; +class ScDocument; +class ScPatternAttr; +struct RowInfo; +struct ScTableInfo; +class ScTabViewShell; +class ScPageBreakData; +class FmFormView; +class ScFieldEditEngine; +class SdrPaintWindow; + +#define SC_SCENARIO_HSPACE 60 +#define SC_SCENARIO_VSPACE 50 + +enum ScOutputType { OUTTYPE_WINDOW, OUTTYPE_PRINTER }; + +class ClearableClipRegion; +typedef std::unique_ptr<ClearableClipRegion, o3tl::default_delete<ClearableClipRegion>> ClearableClipRegionPtr; + +/// Describes reference mark to be drawn, position & size in TWIPs +struct ReferenceMark { + long nX; + long nY; + long nWidth; + long nHeight; + long nTab; + Color aColor; + + ReferenceMark() + : nX( 0 ) + , nY( 0 ) + , nWidth( 0 ) + , nHeight( 0 ) + , nTab( 0 ) + , aColor( COL_AUTO ) {} + + ReferenceMark( long aX, + long aY, + long aWidth, + long aHeight, + long aTab, + const Color& rColor ) + : nX( aX ) + , nY( aY ) + , nWidth( aWidth ) + , nHeight( aHeight ) + , nTab( aTab ) + , aColor( rColor ) {} + + bool Is() const { return ( nWidth > 0 && nHeight > 0 ); } +}; + +class ScOutputData +{ +friend class ScDrawStringsVars; +friend class ScGridWindow; +private: + struct OutputAreaParam + { + tools::Rectangle maAlignRect; + tools::Rectangle maClipRect; + long mnColWidth; + long mnLeftClipLength; /// length of the string getting cut off on the left. + long mnRightClipLength; /// length of the string getting cut off on the right. + bool mbLeftClip; + bool mbRightClip; + }; + + class DrawEditParam + { + public: + SvxCellHorJustify meHorJustAttr; ///< alignment attribute + SvxCellHorJustify meHorJustContext; ///< context depending on attribute, content and direction + SvxCellHorJustify meHorJustResult; ///< result for EditEngine + SvxCellVerJustify meVerJust; + SvxCellJustifyMethod meHorJustMethod; + SvxCellJustifyMethod meVerJustMethod; + SvxCellOrientation meOrient; + SCSIZE mnArrY; + SCCOL mnX; + SCCOL mnCellX; + SCROW mnCellY; + long mnPosX; + long mnPosY; + long mnInitPosX; + bool mbBreak:1; + bool mbCellIsValue:1; + bool mbAsianVertical:1; + bool mbPixelToLogic:1; + bool mbHyphenatorSet:1; + ScFieldEditEngine* mpEngine; + ScRefCellValue maCell; + const ScPatternAttr* mpPattern; + const SfxItemSet* mpCondSet; + const SfxItemSet* mpPreviewFontSet; + const ScPatternAttr* mpOldPattern; + const SfxItemSet* mpOldCondSet; + const SfxItemSet* mpOldPreviewFontSet; + const RowInfo* mpThisRowInfo; + const std::vector<editeng::MisspellRanges>* mpMisspellRanges; + + explicit DrawEditParam(const ScPatternAttr* pPattern, const SfxItemSet* pCondSet, bool bCellIsValue); + + bool readCellContent(const ScDocument* pDoc, bool bShowNullValues, bool bShowFormulas, bool bSyntaxMode, bool bUseStyleColor, bool bForceAutoColor, bool& rWrapFields); + void setPatternToEngine(bool bUseStyleColor); + void calcMargins(long& rTop, long& rLeft, long& rBottom, long& rRight, double nPPTX, double nPPTY) const; + void calcPaperSize(Size& rPaperSize, const tools::Rectangle& rAlignRect, double nPPTX, double nPPTY) const; + void getEngineSize(ScFieldEditEngine* pEngine, long& rWidth, long& rHeight) const; + bool hasLineBreak() const; + bool isHyperlinkCell() const; + + /** + * When the text is vertically oriented, the text is either rotated 90 + * degrees to the right or 90 degrees to the left. Note that this is + * different from being vertically stacked. + */ + bool isVerticallyOriented() const; + + /** + * Calculate offset position for vertically oriented (either + * top-bottom or bottom-top orientation) text. + * + * @param rLogicStart initial position in pixels. When the call is + * finished, this parameter will store the new + * position. + */ + void calcStartPosForVertical(Point& rLogicStart, long nCellWidth, long nEngineWidth, long nTopM, const OutputDevice* pRefDevice); + + void setAlignmentToEngine(); + bool adjustHorAlignment(ScFieldEditEngine* pEngine); + void adjustForHyperlinkInPDF(Point aURLStart, const OutputDevice* pDev); + }; + + VclPtr<OutputDevice> mpDev; // Device + VclPtr<OutputDevice> mpRefDevice; // printer if used for preview + VclPtr<OutputDevice> pFmtDevice; // reference for text formatting + ScTableInfo& mrTabInfo; + RowInfo* pRowInfo; // Info block + SCSIZE nArrCount; // occupied lines in info block + ScDocument* mpDoc; // Document + SCTAB nTab; // sheet + long nScrX; // Output Startpos. (Pixel) + long nScrY; + long nScrW; // Output size (Pixel) + long nScrH; + long nMirrorW; // Visible output width for mirroring (default: nScrW) + SCCOL nX1; // Start-/End coordinates + SCROW nY1; // ( incl. hidden ) + SCCOL nX2; + SCROW nY2; + SCCOL nVisX1; // Start-/End coordinates + SCROW nVisY1; // ( visible range ) + SCCOL nVisX2; + SCROW nVisY2; + ScOutputType eType; // Screen/Printer ... + double mnPPTX; // Pixel per Twips + double mnPPTY; + Fraction aZoomX; + Fraction aZoomY; + + ScTabViewShell* pViewShell; // for connect from visible plug-ins + + FmFormView* pDrawView; // SdrView to paint to + + bool bEditMode; // InPlace edited cell - do not output + SCCOL nEditCol; + SCROW nEditRow; + + bool bMetaFile; // Output to metafile (not pixels!) + + bool bPagebreakMode; // Page break preview + bool bSolidBackground; // white instead of transparent + + bool mbUseStyleColor; + bool mbForceAutoColor; + + bool mbSyntaxMode; // Syntax highlighting + std::unique_ptr<Color> pValueColor; + std::unique_ptr<Color> pTextColor; + std::unique_ptr<Color> pFormulaColor; + + Color aGridColor; + + bool mbShowNullValues; + bool mbShowFormulas; + bool bShowSpellErrors; // Show spelling errors in EditObjects + bool bMarkClipped; + + bool bSnapPixel; + + bool bAnyClipped; // internal + bool bTabProtected; + bool bLayoutRTL; + + // #i74769# use SdrPaintWindow direct, remember it during BeginDrawLayers/EndDrawLayers + SdrPaintWindow* mpTargetPaintWindow; + const sc::SpellCheckContext* mpSpellCheckCxt; + + // private methods + + bool GetMergeOrigin( SCCOL nX, SCROW nY, SCSIZE nArrY, + SCCOL& rOverX, SCROW& rOverY, bool bVisRowChanged ); + bool IsEmptyCellText( const RowInfo* pThisRowInfo, SCCOL nX, SCROW nY ); + void GetVisibleCell( SCCOL nCol, SCROW nRow, SCTAB nTab, ScRefCellValue& rCell ); + + bool IsAvailable( SCCOL nX, SCROW nY ); + + void GetOutputArea( SCCOL nX, SCSIZE nArrY, long nPosX, long nPosY, + SCCOL nCellX, SCROW nCellY, long nNeeded, + const ScPatternAttr& rPattern, + sal_uInt16 nHorJustify, bool bCellIsValue, + bool bBreak, bool bOverwrite, + OutputAreaParam& rParam ); + + void ShrinkEditEngine( EditEngine& rEngine, const tools::Rectangle& rAlignRect, + long nLeftM, long nTopM, long nRightM, long nBottomM, + bool bWidth, SvxCellOrientation nOrient, long nAttrRotate, bool bPixelToLogic, + long& rEngineWidth, long& rEngineHeight, long& rNeededPixel, + bool& rLeftClip, bool& rRightClip ); + + void SetSyntaxColor( vcl::Font* pFont, const ScRefCellValue& rCell ); + void SetEditSyntaxColor( EditEngine& rEngine, const ScRefCellValue& rCell ); + + double GetStretch() const; + + void DrawRotatedFrame(vcl::RenderContext& rRenderContext); // pixel + + std::unique_ptr<drawinglayer::processor2d::BaseProcessor2D> CreateProcessor2D( ); + + void DrawEditStandard(DrawEditParam& rParam); + void DrawEditBottomTop(DrawEditParam& rParam); + void DrawEditTopBottom(DrawEditParam& rParam); + void DrawEditStacked(DrawEditParam& rParam); + void DrawEditAsianVertical(DrawEditParam& rParam); + + std::unique_ptr<ScFieldEditEngine> CreateOutputEditEngine(); + + void ShowClipMarks( DrawEditParam& rParam, long nEngineHeight, const Size& aCellSize, + bool bMerged, OutputAreaParam& aAreaParam ); + + ClearableClipRegionPtr Clip(DrawEditParam& rParam, const Size& aCellSize, OutputAreaParam& aAreaParam, + long nEngineHeight, bool bWrapFields); + + bool AdjustAreaParamClipRect(OutputAreaParam& rAreaParam); + long SetEngineTextAndGetWidth( DrawEditParam& rParam, const OUString& rSetString, + long& rNeededPixel, long nAddWidthPixels ); + + // Check for and set cell rotations at OutputData to have it available + // in the svx tooling to render the borders. Moved to private section + // and the single call to end of constructor to be sure this always happens + void SetCellRotations(); + +public: + + /** + * @param nNewScrX: X-Offset in the output device for the table + * @param nNewScrY: Y-Offset in the output device for the table + * + */ + ScOutputData( OutputDevice* pNewDev, ScOutputType eNewType, + ScTableInfo& rTabInfo, ScDocument* pNewDoc, + SCTAB nNewTab, long nNewScrX, long nNewScrY, + SCCOL nNewX1, SCROW nNewY1, SCCOL nNewX2, SCROW nNewY2, + double nPixelPerTwipsX, double nPixelPerTwipsY, + const Fraction* pZoomX = nullptr, + const Fraction* pZoomY = nullptr ); + + ~ScOutputData(); + + void SetSpellCheckContext( const sc::SpellCheckContext* pCxt ); + void SetContentDevice( OutputDevice* pContentDev ); + + void SetRefDevice( OutputDevice* pRDev ) { mpRefDevice = pFmtDevice = pRDev; } + void SetFmtDevice( OutputDevice* pRDev ) { pFmtDevice = pRDev; } + void SetViewShell( ScTabViewShell* pSh ) { pViewShell = pSh; } + + void SetDrawView( FmFormView* pNew ) { pDrawView = pNew; } + + void SetSolidBackground( bool bSet ) { bSolidBackground = bSet; } + void SetUseStyleColor( bool bSet ) { mbUseStyleColor = bSet; } + + void SetEditCell( SCCOL nCol, SCROW nRow ); + void SetSyntaxMode( bool bNewMode ); + void SetMetaFileMode( bool bNewMode ); + void SetGridColor( const Color& rColor ); + void SetMarkClipped( bool bSet ); + void SetShowNullValues ( bool bSet ); + void SetShowFormulas ( bool bSet ); + void SetShowSpellErrors( bool bSet ); + void SetMirrorWidth( long nNew ); + long GetScrW() const { return nScrW; } + long GetScrH() const { return nScrH; } + + void SetSnapPixel(); + + void DrawGrid(vcl::RenderContext& rRenderContext, bool bGrid, bool bPage); + void DrawStrings( bool bPixelToLogic = false ); + + /// Draw all strings, or provide Rectangle where the text (defined by rAddress) would be drawn. + tools::Rectangle LayoutStrings(bool bPixelToLogic, bool bPaint = true, const ScAddress &rAddress = ScAddress()); + + void DrawDocumentBackground(); + void DrawBackground(vcl::RenderContext& rRenderContext); + void DrawShadow(); + void DrawExtraShadow(bool bLeft, bool bTop, bool bRight, bool bBottom); + void DrawFrame(vcl::RenderContext& rRenderContext); + + // with logic MapMode set! + void DrawEdit(bool bPixelToLogic); + void DrawRotated(bool bPixelToLogic); // logical + + void DrawClear(); + + // #i72502# printer only command set + Point PrePrintDrawingLayer(long nLogStX, long nLogStY ); + void PostPrintDrawingLayer(const Point& rMMOffset); // #i74768# need offset for FormLayer + void PrintDrawingLayer(SdrLayerID nLayer, const Point& rMMOffset); + + // only screen: + void DrawSelectiveObjects(SdrLayerID nLayer); + + bool SetChangedClip(); // sal_False = not + vcl::Region GetChangedAreaRegion(); + + void FindChanged(); + void SetPagebreakMode( ScPageBreakData* pPageData ); + /// Draws reference mark and returns its properties + void DrawRefMark( SCCOL nRefStartX, SCROW nRefStartY, + SCCOL nRefEndX, SCROW nRefEndY, + const Color& rColor, bool bHandle ); + ReferenceMark FillReferenceMark( SCCOL nRefStartX, SCROW nRefStartY, + SCCOL nRefEndX, SCROW nRefEndY, + const Color& rColor ); + void DrawOneChange( SCCOL nRefStartX, SCROW nRefStartY, + SCCOL nRefEndX, SCROW nRefEndY, + const Color& rColor, sal_uInt16 nType ); + void DrawChangeTrack(); + void DrawClipMarks(); + + void DrawNoteMarks(vcl::RenderContext& rRenderContext); + void AddPDFNotes(); +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/overlayobject.hxx b/sc/source/ui/inc/overlayobject.hxx new file mode 100644 index 000000000..d0f33f010 --- /dev/null +++ b/sc/source/ui/inc/overlayobject.hxx @@ -0,0 +1,68 @@ +/* -*- 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_SC_SOURCE_UI_INC_OVERLAYOBJECT_HXX +#define INCLUDED_SC_SOURCE_UI_INC_OVERLAYOBJECT_HXX + +#include <svx/sdr/overlay/overlayobject.hxx> +#include <vcl/font.hxx> +#include <vcl/mapmod.hxx> + +class ScOverlayDashedBorder : public sdr::overlay::OverlayObject +{ +public: + ScOverlayDashedBorder(const ::basegfx::B2DRange& rRange, const Color& rColor); + virtual ~ScOverlayDashedBorder() override; + + virtual void Trigger(sal_uInt32 nTime) override; + + virtual void stripeDefinitionHasChanged() override; + +protected: + virtual drawinglayer::primitive2d::Primitive2DContainer createOverlayObjectPrimitive2DSequence() override; + +private: + ::basegfx::B2DRange maRange; + bool mbToggle; +}; + +class ScOverlayHint : public sdr::overlay::OverlayObject +{ +public: + ScOverlayHint(const OUString& rTit, const OUString& rMsg, const Color& rColor, const vcl::Font& rFont); + Size GetSizePixel() const; + void SetPos(const Point& rPos, const MapMode& rMode); + +public: + virtual drawinglayer::primitive2d::Primitive2DContainer createOverlayObjectPrimitive2DSequence() override; + +private: + drawinglayer::primitive2d::Primitive2DContainer createOverlaySequence(sal_Int32 nLeft, sal_Int32 nTop, const MapMode &rMapMode, basegfx::B2DRange &rRange) const; + + const OUString m_aTitle; + const OUString m_aMessage; + const vcl::Font m_aTextFont; + MapMode m_aMapMode; + sal_Int32 m_nLeft; + sal_Int32 m_nTop; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/pagedata.hxx b/sc/source/ui/inc/pagedata.hxx new file mode 100644 index 000000000..81a277c42 --- /dev/null +++ b/sc/source/ui/inc/pagedata.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_SC_SOURCE_UI_INC_PAGEDATA_HXX +#define INCLUDED_SC_SOURCE_UI_INC_PAGEDATA_HXX + +#include <address.hxx> +#include <memory> +#include <vector> + +class ScPrintRangeData +{ +private: + ScRange aPrintRange; + std::vector<SCCOL> + mvPageEndX; + std::vector<SCROW> + mvPageEndY; + long nFirstPage; + bool bTopDown; + bool bAutomatic; + +public: + ScPrintRangeData(); + ~ScPrintRangeData(); + + void SetPrintRange( const ScRange& rNew ) { aPrintRange = rNew; } + const ScRange& GetPrintRange() const { return aPrintRange; } + + void SetPagesX( size_t nCount, const SCCOL* pEnd ); + void SetPagesY( size_t nCount, const SCROW* pEnd ); + + size_t GetPagesX() const { return mvPageEndX.size(); } + const SCCOL* GetPageEndX() const { return mvPageEndX.data(); } + size_t GetPagesY() const { return mvPageEndY.size(); } + const SCROW* GetPageEndY() const { return mvPageEndY.data(); } + + void SetFirstPage( long nNew ) { nFirstPage = nNew; } + long GetFirstPage() const { return nFirstPage; } + void SetTopDown( bool bSet ) { bTopDown = bSet; } + bool IsTopDown() const { return bTopDown; } + void SetAutomatic( bool bSet ) { bAutomatic = bSet; } + bool IsAutomatic() const { return bAutomatic; } +}; + +class ScPageBreakData +{ +private: + size_t nAlloc; + size_t nUsed; + std::unique_ptr<ScPrintRangeData[]> pData; + +public: + ScPageBreakData(size_t nMax); + ~ScPageBreakData(); + + size_t GetCount() const { return nUsed; } + ScPrintRangeData& GetData(size_t i); + + bool operator==( const ScPageBreakData& rOther ) const; + + void AddPages(); +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/pfiltdlg.hxx b/sc/source/ui/inc/pfiltdlg.hxx new file mode 100644 index 000000000..f58b4d843 --- /dev/null +++ b/sc/source/ui/inc/pfiltdlg.hxx @@ -0,0 +1,96 @@ +/* -*- 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_SC_SOURCE_UI_INC_PFILTDLG_HXX +#define INCLUDED_SC_SOURCE_UI_INC_PFILTDLG_HXX + +#include <vcl/weld.hxx> +#include <address.hxx> +#include <queryparam.hxx> +#include <array> +#include <memory> + +class ScViewData; +class ScDocument; +class ScQueryItem; +class SfxItemSet; +struct ScFilterEntries; + +class ScPivotFilterDlg : public weld::GenericDialogController +{ +public: + ScPivotFilterDlg(weld::Window* pParent, const SfxItemSet& rArgSet, SCTAB nSourceTab); + virtual ~ScPivotFilterDlg() override; + + const ScQueryItem& GetOutputItem(); + +private: + const OUString aStrNone; + const OUString aStrEmpty; + const OUString aStrNotEmpty; + const OUString aStrColumn; + + const sal_uInt16 nWhichQuery; + const ScQueryParam theQueryData; + std::unique_ptr<ScQueryItem> pOutItem; + ScViewData* pViewData; + ScDocument* pDoc; + SCTAB nSrcTab; + + std::unique_ptr<weld::ComboBox> m_xLbField1; + std::unique_ptr<weld::ComboBox> m_xLbCond1; + std::unique_ptr<weld::ComboBox> m_xEdVal1; + + std::unique_ptr<weld::ComboBox> m_xLbConnect1; + std::unique_ptr<weld::ComboBox> m_xLbField2; + std::unique_ptr<weld::ComboBox> m_xLbCond2; + std::unique_ptr<weld::ComboBox> m_xEdVal2; + + std::unique_ptr<weld::ComboBox> m_xLbConnect2; + std::unique_ptr<weld::ComboBox> m_xLbField3; + std::unique_ptr<weld::ComboBox> m_xLbCond3; + std::unique_ptr<weld::ComboBox> m_xEdVal3; + + std::unique_ptr<weld::CheckButton> m_xBtnCase; + std::unique_ptr<weld::CheckButton> m_xBtnRegExp; + std::unique_ptr<weld::CheckButton> m_xBtnUnique; + std::unique_ptr<weld::Label> m_xFtDbArea; + + weld::ComboBox* aValueEdArr[3]; + weld::ComboBox* aFieldLbArr[3]; + weld::ComboBox* aCondLbArr[3]; + + std::array<std::unique_ptr<ScFilterEntries>, MAXCOLCOUNT> m_pEntryLists; + +private: + void Init ( const SfxItemSet& rArgSet ); + void FillFieldLists (); + void UpdateValueList ( sal_uInt16 nList ); + void ClearValueList ( sal_uInt16 nList ); + sal_uInt16 GetFieldSelPos ( SCCOL nField ); + + // Handler: + DECL_LINK( LbSelectHdl, weld::ComboBox&, void ); + DECL_LINK( ValModifyHdl, weld::ComboBox&, void ); + DECL_LINK( CheckBoxHdl, weld::Button&, void ); +}; + +#endif // INCLUDED_SC_SOURCE_UI_INC_PFILTDLG_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/pfuncache.hxx b/sc/source/ui/inc/pfuncache.hxx new file mode 100644 index 000000000..762e3464a --- /dev/null +++ b/sc/source/ui/inc/pfuncache.hxx @@ -0,0 +1,114 @@ +/* -*- 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_SC_SOURCE_UI_INC_PFUNCACHE_HXX +#define INCLUDED_SC_SOURCE_UI_INC_PFUNCACHE_HXX + +#include <vector> +#include <tools/gen.hxx> +#include <rangelst.hxx> +#include <printopt.hxx> + +class ScDocShell; +class ScMarkData; +class OutputDevice; + +/** Possible types of selection for print functions */ + +enum ScPrintSelectionMode +{ + SC_PRINTSEL_INVALID, + SC_PRINTSEL_DOCUMENT, + SC_PRINTSEL_CURSOR, + SC_PRINTSEL_RANGE, + SC_PRINTSEL_RANGE_EXCLUSIVELY_OLE_AND_DRAW_OBJECTS +}; + +/** Stores the selection in the ScPrintFuncCache so it is only used + for the same selection again. */ + +class ScPrintSelectionStatus +{ + ScPrintSelectionMode eMode; + ScRangeList aRanges; + ScPrintOptions aOptions; + +public: + ScPrintSelectionStatus() : eMode(SC_PRINTSEL_INVALID) {} + + void SetMode(ScPrintSelectionMode eNew) { eMode = eNew; } + void SetRanges(const ScRangeList& rNew) { aRanges = rNew; } + void SetOptions(const ScPrintOptions& rNew) { aOptions = rNew; } + + bool operator==(const ScPrintSelectionStatus& rOther) const + { return eMode == rOther.eMode && aRanges == rOther.aRanges && aOptions == rOther.aOptions; } + + ScPrintSelectionMode GetMode() const { return eMode; } + const ScPrintOptions& GetOptions() const { return aOptions; } +}; + +/** The range that is printed on a page (excluding repeated columns/rows), + and its position on the page, used to find hyperlink targets. */ + +struct ScPrintPageLocation +{ + long nPage; + ScRange aCellRange; + tools::Rectangle aRectangle; // pixels + + ScPrintPageLocation() : + nPage(-1) {} // default: invalid + + ScPrintPageLocation( long nP, const ScRange& rRange, const tools::Rectangle& rRect ) : + nPage(nP), aCellRange(rRange), aRectangle(rRect) {} +}; + +/** Stores the data for printing that is needed from several sheets, + so it doesn't have to be calculated for rendering each page. */ + +class ScPrintFuncCache +{ + ScPrintSelectionStatus aSelection; + ScDocShell* pDocSh; + long nTotalPages; + std::vector<long> nPages; + std::vector<long> nFirstAttr; + std::vector<ScPrintPageLocation> aLocations; + bool bLocInitialized; + +public: + ScPrintFuncCache( ScDocShell* pD, const ScMarkData& rMark, + const ScPrintSelectionStatus& rStatus ); + ~ScPrintFuncCache(); + + bool IsSameSelection( const ScPrintSelectionStatus& rStatus ) const; + + void InitLocations( const ScMarkData& rMark, OutputDevice* pDev ); + bool FindLocation( const ScAddress& rCell, ScPrintPageLocation& rLocation ) const; + + long GetPageCount() const { return nTotalPages; } + long GetFirstAttr( SCTAB nTab ) const { return nFirstAttr[nTab]; } + SCTAB GetTabForPage( long nPage ) const; + long GetTabStart( SCTAB nTab ) const; + long GetDisplayStart( SCTAB nTab ) const; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/pgbrksh.hxx b/sc/source/ui/inc/pgbrksh.hxx new file mode 100644 index 000000000..90dd34684 --- /dev/null +++ b/sc/source/ui/inc/pgbrksh.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/. + * + * 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_SC_SOURCE_UI_INC_PGBRKSH_HXX +#define INCLUDED_SC_SOURCE_UI_INC_PGBRKSH_HXX + +#include <sfx2/shell.hxx> + +#include <shellids.hxx> + +class SfxModule; +class ScTabViewShell; + +class ScPageBreakShell : public SfxShell +{ +public: + SFX_DECL_INTERFACE(SCID_PAGEBREAK_SHELL) + +private: + /// SfxInterface initializer. + static void InitInterface_Impl(); + +public: + ScPageBreakShell(ScTabViewShell* pView); + virtual ~ScPageBreakShell() override; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/pivotsh.hxx b/sc/source/ui/inc/pivotsh.hxx new file mode 100644 index 000000000..9a6e9698e --- /dev/null +++ b/sc/source/ui/inc/pivotsh.hxx @@ -0,0 +1,55 @@ +/* -*- 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_SC_SOURCE_UI_INC_PIVOTSH_HXX +#define INCLUDED_SC_SOURCE_UI_INC_PIVOTSH_HXX + +#include <sfx2/shell.hxx> + +#include <shellids.hxx> + +class ScTabViewShell; +class ScDPObject; +class SfxModule; + +class ScPivotShell : public SfxShell +{ +public: + SFX_DECL_INTERFACE(SCID_PIVOT_SHELL) + +private: + /// SfxInterface initializer. + static void InitInterface_Impl(); + +public: + ScPivotShell(ScTabViewShell* pView); + virtual ~ScPivotShell() override; + + void Execute(const SfxRequest& rReq); + void GetState(SfxItemSet& rSet); + +private: + ScTabViewShell* pViewShell; + + ScDPObject* GetCurrDPObject(); +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/pntlock.hxx b/sc/source/ui/inc/pntlock.hxx new file mode 100644 index 000000000..5ae3734c1 --- /dev/null +++ b/sc/source/ui/inc/pntlock.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_SC_SOURCE_UI_INC_PNTLOCK_HXX +#define INCLUDED_SC_SOURCE_UI_INC_PNTLOCK_HXX + +#include <rangelst.hxx> + +class ScPaintLockData +{ +private: + ScRangeListRef xRangeList; + sal_uInt16 nLevel; + sal_uInt16 nDocLevel; + PaintPartFlags nParts; + bool bModified; + +public: + ScPaintLockData(); + ~ScPaintLockData(); + + void AddRange( const ScRange& rRange, PaintPartFlags nP ); + + void SetModified() { bModified = true; } + void IncLevel(bool bDoc) + { if (bDoc) ++nDocLevel; else ++nLevel; } + void DecLevel(bool bDoc) + { if (bDoc) --nDocLevel; else --nLevel; } + + const ScRangeListRef& GetRangeList() const { return xRangeList; } + PaintPartFlags GetParts() const { return nParts; } + sal_uInt16 GetLevel(bool bDoc) const + { return bDoc ? nDocLevel : nLevel; } + bool GetModified() const { return bModified; } + + /** for recovery after reset */ + void SetDocLevel(sal_uInt16 nNew) + { nDocLevel = nNew; } +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/preview.hxx b/sc/source/ui/inc/preview.hxx new file mode 100644 index 000000000..69133b9e9 --- /dev/null +++ b/sc/source/ui/inc/preview.hxx @@ -0,0 +1,166 @@ +/* -*- 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_SC_SOURCE_UI_INC_PREVIEW_HXX +#define INCLUDED_SC_SOURCE_UI_INC_PREVIEW_HXX + +#include <vcl/window.hxx> +#include "printfun.hxx" +#include <markdata.hxx> + +#include <vector> + +class ScDocShell; +class ScPreviewShell; +class FmFormView; + +class SAL_DLLPUBLIC_RTTI ScPreview : public vcl::Window +{ +private: + ScMarkData::MarkedTabsType maSelectedTabs; + // set: + long nPageNo; // Pages in document + sal_uInt16 nZoom; // set Zoom + Point aOffset; // positive + + // calculated: + SCTAB nTabCount; + SCTAB nTabsTested; // for how many sheets is nPages valid? + std::vector<long> nPages; + std::vector<long> nFirstAttr; + SCTAB nTab; // Sheet + long nTabPage; // Page of sheet + long nTabStart; // First (real) page of the sheet + long nDisplayStart; // same as above, relative to the start of counting + DateTime aDateTime; + long nTotalPages; + ScPrintState aState; + std::unique_ptr<ScPreviewLocationData> pLocationData; // stores table layout for accessibility API + std::unique_ptr<FmFormView> pDrawView; + + // internal: + ScDocShell* pDocShell; + ScPreviewShell* pViewShell; + + bool bInGetState:1; + bool bValid:1; // the following values true + bool bStateValid:1; + bool bLocationValid:1; + bool bInPaint:1; + bool bInSetZoom:1; + bool bLeftRulerMove:1; + bool bRightRulerMove:1; + bool bTopRulerMove:1; + bool bBottomRulerMove:1; + bool bHeaderRulerMove:1; + bool bFooterRulerMove:1; + bool bLeftRulerChange:1; + bool bRightRulerChange:1; + bool bTopRulerChange:1; + bool bBottomRulerChange:1; + bool bHeaderRulerChange:1; + bool bFooterRulerChange:1; + bool bPageMargin:1; + bool bColRulerMove:1; + bool mbHasEmptyRangeTable:1; /// we have at least one sheet with empty print range (print range set to '- none -'). + + ScRange aPageArea; + std::vector<long> mvRight; + long nLeftPosition; + long mnScale; + SCCOL nColNumberButttonDown; + Point aButtonDownChangePoint; + Point aButtonDownPt; + Point aButtonUpPt; + long nHeaderHeight; + long nFooterHeight; + + void TestLastPage(); + void CalcPages(); + void RecalcPages(); + void UpdateDrawView(); + void DoPrint( ScPreviewLocationData* pFillLocation ); + + void InvalidateLocationData( SfxHintId nId ); + + using Window::SetZoom; + +protected: + virtual void Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect ) override; + virtual void Command( const CommandEvent& rCEvt ) override; + virtual void KeyInput( const KeyEvent& rKEvt ) override; + virtual void MouseMove( const MouseEvent& rMEvt ) override; + virtual void MouseButtonDown( const MouseEvent& rMEvt ) override; + virtual void MouseButtonUp( const MouseEvent& rMEvt ) override; + + virtual void GetFocus() override; + virtual void LoseFocus() override; + + virtual css::uno::Reference< css::accessibility::XAccessible > CreateAccessible() override; + +public: + ScPreview( vcl::Window* pParent, ScDocShell* pDocSh, ScPreviewShell* pViewSh ); + virtual ~ScPreview() override; + virtual void dispose() override; + + virtual void DataChanged( const DataChangedEvent& rDCEvt ) override; + + SC_DLLPUBLIC void DataChanged(bool bNewTime); // Instead of calling Invalidate + void DoInvalidate(); + + void SetXOffset( long nX ); + void SetYOffset( long nY ); + void SetZoom(sal_uInt16 nNewZoom); + SC_DLLPUBLIC void SetPageNo( long nPage ); + + bool GetPageMargins() const { return bPageMargin; } + void SetPageMargins( bool bVal ) { bPageMargin = bVal; } + void DrawInvert( long nDragPos, PointerStyle nFlags ); + void DragMove( long nDragMovePos, PointerStyle nFlags ); + + const ScPreviewLocationData& GetLocationData(); + + OUString GetPosString(); + + long GetPageNo() const { return nPageNo; } + sal_uInt16 GetZoom() const { return nZoom; } + const Point& GetOffset() const { return aOffset; } + + SCTAB GetTab() { if (!bValid) { CalcPages(); RecalcPages(); } return nTab; } + long GetTotalPages() { if (!bValid) { CalcPages(); RecalcPages(); } return nTotalPages; } + + bool AllTested() const { return bValid && nTabsTested >= nTabCount; } + + sal_uInt16 GetOptimalZoom(bool bWidthOnly); + SC_DLLPUBLIC long GetFirstPage(SCTAB nTab); + + void CalcAll() { CalcPages(); } + void SetInGetState(bool bSet) { bInGetState = bSet; } + + DECL_STATIC_LINK( ScPreview, InvalidateHdl, void*, void ); + static void StaticInvalidate(); + + FmFormView* GetDrawView() { return pDrawView.get(); } + + SC_DLLPUBLIC void SetSelectedTabs(const ScMarkData& rMark); + const ScMarkData::MarkedTabsType& GetSelectedTabs() const { return maSelectedTabs; } +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/prevloc.hxx b/sc/source/ui/inc/prevloc.hxx new file mode 100644 index 000000000..34aa81b65 --- /dev/null +++ b/sc/source/ui/inc/prevloc.hxx @@ -0,0 +1,155 @@ +/* -*- 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_SC_SOURCE_UI_INC_PREVLOC_HXX +#define INCLUDED_SC_SOURCE_UI_INC_PREVLOC_HXX + +#include <sal/types.h> + +#include <address.hxx> + +#include <vcl/mapmod.hxx> +#include <vcl/vclptr.hxx> +#include <tools/gen.hxx> + +#include <memory> +#include <list> + +#define SC_PREVIEW_MAXRANGES 4 +#define SC_PREVIEW_RANGE_EDGE 0 +#define SC_PREVIEW_RANGE_REPCOL 1 +#define SC_PREVIEW_RANGE_REPROW 2 +#define SC_PREVIEW_RANGE_TAB 3 + +class OutputDevice; +class ScDocument; +struct ScPreviewLocationEntry; + +struct ScPreviewColRowInfo +{ + bool bIsHeader; + SCCOLROW nDocIndex; + long nPixelStart; + long nPixelEnd; + + void Set( bool bHeader, SCCOLROW nIndex, long nStart, long nEnd ) + { + bIsHeader = bHeader; + nDocIndex = nIndex; + nPixelStart = nStart; + nPixelEnd = nEnd; + } +}; + +class ScPreviewTableInfo +{ + SCTAB nTab; + SCCOL nCols; + SCROW nRows; + std::unique_ptr<ScPreviewColRowInfo[]> + pColInfo; + std::unique_ptr<ScPreviewColRowInfo[]> + pRowInfo; + +public: + ScPreviewTableInfo(); + ~ScPreviewTableInfo(); + + SCTAB GetTab() const { return nTab; } + SCCOL GetCols() const { return nCols; } + SCROW GetRows() const { return nRows; } + const ScPreviewColRowInfo* GetColInfo() const { return pColInfo.get(); } + const ScPreviewColRowInfo* GetRowInfo() const { return pRowInfo.get(); } + + void SetTab( SCTAB nNewTab ); + void SetColInfo( SCCOL nCount, ScPreviewColRowInfo* pNewInfo ); + void SetRowInfo( SCROW nCount, ScPreviewColRowInfo* pNewInfo ); + void LimitToArea( const tools::Rectangle& rPixelArea ); +}; + +class ScPreviewLocationData +{ +public: + typedef std::list<std::unique_ptr<ScPreviewLocationEntry>> Entries_t; +private: + VclPtr<OutputDevice> pWindow; + ScDocument* pDoc; + MapMode aCellMapMode; + MapMode aDrawMapMode[SC_PREVIEW_MAXRANGES]; + tools::Rectangle aDrawRectangle[SC_PREVIEW_MAXRANGES]; + sal_uInt8 aDrawRangeId[SC_PREVIEW_MAXRANGES]; + sal_uInt16 nDrawRanges; + SCTAB nPrintTab; + Entries_t m_Entries; + + tools::Rectangle GetOffsetPixel( const ScAddress& rCellPos, const ScRange& rRange ) const; + +public: + ScPreviewLocationData( ScDocument* pDocument, OutputDevice* pWin ); + ~ScPreviewLocationData(); + + void SetCellMapMode( const MapMode& rMapMode ); + void SetPrintTab( SCTAB nNew ); + void Clear(); + void AddCellRange( const tools::Rectangle& rRect, const ScRange& rRange, bool bRepCol, bool bRepRow, + const MapMode& rDrawMap ); + void AddColHeaders( const tools::Rectangle& rRect, SCCOL nStartCol, SCCOL nEndCol, bool bRepCol ); + void AddRowHeaders( const tools::Rectangle& rRect, SCROW nStartRow, SCROW nEndRow, bool bRepRow ); + void AddHeaderFooter( const tools::Rectangle& rRect, bool bHeader, bool bLeft ); + void AddNoteMark( const tools::Rectangle& rRect, const ScAddress& rPos ); + void AddNoteText( const tools::Rectangle& rRect, const ScAddress& rPos ); + + SCTAB GetPrintTab() const { return nPrintTab; } + + // Get info on visible columns/rows in the visible area + void GetTableInfo( const tools::Rectangle& rVisiblePixel, ScPreviewTableInfo& rInfo ) const; + + sal_uInt16 GetDrawRanges() const { return nDrawRanges; } + void GetDrawRange( sal_uInt16 nPos, tools::Rectangle& rPixelRect, MapMode& rMapMode, sal_uInt8& rRangeId ) const; + + bool GetHeaderPosition( tools::Rectangle& rHeaderRect ) const; + bool GetFooterPosition( tools::Rectangle& rFooterRect ) const; + bool IsHeaderLeft() const; + bool IsFooterLeft() const; + + long GetNoteCountInRange( const tools::Rectangle& rVisiblePixel, bool bNoteMarks ) const; + bool GetNoteInRange( const tools::Rectangle& rVisiblePixel, long nIndex, bool bNoteMarks, + ScAddress& rCellPos, tools::Rectangle& rNoteRect ) const; + tools::Rectangle GetNoteInRangeOutputRect(const tools::Rectangle& rVisiblePixel, bool bNoteMarks, + const ScAddress& aCellPos) const; + + // Check if any cells (including column/row headers) are in the visible area + bool HasCellsInRange( const tools::Rectangle& rVisiblePixel ) const; + + void GetCellPosition( const ScAddress& rCellPos, tools::Rectangle& rCellRect ) const; + + // returns the rectangle where the EditEngine draws the text of a Header Cell + // if bColHeader is true it returns the rectangle of the header of the column in rCellPos + // otherwise of the header of the row in rCellPos + tools::Rectangle GetHeaderCellOutputRect(const tools::Rectangle& rVisRect, const ScAddress& rCellPos, bool bColHeader) const; + tools::Rectangle GetCellOutputRect(const ScAddress& rCellPos) const; + + // Query the range and rectangle of the main (non-repeat) cell range. + // Returns sal_False if not contained. + bool GetMainCellRange( ScRange& rRange, tools::Rectangle& rPixRect ) const; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/prevwsh.hxx b/sc/source/ui/inc/prevwsh.hxx new file mode 100644 index 000000000..5f2a9e89f --- /dev/null +++ b/sc/source/ui/inc/prevwsh.hxx @@ -0,0 +1,122 @@ +/* -*- 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_SC_SOURCE_UI_INC_PREVWSH_HXX +#define INCLUDED_SC_SOURCE_UI_INC_PREVWSH_HXX + +#include <types.hxx> +#include <scdllapi.h> + +#include <sfx2/viewsh.hxx> +#include <sfx2/zoomitem.hxx> +#include <vcl/syswin.hxx> + +#include <shellids.hxx> + +class ScDocument; +class ScDocShell; +class ScPreview; +struct ScHeaderFieldData; +class ScPreviewLocationData; +class CommandEvent; +class SfxViewFactory; + +class SC_DLLPUBLIC ScPreviewShell: public SfxViewShell +{ + ScDocShell* pDocShell; + + VclPtr<SystemWindow> mpFrameWindow; + VclPtr<ScPreview> pPreview; // Output window + VclPtr<ScrollBar> pHorScroll; + VclPtr<ScrollBar> pVerScroll; + VclPtr<vcl::Window> pCorner; + + TriState nSourceDesignMode; // form design mode from TabView + SvxZoomType eZoom; + long nMaxVertPos; + + std::unique_ptr<SfxBroadcaster> pAccessibilityBroadcaster; + bool GetPageSize( Size& aPageSize ); +private: + void Construct( vcl::Window* pParent ); + DECL_LINK( ScrollHandler, ScrollBar*, void ); + DECL_LINK( CloseHdl, SystemWindow&, void); + void DoScroll( sal_uInt16 nMode ); + void ExitPreview(); + +protected: + virtual void Activate(bool bMDI) override; + void AdjustPosSizePixel( const Point &rPos, const Size &rSize ); + + virtual void InnerResizePixel( const Point &rOfs, const Size &rSize, bool inplaceEditModeChange ) override; + virtual void OuterResizePixel( const Point &rOfs, const Size &rSize ) override; + + virtual void WriteUserData(OUString &, bool bBrowse = false) override; + virtual void ReadUserData(const OUString &, bool bBrowse = false) override; + + virtual void WriteUserDataSequence (css::uno::Sequence < css::beans::PropertyValue >& ) override; + virtual void ReadUserDataSequence (const css::uno::Sequence < css::beans::PropertyValue >& ) override; + +public: + SFX_DECL_INTERFACE(SCID_PREVIEW_SHELL) + SFX_DECL_VIEWFACTORY(ScPreviewShell); + +private: + /// SfxInterface initializer. + static void InitInterface_Impl(); + +public: + ScPreviewShell( SfxViewFrame* pViewFrame, + SfxViewShell* pOldSh ); + + virtual ~ScPreviewShell() override; + + void InitStartTable(SCTAB nTab); + + void UpdateScrollBars(); + void UpdateNeededScrollBars(bool bFromZoom); + bool ScrollCommand( const CommandEvent& rCEvt ); + + void Execute( SfxRequest& rReq ); + void GetState( SfxItemSet& rSet ); + + void FillFieldData( ScHeaderFieldData& rData ); + + TriState GetSourceDesignMode() const { return nSourceDesignMode; } + + virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override; + + virtual SfxPrinter* GetPrinter( bool bCreate = false ) override; + virtual sal_uInt16 SetPrinter( SfxPrinter* pNewPrinter, SfxPrinterChangeFlags nDiffFlags = SFX_PRINTER_ALL ) override; + virtual bool HasPrintOptionsPage() const override; + virtual std::unique_ptr<SfxTabPage> CreatePrintOptionsPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet &rOptions) override; + + void AddAccessibilityObject( SfxListener& rObject ); + void RemoveAccessibilityObject( SfxListener& rObject ); + void BroadcastAccessibility( const SfxHint &rHint ); + bool HasAccessibilityObjects() const; + + const ScPreviewLocationData& GetLocationData(); + ScDocument& GetDocument(); + ScPreview* GetPreview() { return pPreview; } +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/printfun.hxx b/sc/source/ui/inc/printfun.hxx new file mode 100644 index 000000000..e16fd855a --- /dev/null +++ b/sc/source/ui/inc/printfun.hxx @@ -0,0 +1,397 @@ +/* -*- 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_SC_SOURCE_UI_INC_PRINTFUN_HXX +#define INCLUDED_SC_SOURCE_UI_INC_PRINTFUN_HXX + +#include <memory> +#include <pagepar.hxx> +#include <editutil.hxx> + +class SfxPrinter; +class ScDocShell; +class ScDocument; +class ScViewData; +class SfxItemSet; +class ScPageHFItem; +class EditTextObject; +class MultiSelection; +class ScPageBreakData; +class ScPreviewLocationData; +class ScPrintOptions; +class SvxBoxItem; +class SvxBrushItem; +class SvxShadowItem; +class FmFormView; + +#define RANGENO_NORANGE USHRT_MAX + +#define PRINT_HEADER_WIDTH (1.0 * TWIPS_PER_CM) +#define PRINT_HEADER_HEIGHT (12.8 * TWIPS_PER_POINT) + + // Settings for headers/footers +struct ScPrintHFParam +{ + bool bEnable; + bool bDynamic; + bool bShared; + long nHeight; // in total (height + distance + frames) + long nManHeight; // set size (min when dynamic) + sal_uInt16 nDistance; + sal_uInt16 nLeft; // edges + sal_uInt16 nRight; + const ScPageHFItem* pLeft; + const ScPageHFItem* pRight; + const SvxBoxItem* pBorder; + const SvxBrushItem* pBack; + const SvxShadowItem* pShadow; +}; + +class ScPageRowEntry +{ +private: + SCROW nStartRow; + SCROW nEndRow; + size_t nPagesX; + std::vector<bool> aHidden; + //! Cache Number of really visible? + +public: + ScPageRowEntry() { nStartRow = nEndRow = 0; nPagesX = 0; } + + ScPageRowEntry(const ScPageRowEntry& r); + ScPageRowEntry& operator=(const ScPageRowEntry& r); + + SCROW GetStartRow() const { return nStartRow; } + SCROW GetEndRow() const { return nEndRow; } + size_t GetPagesX() const { return nPagesX; } + void SetStartRow(SCROW n) { nStartRow = n; } + void SetEndRow(SCROW n) { nEndRow = n; } + + void SetPagesX(size_t nNew); + void SetHidden(size_t nX); + bool IsHidden(size_t nX) const; + + size_t CountVisible() const; +}; + +namespace sc +{ + +struct PrintPageRangesInput +{ + bool m_bSkipEmpty; + bool m_bPrintArea; + SCROW m_nStartRow; + SCROW m_nEndRow; + SCCOL m_nStartCol; + SCCOL m_nEndCol; + SCTAB m_nPrintTab; + Size m_aDocSize; + + PrintPageRangesInput() + : m_bSkipEmpty(false) + , m_bPrintArea(false) + , m_nStartRow(0) + , m_nEndRow(0) + , m_nStartCol(0) + , m_nEndCol(0) + , m_nPrintTab(0) + {} +}; + +class PrintPageRanges +{ +public: + PrintPageRanges(); + + std::vector<SCCOL> m_aPageEndX; + std::vector<SCROW> m_aPageEndY; + std::vector<ScPageRowEntry> m_aPageRows; + + size_t m_nPagesX; + size_t m_nPagesY; + size_t m_nTotalY; + + PrintPageRangesInput m_aInput; + + bool checkIfAlreadyCalculatedAndSet(bool bSkipEmpty, bool bPrintArea, + SCROW nStartRow, SCROW nEndRow, + SCCOL nStartCol, SCCOL nEndCol, + SCTAB nPrintTab, Size const & aDocSize); + + void calculate(ScDocument* pDoc, bool bSkipEmpty, bool bPrintArea, + SCROW nStartRow, SCROW nEndRow, SCCOL nStartCol, SCCOL nEndCol, + SCTAB nPrintTab, Size const & aDocSize); +}; + +} + +struct ScPrintState // Save Variables from ScPrintFunc +{ + SCTAB nPrintTab; + SCCOL nStartCol; + SCROW nStartRow; + SCCOL nEndCol; + SCROW nEndRow; + bool bPrintAreaValid; // the 4 variables above are set + sal_uInt16 nZoom; + size_t nPagesX; + size_t nPagesY; + long nTabPages; + long nTotalPages; + long nPageStart; + long nDocPages; + + // Additional state of page ranges + bool bSavedStateRanges; + sc::PrintPageRangesInput aPrintPageRangesInput; + size_t nTotalY; + std::vector<SCCOL> aPageEndX; + std::vector<SCROW> aPageEndY; + std::vector<ScPageRowEntry> aPageRows; + + ScPrintState() + : nPrintTab(0) + , nStartCol(0) + , nStartRow(0) + , nEndCol(0) + , nEndRow(0) + , bPrintAreaValid(false) + , nZoom(0) + , nPagesX(0) + , nPagesY(0) + , nTabPages(0) + , nTotalPages(0) + , nPageStart(0) + , nDocPages(0) + , bSavedStateRanges(false) + , nTotalY(0) + {} +}; + +class ScPrintFunc +{ +private: + ScDocShell* pDocShell; + ScDocument* pDoc; + VclPtr<SfxPrinter> pPrinter; + VclPtr<OutputDevice> pDev; + FmFormView* pDrawView; + + MapMode aOldPrinterMode; // MapMode before the call + + Point aSrcOffset; // Paper-1/100 mm + Point aOffset; // scaled by a factor of page size + sal_uInt16 nManualZoom; // Zoom in Preview (percent) + bool bClearWin; // Clear output before + bool bUseStyleColor; + bool bIsRender; + + SCTAB nPrintTab; + long nPageStart; // Offset for the first page + long nDocPages; // Number of Pages in Document + + const ScRange* pUserArea; // Selection, if set in dialog + + const SfxItemSet* pParamSet; // Selected template + bool bFromPrintState; // created from State-struct + + // Parameter from template: + sal_uInt16 nLeftMargin; + sal_uInt16 nTopMargin; + sal_uInt16 nRightMargin; + sal_uInt16 nBottomMargin; + bool bCenterHor; + bool bCenterVer; + bool bLandscape; + bool bSourceRangeValid; + + SvxPageUsage nPageUsage; + Size aPageSize; // Printer Twips + const SvxBoxItem* pBorderItem; + const SvxBrushItem* pBackgroundItem; + const SvxShadowItem* pShadowItem; + + ScRange aLastSourceRange; + ScPrintHFParam aHdr; + ScPrintHFParam aFtr; + ScPageTableParam aTableParam; + ScPageAreaParam aAreaParam; + + // Calculated values: + sal_uInt16 nZoom; + bool bPrintCurrentTable; + bool bMultiArea; + bool mbHasPrintRange; + long nTabPages; + long nTotalPages; + + tools::Rectangle aPageRect; // Document Twips + + MapMode aLogicMode; // Set in DoPrint + MapMode aOffsetMode; + MapMode aTwipMode; + double nScaleX; + double nScaleY; + + SCCOL nRepeatStartCol; + SCCOL nRepeatEndCol; + SCROW nRepeatStartRow; + SCROW nRepeatEndRow; + + SCCOL nStartCol; + SCROW nStartRow; + SCCOL nEndCol; + SCROW nEndRow; + bool bPrintAreaValid; // the 4 variables above are set + + sc::PrintPageRanges m_aRanges; + + std::unique_ptr<ScHeaderEditEngine> pEditEngine; + std::unique_ptr<SfxItemSet> pEditDefaults; + + ScHeaderFieldData aFieldData; + + std::vector<ScAddress> aNotePosList; // The order of notes + + ScPageBreakData* pPageData; // for recording the breaks etc. + +public: + ScPrintFunc( ScDocShell* pShell, SfxPrinter* pNewPrinter, SCTAB nTab, + long nPage = 0, long nDocP = 0, + const ScRange* pArea = nullptr, + const ScPrintOptions* pOptions = nullptr, + ScPageBreakData* pData = nullptr ); + + ScPrintFunc( ScDocShell* pShell, SfxPrinter* pNewPrinter, + const ScPrintState& rState, const ScPrintOptions* pOptions ); + + // ctors for device other than printer - for preview and pdf: + + ScPrintFunc( OutputDevice* pOutDev, ScDocShell* pShell, SCTAB nTab, + long nPage = 0, long nDocP = 0, + const ScRange* pArea = nullptr, + const ScPrintOptions* pOptions = nullptr ); + + ScPrintFunc( OutputDevice* pOutDev, ScDocShell* pShell, + const ScPrintState& rState, + const ScPrintOptions* pOptions ); + + ~ScPrintFunc(); + + static void DrawToDev( ScDocument* pDoc, OutputDevice* pDev, double nPrintFactor, + const tools::Rectangle& rBound, ScViewData* pViewData, bool bMetaFile ); + + void SetDrawView( FmFormView* pNew ); + + void SetOffset( const Point& rOfs ); + void SetManualZoom( sal_uInt16 nNewZoom ); + void SetDateTime( const DateTime& ); + + void SetClearFlag( bool bFlag ); + void SetUseStyleColor( bool bFlag ); + void SetRenderFlag( bool bFlag ); + + void SetExclusivelyDrawOleAndDrawObjects();//for printing selected objects without surrounding cell contents + + bool UpdatePages(); + + void ApplyPrintSettings(); // Already called from DoPrint() + long DoPrint( const MultiSelection& rPageRanges, + long nStartPage, long nDisplayStart, bool bDoPrint, + ScPreviewLocationData* pLocationData ); + + // Query values - immediately + + const Size& GetPageSize() const { return aPageSize; } + Size GetDataSize() const; + void GetScaleData( Size& rPhysSize, long& rDocHdr, long& rDocFtr ); + long GetFirstPageNo() const { return aTableParam.nFirstPageNo; } + + long GetTotalPages() const { return nTotalPages; } + sal_uInt16 GetZoom() const { return nZoom; } + + void ResetBreaks( SCTAB nTab ); + + void GetPrintState(ScPrintState& rState, bool bSavePageRanges = false); + bool GetLastSourceRange( ScRange& rRange ) const; + sal_uInt16 GetLeftMargin() const{return nLeftMargin;} + sal_uInt16 GetRightMargin() const{return nRightMargin;} + sal_uInt16 GetTopMargin() const{return nTopMargin;} + sal_uInt16 GetBottomMargin() const{return nBottomMargin;} + const ScPrintHFParam& GetHeader() const {return aHdr;} + const ScPrintHFParam& GetFooter() const {return aFtr;} + + bool HasPrintRange() const { return mbHasPrintRange;} + +private: + void Construct( const ScPrintOptions* pOptions ); + void InitParam( const ScPrintOptions* pOptions ); + void CalcZoom( sal_uInt16 nRangeNo ); + void CalcPages(); + long CountPages(); + long CountNotePages(); + + bool AdjustPrintArea( bool bNew ); + + Size GetDocPageSize(); + + long TextHeight( const EditTextObject* pObject ); + void MakeEditEngine(); + void UpdateHFHeight( ScPrintHFParam& rParam ); + + void InitModes(); + + bool IsLeft( long nPageNo ); + bool IsMirror( long nPageNo ); + void MakeTableString(); // sets aTableStr + + void PrintPage( long nPageNo, + SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2, + bool bDoPrint, ScPreviewLocationData* pLocationData ); + void PrintArea( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2, + long nScrX, long nScrY, + bool bShLeft, bool bShTop, bool bShRight, bool bShBottom ); + void LocateArea( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2, + long nScrX, long nScrY, bool bRepCol, bool bRepRow, + ScPreviewLocationData& rLocationData ); + void PrintColHdr( SCCOL nX1, SCCOL nX2, long nScrX, long nScrY ); + void PrintRowHdr( SCROW nY1, SCROW nY2, long nScrX, long nScrY ); + void LocateColHdr( SCCOL nX1, SCCOL nX2, long nScrX, long nScrY, + bool bRepCol, ScPreviewLocationData& rLocationData ); + void LocateRowHdr( SCROW nY1, SCROW nY2, long nScrX, long nScrY, + bool bRepRow, ScPreviewLocationData& rLocationData ); + void PrintHF( long nPageNo, bool bHeader, long nStartY, + bool bDoPrint, ScPreviewLocationData* pLocationData ); + + long PrintNotes( long nPageNo, long nNoteStart, bool bDoPrint, ScPreviewLocationData* pLocationData ); + long DoNotes( long nNoteStart, bool bDoPrint, ScPreviewLocationData* pLocationData ); + + void DrawBorder( long nScrX, long nScrY, long nScrW, long nScrH, + const SvxBoxItem* pBorderData, + const SvxBrushItem* pBackground, + const SvxShadowItem* pShadow ); + + void FillPageData(); +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/protectiondlg.hxx b/sc/source/ui/inc/protectiondlg.hxx new file mode 100644 index 000000000..b3db92440 --- /dev/null +++ b/sc/source/ui/inc/protectiondlg.hxx @@ -0,0 +1,74 @@ +/* -*- 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_SC_SOURCE_UI_INC_PROTECTIONDLG_HXX +#define INCLUDED_SC_SOURCE_UI_INC_PROTECTIONDLG_HXX + +#include <vcl/weld.hxx> +#include <scdllapi.h> + +class ScTableProtection; + +class ScTableProtectionDlg : public weld::GenericDialogController +{ +public: + ScTableProtectionDlg() = delete; + explicit ScTableProtectionDlg(weld::Window* pParent); + virtual ~ScTableProtectionDlg() override; + + void SetDialogData(const ScTableProtection& rData); + + void WriteData(ScTableProtection& rData) const; + +private: + void Init(); + + void EnableOptionalWidgets(bool bEnable); + + OUString m_aSelectLockedCells; + OUString m_aSelectUnlockedCells; + OUString m_aInsertColumns; + OUString m_aInsertRows; + OUString m_aDeleteColumns; + OUString m_aDeleteRows; + + std::unique_ptr<weld::CheckButton> m_xBtnProtect; + std::unique_ptr<weld::Container> m_xPasswords; + std::unique_ptr<weld::Container> m_xOptions; + std::unique_ptr<weld::Entry> m_xPassword1Edit; + std::unique_ptr<weld::Entry> m_xPassword2Edit; + std::unique_ptr<weld::TreeView> m_xOptionsListBox; + std::unique_ptr<weld::Button> m_xBtnOk; + std::unique_ptr<weld::Label> m_xProtected; + std::unique_ptr<weld::Label> m_xUnprotected; + std::unique_ptr<weld::Label> m_xInsertColumns; + std::unique_ptr<weld::Label> m_xInsertRows; + std::unique_ptr<weld::Label> m_xDeleteColumns; + std::unique_ptr<weld::Label> m_xDeleteRows; + + void InsertEntry(const OUString& rTxt); + + DECL_LINK(OKHdl, weld::Button&, void); + DECL_LINK(CheckBoxHdl, weld::ToggleButton&, void); + DECL_LINK(PasswordModifyHdl, weld::Entry&, void); +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/pvfundlg.hxx b/sc/source/ui/inc/pvfundlg.hxx new file mode 100644 index 000000000..47891ece7 --- /dev/null +++ b/sc/source/ui/inc/pvfundlg.hxx @@ -0,0 +1,206 @@ +/* -*- 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_SC_SOURCE_UI_INC_PVFUNDLG_HXX +#define INCLUDED_SC_SOURCE_UI_INC_PVFUNDLG_HXX + +#include <com/sun/star/sheet/DataPilotFieldReference.hpp> +#include <com/sun/star/sheet/DataPilotFieldOrientation.hpp> + +#include <vcl/weld.hxx> +#include <pivot.hxx> + +#include <memory> +#include <unordered_map> + +class ScDPObject; + +class ScDPFunctionListBox +{ +public: + ScDPFunctionListBox(std::unique_ptr<weld::TreeView> xControl); + + void SetSelection( PivotFunc nFuncMask ); + PivotFunc GetSelection() const; + + void set_sensitive(bool sensitive) { m_xControl->set_sensitive(sensitive); } + void set_selection_mode(SelectionMode eMode) { m_xControl->set_selection_mode(eMode); } + void connect_row_activated(const Link<weld::TreeView&, bool>& rLink) { m_xControl->connect_row_activated(rLink); } + int get_height_rows(int nRows) const { return m_xControl->get_height_rows(nRows); } + void set_size_request(int nWidth, int nHeight) { m_xControl->set_size_request(nWidth, nHeight); } + +private: + std::unique_ptr<weld::TreeView> m_xControl; + void FillFunctionNames(); +}; + +class ScDPFunctionDlg : public weld::GenericDialogController +{ + typedef std::unordered_map< OUString, OUString > NameMapType; +public: + explicit ScDPFunctionDlg(weld::Widget* pParent, const ScDPLabelDataVector& rLabelVec, + const ScDPLabelData& rLabelData, const ScPivotFuncData& rFuncData ); + virtual ~ScDPFunctionDlg() override; + PivotFunc GetFuncMask() const; + css::sheet::DataPilotFieldReference GetFieldRef() const; + +private: + void Init( const ScDPLabelData& rLabelData, const ScPivotFuncData& rFuncData ); + + const OUString& GetBaseFieldName(const OUString& rLayoutName) const; + const OUString& GetBaseItemName(const OUString& rLayoutName) const; + + /** Searches for a listbox entry, starts search at specified position. */ + sal_Int32 FindBaseItemPos( const OUString& rEntry, sal_Int32 nStartPos ) const; + + DECL_LINK(SelectHdl, weld::ComboBox&, void); + DECL_LINK(DblClickHdl, weld::TreeView&, bool); + +private: + std::unique_ptr<ScDPFunctionListBox> mxLbFunc; + std::unique_ptr<weld::Label> mxFtName; + std::unique_ptr<weld::ComboBox> mxLbType; + std::unique_ptr<weld::Label> mxFtBaseField; + std::unique_ptr<weld::ComboBox> mxLbBaseField; + std::unique_ptr<weld::Label> mxFtBaseItem; + std::unique_ptr<weld::ComboBox> mxLbBaseItem; + std::unique_ptr<weld::Button> mxBtnOk; + + NameMapType maBaseFieldNameMap; // cache for base field display -> original name. + NameMapType maBaseItemNameMap; // cache for base item display -> original name. + + const ScDPLabelDataVector& mrLabelVec; /// Data of all labels. + bool mbEmptyItem; /// true = Empty base item in listbox. +}; + +class ScDPSubtotalDlg : public weld::GenericDialogController +{ +public: + explicit ScDPSubtotalDlg(weld::Widget* pParent, ScDPObject& rDPObj, + const ScDPLabelData& rLabelData, const ScPivotFuncData& rFuncData, + const ScDPNameVec& rDataFields, bool bEnableLayout); + virtual ~ScDPSubtotalDlg() override; + PivotFunc GetFuncMask() const; + + void FillLabelData( ScDPLabelData& rLabelData ) const; + +private: + void Init( const ScDPLabelData& rLabelData, const ScPivotFuncData& rFuncData ); + + DECL_LINK( DblClickHdl, weld::TreeView&, bool ); + DECL_LINK( RadioClickHdl, weld::Button&, void ); + DECL_LINK( ClickHdl, weld::Button&, void ); + +private: + ScDPObject& mrDPObj; /// The DataPilot object (for member names). + const ScDPNameVec& mrDataFields; /// The list of all data field names. + + ScDPLabelData maLabelData; /// Cache for sub dialog. + bool mbEnableLayout; /// true = Enable Layout mode controls. + + std::unique_ptr<weld::RadioButton> mxRbNone; + std::unique_ptr<weld::RadioButton> mxRbAuto; + std::unique_ptr<weld::RadioButton> mxRbUser; + std::unique_ptr<ScDPFunctionListBox> mxLbFunc; + std::unique_ptr<weld::Label> mxFtName; + std::unique_ptr<weld::CheckButton> mxCbShowAll; + std::unique_ptr<weld::Button> mxBtnOk; + std::unique_ptr<weld::Button> mxBtnOptions; +}; + +class ScDPSubtotalOptDlg : public weld::GenericDialogController +{ +public: + explicit ScDPSubtotalOptDlg(weld::Window* pParent, ScDPObject& rDPObj, + const ScDPLabelData& rLabelData, const ScDPNameVec& rDataFields, + bool bEnableLayout ); + virtual ~ScDPSubtotalOptDlg() override; + void FillLabelData( ScDPLabelData& rLabelData ) const; + +private: + void Init( const ScDPNameVec& rDataFields, bool bEnableLayout ); + void InitHideListBox(); + + ScDPName GetFieldName(const OUString& rLayoutName) const; + + /** Searches for a listbox entry, starts search at specified position. */ + sal_Int32 FindListBoxEntry( const weld::ComboBox& rLBox, const OUString& rEntry, sal_Int32 nStartPos ) const; + + DECL_LINK( RadioClickHdl, weld::Button&, void ); + DECL_LINK( CheckHdl, weld::Button&, void ); + DECL_LINK( SelectHdl, weld::ComboBox&, void ); + +private: + std::unique_ptr<weld::ComboBox> m_xLbSortBy; + std::unique_ptr<weld::RadioButton> m_xRbSortAsc; + std::unique_ptr<weld::RadioButton> m_xRbSortDesc; + std::unique_ptr<weld::RadioButton> m_xRbSortMan; + std::unique_ptr<weld::Widget> m_xLayoutFrame; + std::unique_ptr<weld::ComboBox> m_xLbLayout; + std::unique_ptr<weld::CheckButton> m_xCbLayoutEmpty; + std::unique_ptr<weld::CheckButton> m_xCbRepeatItemLabels; + std::unique_ptr<weld::CheckButton> m_xCbShow; + std::unique_ptr<weld::SpinButton> m_xNfShow; + std::unique_ptr<weld::Label> m_xFtShow; + std::unique_ptr<weld::Label> m_xFtShowFrom; + std::unique_ptr<weld::ComboBox> m_xLbShowFrom; + std::unique_ptr<weld::Label> m_xFtShowUsing; + std::unique_ptr<weld::ComboBox> m_xLbShowUsing; + std::unique_ptr<weld::Widget> m_xHideFrame; + std::unique_ptr<weld::TreeView> m_xLbHide; + std::unique_ptr<weld::Label> m_xFtHierarchy; + std::unique_ptr<weld::ComboBox> m_xLbHierarchy; + + ScDPObject& mrDPObj; /// The DataPilot object (for member names). + ScDPLabelData maLabelData; /// Cache for members data. + + typedef std::unordered_map<OUString, ScDPName> NameMapType; + NameMapType maDataFieldNameMap; /// Cache for displayed name to field name mapping. +}; + +class ScDPShowDetailDlg : public weld::GenericDialogController +{ +public: + explicit ScDPShowDetailDlg(weld::Window* pParent, ScDPObject& rDPObj, + css::sheet::DataPilotFieldOrientation nOrient); + virtual ~ScDPShowDetailDlg() override; + + virtual short run() override; + + /** + * @return String internal name of the selected field. Note that this may + * be different from the name displayed in the dialog if the field + * has a layout name. + */ + OUString GetDimensionName() const; + +private: + DECL_LINK(DblClickHdl, weld::TreeView&, bool); + +private: + typedef std::unordered_map<OUString, long> DimNameIndexMap; + DimNameIndexMap maNameIndexMap; + ScDPObject& mrDPObj; + + std::unique_ptr<weld::TreeView> mxLbDims; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/redcom.hxx b/sc/source/ui/inc/redcom.hxx new file mode 100644 index 000000000..2164af873 --- /dev/null +++ b/sc/source/ui/inc/redcom.hxx @@ -0,0 +1,60 @@ +/* -*- 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_SC_SOURCE_UI_INC_REDCOM_HXX +#define INCLUDED_SC_SOURCE_UI_INC_REDCOM_HXX + +#include <rtl/ustring.hxx> +#include <tools/link.hxx> +#include <vcl/vclptr.hxx> + +namespace weld { class Window; } +class ScChangeAction; +class SfxItemSet; +class ScDocShell; +class AbstractSvxPostItDialog; + +class ScRedComDialog final +{ + ScChangeAction *pChangeAction; + ScDocShell *pDocShell; + OUString aComment; + VclPtr<AbstractSvxPostItDialog> pDlg; + + DECL_LINK( PrevHdl, AbstractSvxPostItDialog&, void ); + DECL_LINK( NextHdl, AbstractSvxPostItDialog&, void ); + + void ReInit(ScChangeAction *); + void SelectCell(); + + ScChangeAction *FindPrev(ScChangeAction *pAction); + ScChangeAction *FindNext(ScChangeAction *pAction); + +public: + + ScRedComDialog( weld::Window* pParent, const SfxItemSet& rCoreSet, + ScDocShell *pShell, ScChangeAction *pAction, bool bPrevNext); + ~ScRedComDialog(); + + void Execute(); +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/reffact.hxx b/sc/source/ui/inc/reffact.hxx new file mode 100644 index 000000000..f30cdf73c --- /dev/null +++ b/sc/source/ui/inc/reffact.hxx @@ -0,0 +1,200 @@ +/* -*- 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_SC_SOURCE_UI_INC_REFFACT_HXX +#define INCLUDED_SC_SOURCE_UI_INC_REFFACT_HXX + +#include <sfx2/childwin.hxx> +#include "ChildWindowWrapper.hxx" + +#include <sc.hrc> + +#define DECL_WRAPPER_WITHID(Class) \ + class Class : public SfxChildWindow \ + { \ + public: \ + Class( vcl::Window*, sal_uInt16, SfxBindings*, const SfxChildWinInfo* ); \ + SFX_DECL_CHILDWINDOW_WITHID(Class); \ + }; + +DECL_WRAPPER_WITHID(ScNameDlgWrapper) +DECL_WRAPPER_WITHID(ScNameDefDlgWrapper) +DECL_WRAPPER_WITHID(ScSolverDlgWrapper) +DECL_WRAPPER_WITHID(ScOptSolverDlgWrapper) +DECL_WRAPPER_WITHID(ScXMLSourceDlgWrapper) +DECL_WRAPPER_WITHID(ScPivotLayoutWrapper) +DECL_WRAPPER_WITHID(ScTabOpDlgWrapper) +DECL_WRAPPER_WITHID(ScFilterDlgWrapper) +DECL_WRAPPER_WITHID(ScSpecialFilterDlgWrapper) +DECL_WRAPPER_WITHID(ScDbNameDlgWrapper) +DECL_WRAPPER_WITHID(ScConsolidateDlgWrapper) +DECL_WRAPPER_WITHID(ScPrintAreasDlgWrapper) +DECL_WRAPPER_WITHID(ScColRowNameRangesDlgWrapper) +DECL_WRAPPER_WITHID(ScFormulaDlgWrapper) +DECL_WRAPPER_WITHID(ScHighlightChgDlgWrapper) +DECL_WRAPPER_WITHID(ScCondFormatDlgWrapper) + +class ScDescriptiveStatisticsDialogWrapper : + public ChildControllerWrapper<SID_DESCRIPTIVE_STATISTICS_DIALOG> +{ +private: + ScDescriptiveStatisticsDialogWrapper() = delete; +}; + +class ScSamplingDialogWrapper : + public ChildControllerWrapper<SID_SAMPLING_DIALOG> +{ +private: + ScSamplingDialogWrapper() = delete; +}; + +class ScRandomNumberGeneratorDialogWrapper : + public ChildControllerWrapper<SID_RANDOM_NUMBER_GENERATOR_DIALOG> +{ +private: + ScRandomNumberGeneratorDialogWrapper() = delete; +}; + +class ScAnalysisOfVarianceDialogWrapper : + public ChildControllerWrapper<SID_ANALYSIS_OF_VARIANCE_DIALOG> +{ +private: + ScAnalysisOfVarianceDialogWrapper() = delete; +}; + +class ScCorrelationDialogWrapper : + public ChildControllerWrapper<SID_CORRELATION_DIALOG> +{ +private: + ScCorrelationDialogWrapper() = delete; +}; + +class ScCovarianceDialogWrapper : + public ChildControllerWrapper<SID_COVARIANCE_DIALOG> +{ +private: + ScCovarianceDialogWrapper() = delete; +}; + +class ScExponentialSmoothingDialogWrapper : + public ChildControllerWrapper<SID_EXPONENTIAL_SMOOTHING_DIALOG> +{ +private: + ScExponentialSmoothingDialogWrapper() = delete; +}; + +class ScMovingAverageDialogWrapper : + public ChildControllerWrapper<SID_MOVING_AVERAGE_DIALOG> +{ +private: + ScMovingAverageDialogWrapper() = delete; +}; + +class ScRegressionDialogWrapper : + public ChildControllerWrapper<SID_REGRESSION_DIALOG> +{ +private: + ScRegressionDialogWrapper() = delete; +}; + +class ScTTestDialogWrapper : + public ChildControllerWrapper<SID_TTEST_DIALOG> +{ +private: + ScTTestDialogWrapper() = delete; +}; + +class ScFTestDialogWrapper : + public ChildControllerWrapper<SID_FTEST_DIALOG> +{ +private: + ScFTestDialogWrapper() = delete; +}; + +class ScZTestDialogWrapper : + public ChildControllerWrapper<SID_ZTEST_DIALOG> +{ +private: + ScZTestDialogWrapper() = delete; +}; + +class ScChiSquareTestDialogWrapper : + public ChildControllerWrapper<SID_CHI_SQUARE_TEST_DIALOG> +{ +private: + ScChiSquareTestDialogWrapper() = delete; +}; + +class ScFourierAnalysisDialogWrapper : + public ChildControllerWrapper<SID_FOURIER_ANALYSIS_DIALOG> +{ +private: + ScFourierAnalysisDialogWrapper() = delete; +}; + +class ScAcceptChgDlgWrapper : public SfxChildWindow +{ +public: + ScAcceptChgDlgWrapper( vcl::Window*, + sal_uInt16, + SfxBindings*, + SfxChildWinInfo* ); + + SFX_DECL_CHILDWINDOW_WITHID(Class); + + void ReInitDlg(); +}; + +class ScSimpleRefDlgWrapper: public SfxChildWindow +{ +public: + ScSimpleRefDlgWrapper(vcl::Window*, + sal_uInt16, + SfxBindings*, + SfxChildWinInfo*); + + SFX_DECL_CHILDWINDOW_WITHID(Class); + + void SetRefString(const OUString& rStr); + void SetCloseHdl( const Link<const OUString*,void>& rLink ); + void SetUnoLinks( const Link<const OUString&,void>& rDone, const Link<const OUString&,void>& rAbort, + const Link<const OUString&,void>& rChange ); + void SetFlags( bool bCloseOnButtonUp, bool bSingleCell, bool bMultiSelection ); + static void SetAutoReOpen(bool bFlag); + + void StartRefInput(); +}; + +class ScValidityRefChildWin : public SfxChildWindow +{ + bool m_bVisibleLock:1; + bool m_bFreeWindowLock:1; +public: + ScValidityRefChildWin( vcl::Window*, sal_uInt16, const SfxBindings*, SfxChildWinInfo* ); + SFX_DECL_CHILDWINDOW_WITHID(ScValidityRefChildWin); + virtual ~ScValidityRefChildWin() override; + bool LockVisible( bool bLock ){ bool bVis = m_bVisibleLock; m_bVisibleLock = bLock; return bVis; } + bool LockFreeWindow( bool bLock ){ bool bFreeWindow = m_bFreeWindowLock; m_bFreeWindowLock = bLock; return bFreeWindow; } + void Hide() override { if( !m_bVisibleLock) SfxChildWindow::Hide(); } + void Show( ShowFlags nFlags ) override { if( !m_bVisibleLock ) SfxChildWindow::Show( nFlags ); } +}; + +#endif // INCLUDED_SC_SOURCE_UI_INC_REFFACT_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/refundo.hxx b/sc/source/ui/inc/refundo.hxx new file mode 100644 index 000000000..7ee764eca --- /dev/null +++ b/sc/source/ui/inc/refundo.hxx @@ -0,0 +1,57 @@ +/* -*- 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_SC_SOURCE_UI_INC_REFUNDO_HXX +#define INCLUDED_SC_SOURCE_UI_INC_REFUNDO_HXX + +#include <memory> + +class ScDocument; +class ScDBCollection; +class ScRangeName; +class ScPrintRangeSaver; +class ScDPCollection; +class ScDetOpList; +class ScChartListenerCollection; +class ScAreaLinkSaveCollection; +class ScUnoRefList; + +class ScRefUndoData +{ +private: + std::unique_ptr<ScDBCollection> pDBCollection; + std::unique_ptr<ScRangeName> pRangeName; + std::unique_ptr<ScPrintRangeSaver> pPrintRanges; + std::unique_ptr<ScDPCollection> pDPCollection; + std::unique_ptr<ScDetOpList> pDetOpList; + std::unique_ptr<ScChartListenerCollection> pChartListenerCollection; + std::unique_ptr<ScAreaLinkSaveCollection> pAreaLinks; + std::unique_ptr<ScUnoRefList> pUnoRefs; + +public: + ScRefUndoData( const ScDocument* pDoc ); + ~ScRefUndoData(); + + void DeleteUnchanged( const ScDocument* pDoc ); + void DoUndo( ScDocument* pDoc, bool bUndoRefFirst ); +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/retypepassdlg.hxx b/sc/source/ui/inc/retypepassdlg.hxx new file mode 100644 index 000000000..60321a73f --- /dev/null +++ b/sc/source/ui/inc/retypepassdlg.hxx @@ -0,0 +1,134 @@ +/* -*- 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_SC_SOURCE_UI_INC_RETYPEPASSDLG_HXX +#define INCLUDED_SC_SOURCE_UI_INC_RETYPEPASSDLG_HXX + +#include <vcl/weld.hxx> +#include <tabprotection.hxx> +#include <memory> + +class ScDocument; + +struct PassFragment +{ + std::unique_ptr<weld::Builder> m_xBuilder; + std::unique_ptr<weld::Container> m_xSheetsBox; + std::unique_ptr<weld::Label> m_xName; + std::unique_ptr<weld::Label> m_xStatus; + std::unique_ptr<weld::Button> m_xButton; + + PassFragment(weld::Widget* pParent); +}; + +class ScRetypePassDlg : public weld::GenericDialogController +{ +public: + typedef std::shared_ptr<ScDocProtection> DocProtectionPtr; + typedef std::shared_ptr<ScTableProtection> TabProtectionPtr; + + explicit ScRetypePassDlg(weld::Window* pParent); + virtual ~ScRetypePassDlg() override; + + virtual short run() override; + + void SetDataFromDocument(const ScDocument& rDoc); + void SetDesiredHash(ScPasswordHash eHash); + + /** Write the new set of password data to the document instance to + overwrite the current ones. */ + void WriteNewDataToDocument(ScDocument& rDoc) const; + +private: + void Init(); + void PopulateDialog(); + void SetDocData(); + void SetTableData(size_t nRowPos, SCTAB nTab); + + /** Check the status of all hash values to see if it's okay to enable + the OK button. */ + void CheckHashStatus(); + + void DeleteSheets(); + +private: + OUString maTextNotProtected; + OUString maTextNotPassProtected; + OUString maTextHashBad; + OUString maTextHashGood; + + DECL_LINK(OKHdl, weld::Button&, void); + DECL_LINK(RetypeBtnHdl, weld::Button&, void); + + struct TableItem + { + OUString maName; + TabProtectionPtr mpProtect; + }; + ::std::vector<TableItem> maTableItems; + + DocProtectionPtr mpDocItem; + ScPasswordHash meDesiredHash; + + std::unique_ptr<weld::Button> mxBtnOk; + std::unique_ptr<weld::Label> mxTextDocStatus; + std::unique_ptr<weld::Button> mxBtnRetypeDoc; + std::unique_ptr<weld::ScrolledWindow> mxScrolledWindow; + std::unique_ptr<weld::Container> mxSheetsBox; + std::vector<std::unique_ptr<PassFragment>> maSheets; +}; + +class ScRetypePassInputDlg : public weld::GenericDialogController +{ +public: + ScRetypePassInputDlg() = delete; + explicit ScRetypePassInputDlg(weld::Window* pParent, ScPassHashProtectable* pProtected); + virtual ~ScRetypePassInputDlg() override; + + bool IsRemovePassword() const; + OUString GetNewPassword() const; + +private: + void Init(); + void CheckPasswordInput(); + +private: + ScPassHashProtectable* m_pProtected; + + std::unique_ptr<weld::Button> m_xBtnOk; + + std::unique_ptr<weld::RadioButton> m_xBtnRetypePassword; + + std::unique_ptr<weld::Widget> m_xPasswordGrid; + std::unique_ptr<weld::Entry> m_xPassword1Edit; + std::unique_ptr<weld::Entry> m_xPassword2Edit; + + std::unique_ptr<weld::CheckButton> m_xBtnMatchOldPass; + + std::unique_ptr<weld::RadioButton> m_xBtnRemovePassword; + + DECL_LINK( OKHdl, weld::Button&, void ); + DECL_LINK( RadioBtnHdl, weld::ToggleButton&, void ); + DECL_LINK( CheckBoxHdl, weld::ToggleButton&, void ); + DECL_LINK( PasswordModifyHdl, weld::Entry&, void ); +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/rfindlst.hxx b/sc/source/ui/inc/rfindlst.hxx new file mode 100644 index 000000000..e6f04e07c --- /dev/null +++ b/sc/source/ui/inc/rfindlst.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_SC_SOURCE_UI_INC_RFINDLST_HXX +#define INCLUDED_SC_SOURCE_UI_INC_RFINDLST_HXX + +#include <tools/color.hxx> +#include <address.hxx> +#include <tools/solar.h> + +#include <vector> + +struct ScRangeFindData +{ + ScRange aRef; + ScRefFlags nFlags; + sal_Int32 nSelStart; + sal_Int32 nSelEnd; + Color nColor; + + ScRangeFindData( const ScRange& rR, ScRefFlags nF, sal_Int32 nS, sal_Int32 nE ) : + aRef(rR), nFlags(nF), nSelStart(nS), nSelEnd(nE) {} +}; + +class ScRangeFindList +{ + std::vector<ScRangeFindData> maEntries; + OUString aDocName; + bool bHidden; + sal_uInt16 nIndexColor; + +public: + ScRangeFindList(const OUString& rName); + + sal_uLong Count() const { return maEntries.size(); } + Color Insert( const ScRangeFindData &rNew ); + + ScRangeFindData& GetObject( sal_uLong nIndex ) { return maEntries[nIndex]; } + + void SetHidden( bool bSet ) { bHidden = bSet; } + + const OUString& GetDocName() const { return aDocName; } + bool IsHidden() const { return bHidden; } + + static Color GetColorName(const size_t nIndex); + Color FindColor(const ScRange& rRef, const size_t nIndex); +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/scendlg.hxx b/sc/source/ui/inc/scendlg.hxx new file mode 100644 index 000000000..97cc05e7b --- /dev/null +++ b/sc/source/ui/inc/scendlg.hxx @@ -0,0 +1,61 @@ +/* -*- 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_SC_SOURCE_UI_INC_SCENDLG_HXX +#define INCLUDED_SC_SOURCE_UI_INC_SCENDLG_HXX + +#include <vcl/weld.hxx> + +enum class ScScenarioFlags; + +class ColorListBox; + +class ScNewScenarioDlg : public weld::GenericDialogController +{ +public: + ScNewScenarioDlg(weld::Window* pParent, const OUString& rName, bool bEdit, bool bSheetProtected); + virtual ~ScNewScenarioDlg() override; + void SetScenarioData( const OUString& rName, const OUString& rComment, + const Color& rColor, ScScenarioFlags nFlags ); + + void GetScenarioData(OUString& rName, OUString& rComment, + Color& rColor, ScScenarioFlags &rFlags) const; + +private: + OUString aDefScenarioName; + bool bIsEdit; + std::unique_ptr<weld::Entry> m_xEdName; + std::unique_ptr<weld::TextView> m_xEdComment; + std::unique_ptr<weld::CheckButton> m_xCbShowFrame; + std::unique_ptr<ColorListBox> m_xLbColor; + std::unique_ptr<weld::CheckButton> m_xCbTwoWay; + std::unique_ptr<weld::CheckButton> m_xCbCopyAll; + std::unique_ptr<weld::CheckButton> m_xCbProtect; + std::unique_ptr<weld::Button> m_xBtnOk; + std::unique_ptr<weld::Label> m_xAltTitle; + std::unique_ptr<weld::Label> m_xCreatedFt; + std::unique_ptr<weld::Label> m_xOnFt; + + DECL_LINK(OkHdl, weld::Button&, void); + DECL_LINK(EnableHdl, weld::ToggleButton&, void); +}; + +#endif // INCLUDED_SC_SOURCE_UI_INC_SCENDLG_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/scui_def.hxx b/sc/source/ui/inc/scui_def.hxx new file mode 100644 index 000000000..c2bc095b8 --- /dev/null +++ b/sc/source/ui/inc/scui_def.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_SC_SOURCE_UI_INC_SCUI_DEF_HXX +#define INCLUDED_SC_SOURCE_UI_INC_SCUI_DEF_HXX + +#include <o3tl/typed_flags_set.hxx> + +#define SCRET_COLS 0x42 +#define SCRET_ROWS 0x43 + +#define FDS_OPT_NONE 0 // from filldlg.hxx +#define FDS_OPT_HORZ 1 // from filldlg.hxx +#define FDS_OPT_VERT 2 // from filldlg.hxx + +enum class InsertContentsFlags { + NONE = 0x00, + NoEmpty = 0x01, //from inscodlg.hxx + Trans = 0x02, //from inscodlg.hxx + Link = 0x04 //from inscodlg.hxx +}; +namespace o3tl { + template<> struct typed_flags<InsertContentsFlags> : is_typed_flags<InsertContentsFlags, 0x07> {}; +} + +enum class CellShiftDisabledFlags { + NONE = 0x00, + Down = 0x01, //from inscodlg.hxx + Right = 0x02 //from inscodlg.hxx +}; +namespace o3tl { + template<> struct typed_flags<CellShiftDisabledFlags> : is_typed_flags<CellShiftDisabledFlags, 0x3> {}; +} + +enum class CreateNameFlags { + NONE = 0, + Top = 1, //from namecrea.hxx + Left = 2, //from namecrea.hxx + Bottom = 4, //from namecrea.hxx + Right = 8, //from namecrea.hxx +}; +namespace o3tl { + template<> struct typed_flags<CreateNameFlags> : is_typed_flags<CreateNameFlags, 0xf> {}; +} + +#define BTN_PASTE_NAME 100 // from namepast.hxx +#define BTN_PASTE_LIST 101 // from namepast.hxx +#define BTN_PASTE_CLOSE 102 // from namepast.hxx + +#define BTN_EXTEND_RANGE 150 +#define BTN_CURRENT_SELECTION 151 +#define SCRET_REMOVE 0x42 //from subtdlg.hxx +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/scuiasciiopt.hxx b/sc/source/ui/inc/scuiasciiopt.hxx new file mode 100644 index 000000000..9128a196a --- /dev/null +++ b/sc/source/ui/inc/scuiasciiopt.hxx @@ -0,0 +1,142 @@ +/* -*- 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_SC_SOURCE_UI_INC_SCUIASCIIOPT_HXX +#define INCLUDED_SC_SOURCE_UI_INC_SCUIASCIIOPT_HXX + +#include <svx/langbox.hxx> +#include <tools/solar.h> +#include <tools/stream.hxx> +#include <vcl/customweld.hxx> +#include <vcl/weld.hxx> + +#include "asciiopt.hxx" + +class Button; +class CheckBox; +class Edit; +class FixedText; +class RadioButton; +class NumericField; + +class ScCsvTableBox; +class SvxTextEncodingBox; + +class ScImportAsciiDlg : public weld::GenericDialogController +{ + SvStream* mpDatStream; + sal_uLong mnStreamPos; + std::unique_ptr<sal_uLong[]> mpRowPosArray; + sal_uLong mnRowPosCount; + + OUString maPreviewLine[ CSV_PREVIEW_LINES ]; + + OUString maFieldSeparators; // selected field separators + sal_Unicode mcTextSep; + + rtl_TextEncoding meCharSet; /// Selected char set. + bool mbCharSetSystem; /// Is System char set selected? + ScImportAsciiCall meCall; /// How the dialog is called (see asciiopt.hxx) + bool mbDetectSpaceSep; /// Whether to detect a possible space separator. + + std::unique_ptr<weld::Label> mxFtCharSet; + std::unique_ptr<SvxTextEncodingBox> mxLbCharSet; + std::unique_ptr<weld::Label> mxFtCustomLang; + std::unique_ptr<SvxLanguageBox> mxLbCustomLang; + + std::unique_ptr<weld::Label> mxFtRow; + std::unique_ptr<weld::SpinButton> mxNfRow; + + std::unique_ptr<weld::RadioButton> mxRbFixed; + std::unique_ptr<weld::RadioButton> mxRbSeparated; + + std::unique_ptr<weld::CheckButton> mxCkbTab; + std::unique_ptr<weld::CheckButton> mxCkbSemicolon; + std::unique_ptr<weld::CheckButton> mxCkbComma; + std::unique_ptr<weld::CheckButton> mxCkbRemoveSpace; + std::unique_ptr<weld::CheckButton> mxCkbSpace; + std::unique_ptr<weld::CheckButton> mxCkbOther; + std::unique_ptr<weld::Entry> mxEdOther; + std::unique_ptr<weld::CheckButton> mxCkbAsOnce; + + std::unique_ptr<weld::Label> mxFtTextSep; + std::unique_ptr<weld::ComboBox> mxCbTextSep; + + std::unique_ptr<weld::CheckButton> mxCkbQuotedAsText; + std::unique_ptr<weld::CheckButton> mxCkbDetectNumber; + std::unique_ptr<weld::CheckButton> mxCkbSkipEmptyCells; + + std::unique_ptr<weld::Label> mxFtType; + std::unique_ptr<weld::ComboBox> mxLbType; + std::unique_ptr<weld::Label> mxAltTitle; + + std::unique_ptr<ScCsvTableBox> mxTableBox; + +public: + ScImportAsciiDlg( + weld::Window* pParent, const OUString& aDatName, + SvStream* pInStream, ScImportAsciiCall eCall ); + virtual ~ScImportAsciiDlg() override; + + void GetOptions( ScAsciiOptions& rOpt ); + void SaveParameters(); + +private: + /** Sets the selected char set data to meCharSet and mbCharSetSystem. */ + void SetSelectedCharSet(); + /** Set separators in ui from maFieldSeparators */ + void SetSeparators(); + /** Returns all separator characters in a string. */ + OUString GetSeparators() const; + + /** Enables or disables all separator checkboxes and edit fields. */ + void SetupSeparatorCtrls(); + + bool GetLine( sal_uLong nLine, OUString &rText, sal_Unicode& rcDetectSep ); + void UpdateVertical(); + inline bool Seek( sal_uLong nPos ); // synced to and from mnStreamPos + + DECL_LINK( CharSetHdl, weld::ComboBox&, void ); + DECL_LINK( FirstRowHdl, weld::SpinButton&, void ); + DECL_LINK( RbSepFixHdl, weld::Button&, void ); + DECL_LINK( SeparatorEditHdl, weld::Entry&, void ); + DECL_LINK( SeparatorClickHdl, weld::Button&, void ); + DECL_LINK( SeparatorComboBoxHdl, weld::ComboBox&, void ); + void SeparatorHdl(const weld::Widget*); + DECL_LINK( LbColTypeHdl, weld::ComboBox&, void ); + DECL_LINK( UpdateTextHdl, ScCsvTableBox&, void ); + DECL_LINK( ColTypeHdl, ScCsvTableBox&, void ); +}; + +inline bool ScImportAsciiDlg::Seek(sal_uLong nPos) +{ + bool bSuccess = true; + if (nPos != mnStreamPos && mpDatStream) + { + if (mpDatStream->Seek( nPos ) != nPos) + bSuccess = false; + else + mnStreamPos = nPos; + } + return bSuccess; +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/scuiautofmt.hxx b/sc/source/ui/inc/scuiautofmt.hxx new file mode 100644 index 000000000..5fee72451 --- /dev/null +++ b/sc/source/ui/inc/scuiautofmt.hxx @@ -0,0 +1,79 @@ +/* -*- 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_SC_SOURCE_UI_INC_SCUIAUTOFMT_HXX +#define INCLUDED_SC_SOURCE_UI_INC_SCUIAUTOFMT_HXX + +#include <vcl/customweld.hxx> +#include "autofmt.hxx" + +class ScAutoFormatDlg : public weld::GenericDialogController +{ +public: + ScAutoFormatDlg(weld::Window* pParent, + ScAutoFormat* pAutoFormat, + const ScAutoFormatData* pSelFormatData, + const ScViewData *pViewData); + virtual ~ScAutoFormatDlg() override; + + sal_uInt16 GetIndex() const { return nIndex; } + OUString GetCurrFormatName(); + +private: + OUString aStrTitle; + OUString aStrLabel; + OUString aStrClose; + OUString aStrDelMsg; + OUString aStrRename; + + ScAutoFormat* pFormat; + const ScAutoFormatData* pSelFmtData; + sal_uInt16 nIndex; + bool bCoreDataChanged; + bool bFmtInserted; + + ScAutoFmtPreview m_aWndPreview; + std::unique_ptr<weld::TreeView> m_xLbFormat; + std::unique_ptr<weld::Button> m_xBtnOk; + std::unique_ptr<weld::Button> m_xBtnCancel; + std::unique_ptr<weld::Button> m_xBtnAdd; + std::unique_ptr<weld::Button> m_xBtnRemove; + std::unique_ptr<weld::Button> m_xBtnRename; + std::unique_ptr<weld::CheckButton> m_xBtnNumFormat; + std::unique_ptr<weld::CheckButton> m_xBtnBorder; + std::unique_ptr<weld::CheckButton> m_xBtnFont; + std::unique_ptr<weld::CheckButton> m_xBtnPattern; + std::unique_ptr<weld::CheckButton> m_xBtnAlignment; + std::unique_ptr<weld::CheckButton> m_xBtnAdjust; + std::unique_ptr<weld::CustomWeld> m_xWndPreview; + + void Init (); + void UpdateChecks (); + + DECL_LINK( CheckHdl, weld::ToggleButton&, void ); + DECL_LINK( AddHdl, weld::Button&, void ); + DECL_LINK( RemoveHdl, weld::Button&, void ); + DECL_LINK( SelFmtHdl, weld::TreeView&, void ); + DECL_LINK( CloseHdl, weld::Button&, void ); + DECL_LINK( DblClkHdl, weld::TreeView&, bool ); + DECL_LINK( RenameHdl, weld::Button&, void ); + +}; +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/scuiimoptdlg.hxx b/sc/source/ui/inc/scuiimoptdlg.hxx new file mode 100644 index 000000000..27d0db36b --- /dev/null +++ b/sc/source/ui/inc/scuiimoptdlg.hxx @@ -0,0 +1,78 @@ +/* -*- 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_SC_SOURCE_UI_INC_SCUIIMOPTDLG_HXX +#define INCLUDED_SC_SOURCE_UI_INC_SCUIIMOPTDLG_HXX + +#include <vcl/weld.hxx> + +class ScDelimiterTable; +class ScImportOptions; +class SvxTextEncodingBox; +class SvxTextEncodingTreeView; + +class ScImportOptionsDlg : public weld::GenericDialogController +{ +public: + ScImportOptionsDlg(weld::Window* pParent, + bool bAscii, + const ScImportOptions* pOptions, + const OUString* pStrTitle, + bool bMultiByte, + bool bOnlyDbtoolsEncodings, + bool bImport); + + virtual ~ScImportOptionsDlg() override; + + void GetImportOptions( ScImportOptions& rOptions ) const; + void SaveImportOptions() const; + +private: + std::unique_ptr<ScDelimiterTable> pFieldSepTab; + std::unique_ptr<ScDelimiterTable> pTextSepTab; + + bool m_bIsAsciiImport; + + std::unique_ptr<weld::Frame> m_xFieldFrame; + std::unique_ptr<weld::Label> m_xFtCharset; + std::unique_ptr<weld::Widget> m_xEncGrid; + std::unique_ptr<weld::Label> m_xFtFieldSep; + std::unique_ptr<weld::ComboBox> m_xEdFieldSep; + std::unique_ptr<weld::Label> m_xFtTextSep; + std::unique_ptr<weld::ComboBox> m_xEdTextSep; + std::unique_ptr<weld::CheckButton> m_xCbShown; + std::unique_ptr<weld::CheckButton> m_xCbFormulas; + std::unique_ptr<weld::CheckButton> m_xCbQuoteAll; + std::unique_ptr<weld::CheckButton> m_xCbFixed; + std::unique_ptr<weld::Button> m_xBtnOk; + std::unique_ptr<SvxTextEncodingBox> m_xLbCharset; + std::unique_ptr<SvxTextEncodingTreeView> m_xTvCharset; + +private: + sal_uInt16 GetCodeFromCombo( const weld::ComboBox& rEd ) const; + void FillFromTextEncodingTable(bool bExcludeImportSubsets, sal_uInt32 nExcludeInfoFlags = 0); + void FillFromDbTextEncodingMap(bool bExcludeImportSubsets, sal_uInt32 nExcludeInfoFlags = 0); + + DECL_LINK(FixedWidthHdl, weld::ToggleButton&, void); + DECL_LINK(DoubleClickHdl, weld::TreeView&, bool); +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/scuitphfedit.hxx b/sc/source/ui/inc/scuitphfedit.hxx new file mode 100644 index 000000000..b0f0d32c4 --- /dev/null +++ b/sc/source/ui/inc/scuitphfedit.hxx @@ -0,0 +1,146 @@ +/* -*- 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_SC_SOURCE_UI_INC_SCUITPHFEDIT_HXX +#define INCLUDED_SC_SOURCE_UI_INC_SCUITPHFEDIT_HXX + +#include "tphfedit.hxx" +#include <vcl/customweld.hxx> +#include <vcl/weld.hxx> + +enum ScHFEntryId +{ + eNoneEntry , + ePageEntry , + ePagesEntry , + eSheetEntry , + eConfidentialEntry , + eFileNamePageEntry , + eExtFileNameEntry , + ePageSheetEntry , + ePageFileNameEntry , + ePageExtFileNameEntry , + eUserNameEntry , + eCreatedByEntry , + eEntryCount +}; + +class EditTextObject; +class EditEngine; + +class ScHFEditPage : public SfxTabPage +{ +public: + virtual bool FillItemSet ( SfxItemSet* rCoreSet ) override; + virtual void Reset ( const SfxItemSet* rCoreSet ) override; + + void SetNumType(SvxNumType eNumType); + void ClearTextAreas(); + +protected: + ScHFEditPage( weld::Container* pPage, weld::DialogController* pController, + const SfxItemSet& rCoreSet, + sal_uInt16 nWhich, + bool bHeader ); + virtual ~ScHFEditPage() override; + +private: + sal_uInt16 nWhich; + bool m_bDropDownActive; + sal_Int64 m_nTimeToggled; + + std::unique_ptr<weld::Label> m_xFtDefinedHF; + std::unique_ptr<weld::ComboBox> m_xLbDefined; + std::unique_ptr<weld::Label> m_xFtCustomHF; + std::unique_ptr<weld::Button> m_xBtnText; + std::unique_ptr<weld::MenuButton> m_xBtnFile; + std::unique_ptr<weld::Button> m_xBtnTable; + std::unique_ptr<weld::Button> m_xBtnPage; + std::unique_ptr<weld::Button> m_xBtnLastPage; + std::unique_ptr<weld::Button> m_xBtnDate; + std::unique_ptr<weld::Button> m_xBtnTime; + + std::unique_ptr<weld::Label> m_xFtConfidential; + std::unique_ptr<weld::Label> m_xFtPage; + std::unique_ptr<weld::Label> m_xFtOfQuestion; + std::unique_ptr<weld::Label> m_xFtOf; + std::unique_ptr<weld::Label> m_xFtNone; + std::unique_ptr<weld::Label> m_xFtCreatedBy; + std::unique_ptr<weld::Label> m_xFtCustomized; + + std::unique_ptr<weld::Widget> m_xLeft; + std::unique_ptr<weld::Widget> m_xRight; + + std::unique_ptr<ScEditWindow> m_xWndLeft; + std::unique_ptr<ScEditWindow> m_xWndCenter; + std::unique_ptr<ScEditWindow> m_xWndRight; + std::unique_ptr<weld::CustomWeld> m_xWndLeftWnd; + std::unique_ptr<weld::CustomWeld> m_xWndCenterWnd; + std::unique_ptr<weld::CustomWeld> m_xWndRightWnd; + + ScEditWindow * m_pEditFocus; ///one of m_pWndLeft, m_pWndCenter, m_pWndRight + + DECL_LINK( ObjectSelectHdl, ScEditWindow&, void ); + +private: + void InitPreDefinedList(); + void ProcessDefinedListSel(ScHFEntryId eSel, bool bTravelling); + void InsertToDefinedList(); + void RemoveFromDefinedList(); + void SetSelectDefinedList(); + bool IsPageEntry(EditEngine*pEngine, const EditTextObject* pTextObj); + static bool IsDateEntry(const EditTextObject* pTextObj); + static bool IsExtFileNameEntry(const EditTextObject* pTextObj); + DECL_LINK( ListHdl_Impl, weld::ComboBox&, void); + DECL_LINK( ListToggleHdl_Impl, weld::ComboBox&, void); + DECL_LINK( ClickHdl, weld::Button&, void ); + DECL_LINK( MenuHdl, const OString&, void ); +}; + +class ScRightHeaderEditPage : public ScHFEditPage +{ +public: + static std::unique_ptr<SfxTabPage> Create( weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rCoreSet ); + ScRightHeaderEditPage( weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet ); +}; + +class ScLeftHeaderEditPage : public ScHFEditPage +{ +public: + static std::unique_ptr<SfxTabPage> Create( weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rCoreSet ); + ScLeftHeaderEditPage( weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet ); +}; + +class ScRightFooterEditPage : public ScHFEditPage +{ +public: + static std::unique_ptr<SfxTabPage> Create( weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rCoreSet ); + ScRightFooterEditPage( weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet ); +}; + +class ScLeftFooterEditPage : public ScHFEditPage +{ +public: + static std::unique_ptr<SfxTabPage> Create( weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rCoreSet ); + ScLeftFooterEditPage( weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet ); +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/searchresults.hxx b/sc/source/ui/inc/searchresults.hxx new file mode 100644 index 000000000..cf48fb239 --- /dev/null +++ b/sc/source/ui/inc/searchresults.hxx @@ -0,0 +1,60 @@ +/* -*- 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_SC_SOURCE_UI_INC_SEARCHRESULTS_HXX +#define INCLUDED_SC_SOURCE_UI_INC_SEARCHRESULTS_HXX + +#include <vcl/weld.hxx> +#include <sfx2/basedlgs.hxx> +#include <sfx2/childwin.hxx> + +class ScDocument; +class ScRangeList; + +namespace sc { + +class SearchResultsDlg : public SfxDialogController +{ + OUString aSkipped; + SfxBindings* mpBindings; + ScDocument* mpDoc; + bool mbSorted; + std::unique_ptr<weld::TreeView> mxList; + std::unique_ptr<weld::Label> mxSearchResults; + std::unique_ptr<weld::CheckButton> mxShowDialog; + + DECL_LINK(ListSelectHdl, weld::TreeView&, void); + DECL_LINK(HeaderBarClick, int, void); + DECL_STATIC_LINK(SearchResultsDlg, OnShowToggled, weld::ToggleButton&, void); +public: + SearchResultsDlg(SfxBindings* _pBindings, weld::Window* pParent); + virtual ~SearchResultsDlg() override; + + virtual void Close() override; + + void FillResults( ScDocument* pDoc, const ScRangeList& rMatchedRanges, bool bCellNotes ); +}; + +class SearchResultsDlgWrapper : public SfxChildWindow +{ + std::shared_ptr<SearchResultsDlg> m_xDialog; +public: + SearchResultsDlgWrapper( + vcl::Window* _pParent, sal_uInt16 nId, SfxBindings* pBindings, SfxChildWinInfo* pInfo ); + + virtual ~SearchResultsDlgWrapper() override; + + SFX_DECL_CHILDWINDOW_WITHID(SearchResultsDlgWrapper); +}; + +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/select.hxx b/sc/source/ui/inc/select.hxx new file mode 100644 index 000000000..d1da97b13 --- /dev/null +++ b/sc/source/ui/inc/select.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_SC_SOURCE_UI_INC_SELECT_HXX +#define INCLUDED_SC_SOURCE_UI_INC_SELECT_HXX + +#include <vcl/seleng.hxx> + +#include "viewdata.hxx" + +class ScTabView; + +class ScViewSelectionEngine : public SelectionEngine +{ +private: + ScSplitPos eWhich; +public: + ScViewSelectionEngine( vcl::Window* pWindow, ScTabView* pView, + ScSplitPos eSplitPos ); + + ScSplitPos GetWhich() const { return eWhich; } + void SetWhich(ScSplitPos eNew) { eWhich = eNew; } +}; + +class ScViewFunctionSet : public FunctionSet // View (Gridwin / keyboard) +{ +private: + ScViewData* pViewData; + ScViewSelectionEngine* pEngine; + + bool bAnchor; + bool bStarted; + ScAddress aAnchorPos; + + ScSplitPos GetWhich() const; + + sal_uLong CalcUpdateInterval( const Size& rWinSize, const Point& rEffPos, + bool bLeftScroll, bool bTopScroll, bool bRightScroll, bool bBottomScroll ); + +public: + ScViewFunctionSet( ScViewData* pNewViewData ); + + void SetSelectionEngine( ScViewSelectionEngine* pSelEngine ); + + void SetAnchor( SCCOL nPosX, SCROW nPosY ); + void SetAnchorFlag( bool bSet ); + + virtual void BeginDrag() override; + virtual void CreateAnchor() override; + virtual void DestroyAnchor() override; + virtual void SetCursorAtPoint( const Point& rPointPixel, bool bDontSelectAtCursor = false ) override; + virtual bool IsSelectionAtPoint( const Point& rPointPixel ) override; + virtual void DeselectAtPoint( const Point& rPointPixel ) override; + virtual void DeselectAll() override; + + bool SetCursorAtCell( SCCOL nPosX, SCROW nPosY, bool bScroll ); +}; + +class ScHeaderFunctionSet : public FunctionSet // Column / row headers +{ +private: + ScViewData* pViewData; + bool bColumn; // Col- / Rowbar + ScSplitPos eWhich; + + bool bAnchor; + SCCOLROW nCursorPos; + +public: + ScHeaderFunctionSet( ScViewData* pNewViewData ); + + void SetColumn( bool bSet ); + void SetWhich( ScSplitPos eNew ); + + virtual void BeginDrag() override; + virtual void CreateAnchor() override; + virtual void DestroyAnchor() override; + virtual void SetCursorAtPoint( const Point& rPointPixel, bool bDontSelectAtCursor = false ) override; + virtual bool IsSelectionAtPoint( const Point& rPointPixel ) override; + virtual void DeselectAtPoint( const Point& rPointPixel ) override; + virtual void DeselectAll() override; + + void SetAnchorFlag(bool bSet) { bAnchor = bSet; } +}; + +class ScHeaderSelectionEngine : public SelectionEngine +{ +public: + ScHeaderSelectionEngine( vcl::Window* pWindow, ScHeaderFunctionSet* pFuncSet ); +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/selectionstate.hxx b/sc/source/ui/inc/selectionstate.hxx new file mode 100644 index 000000000..0d7505260 --- /dev/null +++ b/sc/source/ui/inc/selectionstate.hxx @@ -0,0 +1,58 @@ +/* -*- 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_SC_SOURCE_UI_INC_SELECTIONSTATE_HXX +#define INCLUDED_SC_SOURCE_UI_INC_SELECTIONSTATE_HXX + +#include <editeng/editdata.hxx> +#include <address.hxx> + +/** Enumerates all possible types of selections in a Calc document. */ +enum ScSelectionType +{ + SC_SELECTTYPE_NONE, /// No selection, simple cell cursor. + SC_SELECTTYPE_SHEET, /// Single cell, cell range, or multi range selection. + SC_SELECTTYPE_EDITCELL, /// Cell in edit mode (with or without selection). +}; + +class ScViewData; + +/** Contains all available data about any possible selection in a Calc document. */ +class ScSelectionState +{ +public: + explicit ScSelectionState( ScViewData& rViewData ); + + /** Returns the type of the selection this object contains. */ + ScSelectionType GetSelectionType() const { return meType; } + + /** Returns the position of the cell cursor. */ + const ScAddress& GetCellCursor() const { return maCursor; } + /** Returns the edit engine selection. */ + const ESelection& GetEditSelection() const { return maEditSel; } + +private: + ScSelectionType meType; /// Type of the selection. + ScAddress maCursor; /// Cell cursor position. + ESelection maEditSel; /// Selection in edit mode. +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/seltrans.hxx b/sc/source/ui/inc/seltrans.hxx new file mode 100644 index 000000000..83adb2c11 --- /dev/null +++ b/sc/source/ui/inc/seltrans.hxx @@ -0,0 +1,75 @@ +/* -*- 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_SC_SOURCE_UI_INC_SELTRANS_HXX +#define INCLUDED_SC_SOURCE_UI_INC_SELTRANS_HXX + +#include <vcl/transfer.hxx> +#include <rtl/ref.hxx> + +class ScTabView; +class ScTransferObj; +class ScDrawTransferObj; + +enum ScSelectionTransferMode +{ + SC_SELTRANS_INVALID, + SC_SELTRANS_CELL, + SC_SELTRANS_CELLS, + SC_SELTRANS_DRAW_BITMAP, + SC_SELTRANS_DRAW_GRAPHIC, + SC_SELTRANS_DRAW_BOOKMARK, + SC_SELTRANS_DRAW_OLE, + SC_SELTRANS_DRAW_OTHER +}; + +class ScSelectionTransferObj : public TransferableHelper +{ +private: + ScTabView* pView; + ScSelectionTransferMode eMode; + rtl::Reference<ScTransferObj> mxCellData; + rtl::Reference<ScDrawTransferObj> mxDrawData; + + ScSelectionTransferObj( ScTabView* pSource, ScSelectionTransferMode eNewMode ); + void CreateCellData(); + void CreateDrawData(); + +public: + // creates an object if the view has a valid selection, + // returns NULL otherwise + static ScSelectionTransferObj* CreateFromView( ScTabView* pSource ); + + virtual ~ScSelectionTransferObj() override; + + void ForgetView(); + ScTabView* GetView() const { return pView; } + + ScTransferObj* GetCellData(); + ScDrawTransferObj* GetDrawData(); + + virtual void AddSupportedFormats() override; + virtual bool GetData( const css::datatransfer::DataFlavor& rFlavor, const OUString& rDestDoc ) override; + virtual void ObjectReleased() override; + virtual sal_Bool SAL_CALL isComplex() override; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/servobj.hxx b/sc/source/ui/inc/servobj.hxx new file mode 100644 index 000000000..d6b664e1c --- /dev/null +++ b/sc/source/ui/inc/servobj.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_SC_SOURCE_UI_INC_SERVOBJ_HXX +#define INCLUDED_SC_SOURCE_UI_INC_SERVOBJ_HXX + +#include <svl/lstner.hxx> +#include <svl/listener.hxx> +#include <sfx2/linksrc.hxx> +#include <address.hxx> +#include <svl/SfxBroadcaster.hxx> + +class ScDocShell; +class ScServerObject; + +class ScServerObjectSvtListenerForwarder : public SvtListener +{ + ScServerObject* pObj; + SfxBroadcaster aBroadcaster; +public: + ScServerObjectSvtListenerForwarder( ScServerObject* pObjP); + virtual ~ScServerObjectSvtListenerForwarder() override; + virtual void Notify( const SfxHint& rHint ) override; +}; + +class ScServerObject : public ::sfx2::SvLinkSource, public SfxListener +{ +private: + ScServerObjectSvtListenerForwarder aForwarder; + ScDocShell* pDocSh; + ScRange aRange; + OUString aItemStr; + bool bRefreshListener; + + void Clear(); + +public: + ScServerObject( ScDocShell* pShell, const OUString& rItem ); + virtual ~ScServerObject() override; + + virtual bool GetData( css::uno::Any & rData /*out param*/, + const OUString & rMimeType, + bool bSynchron = false ) override; + + virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override; + void EndListeningAll(); +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/sharedocdlg.hxx b/sc/source/ui/inc/sharedocdlg.hxx new file mode 100644 index 000000000..e49d4c32a --- /dev/null +++ b/sc/source/ui/inc/sharedocdlg.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_SC_SOURCE_UI_INC_SHAREDOCDLG_HXX +#define INCLUDED_SC_SOURCE_UI_INC_SHAREDOCDLG_HXX + +#include <vcl/weld.hxx> +#include <scdllapi.h> + +class ScViewData; +class ScDocShell; + + +class ScShareDocumentDlg : public weld::GenericDialogController +{ +private: + OUString m_aStrNoUserData; + OUString m_aStrUnknownUser; + OUString m_aStrExclusiveAccess; + + ScDocShell* mpDocShell; + + std::unique_ptr<weld::CheckButton> m_xCbShare; + std::unique_ptr<weld::Label> m_xFtWarning; + std::unique_ptr<weld::TreeView> m_xLbUsers; + + DECL_LINK(ToggleHandle, weld::ToggleButton&, void); + DECL_LINK(SizeAllocated, const Size&, void); + +public: + ScShareDocumentDlg(weld::Window* pParent, const ScViewData* pViewData); + virtual ~ScShareDocumentDlg() override; + + bool IsShareDocumentChecked() const; + void UpdateView(); +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/shtabdlg.hxx b/sc/source/ui/inc/shtabdlg.hxx new file mode 100644 index 000000000..0143ad73a --- /dev/null +++ b/sc/source/ui/inc/shtabdlg.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_SC_SOURCE_UI_INC_SHTABDLG_HXX +#define INCLUDED_SC_SOURCE_UI_INC_SHTABDLG_HXX + +#include <vcl/weld.hxx> + +class ScShowTabDlg : public weld::GenericDialogController +{ +private: + std::unique_ptr<weld::Frame> m_xFrame; + std::unique_ptr<weld::TreeView> m_xLb; + + DECL_LINK( DblClkHdl, weld::TreeView&, bool ); + +public: + ScShowTabDlg(weld::Window* pParent); + virtual ~ScShowTabDlg() override; + + /** Sets dialog title, fixed text for listbox and help IDs. */ + void SetDescription( + const OUString& rTitle, const OUString& rFixedText, + const OString& nDlgHelpId, const OString& nLbHelpId ); + + /** Inserts a string into the weld::TreeView. */ + void Insert( const OUString& rString, bool bSelected ); + + std::vector<sal_Int32> GetSelectedRows() const; + OUString GetEntry(sal_Int32 nPos) const; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/simpref.hxx b/sc/source/ui/inc/simpref.hxx new file mode 100644 index 000000000..ce62242f6 --- /dev/null +++ b/sc/source/ui/inc/simpref.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_SC_SOURCE_UI_INC_SIMPREF_HXX +#define INCLUDED_SC_SOURCE_UI_INC_SIMPREF_HXX + +#include "anyrefdg.hxx" + +class ScDocument; + +class ScSimpleRefDlg: public ScAnyRefDlgController +{ +private: + Link<const OUString*,void> aCloseHdl; + Link<const OUString&,void> aDoneHdl; + Link<const OUString&,void> aAbortedHdl; + Link<const OUString&,void> aChangeHdl; + + ScRange theCurArea; + bool bCloseFlag; + bool bAutoReOpen; + bool bCloseOnButtonUp; + bool bSingleCell; + bool bMultiSelection; + + std::unique_ptr<weld::Label> m_xFtAssign; + std::unique_ptr<formula::RefEdit> m_xEdAssign; + std::unique_ptr<formula::RefButton> m_xRbAssign; + std::unique_ptr<weld::Button> m_xBtnOk; + std::unique_ptr<weld::Button> m_xBtnCancel; + + void Init(); + + DECL_LINK( CancelBtnHdl, weld::Button&, void ); + DECL_LINK( OkBtnHdl, weld::Button&, void ); + +protected: + + virtual void RefInputDone( bool bForced = false ) override; + +public: + ScSimpleRefDlg( SfxBindings* pB, SfxChildWindow* pCW, weld::Window* pParent); + virtual ~ScSimpleRefDlg() override; + + virtual void SetReference( const ScRange& rRef, ScDocument& rDoc ) override; + + virtual bool IsRefInputMode() const override; + virtual void SetActive() override; + virtual void Close() override; + + void StartRefInput(); + + void SetRefString(const OUString &rStr); + virtual void FillInfo(SfxChildWinInfo&) const override; + + void SetCloseHdl( const Link<const OUString*,void>& rLink ); + void SetUnoLinks( const Link<const OUString&,void>& rDone, const Link<const OUString&,void>& rAbort, + const Link<const OUString&,void>& rChange ); + + void SetFlags( bool bSetCloseOnButtonUp, bool bSetSingleCell, bool bSetMultiSelection ); +}; + +#endif // INCLUDED_SC_SOURCE_UI_INC_SIMPREF_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/sizedev.hxx b/sc/source/ui/inc/sizedev.hxx new file mode 100644 index 000000000..95bfac3a4 --- /dev/null +++ b/sc/source/ui/inc/sizedev.hxx @@ -0,0 +1,48 @@ +/* -*- 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_SC_SOURCE_UI_INC_SIZEDEV_HXX +#define INCLUDED_SC_SOURCE_UI_INC_SIZEDEV_HXX + +#include <vcl/mapmod.hxx> + +class OutputDevice; +class ScDocShell; + +class ScSizeDeviceProvider +{ + VclPtr<OutputDevice> pDevice; + bool bOwner; + double nPPTX; + double nPPTY; + MapMode aOldMapMode; + +public: + ScSizeDeviceProvider( ScDocShell* pDocSh ); + ~ScSizeDeviceProvider(); + + OutputDevice* GetDevice() const { return pDevice.get(); } + double GetPPTX() const { return nPPTX; } + double GetPPTY() const { return nPPTY; } + bool IsPrinter() const { return !bOwner; } +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/solveroptions.hxx b/sc/source/ui/inc/solveroptions.hxx new file mode 100644 index 000000000..56f450836 --- /dev/null +++ b/sc/source/ui/inc/solveroptions.hxx @@ -0,0 +1,128 @@ +/* -*- 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_SC_SOURCE_UI_INC_SOLVEROPTIONS_HXX +#define INCLUDED_SC_SOURCE_UI_INC_SOLVEROPTIONS_HXX + +#include <vcl/weld.hxx> +#include <com/sun/star/uno/Sequence.hxx> + +namespace com::sun::star { + namespace beans { struct PropertyValue; } +} + +class ScSolverOptionsString +{ + bool mbIsDouble; + double mfDoubleValue; + sal_Int32 mnIntValue; + OUString msStr; + +public: + explicit ScSolverOptionsString(const OUString& rStr) + : mbIsDouble(false) + , mfDoubleValue(0.0) + , mnIntValue(0) + , msStr(rStr) + { + } + + bool IsDouble() const { return mbIsDouble; } + double GetDoubleValue() const { return mfDoubleValue; } + sal_Int32 GetIntValue() const { return mnIntValue; } + const OUString& GetText() const { return msStr; } + + void SetDoubleValue( double fNew ) { mbIsDouble = true; mfDoubleValue = fNew; } + void SetIntValue( sal_Int32 nNew ) { mbIsDouble = false; mnIntValue = nNew; } +}; + +class ScSolverIntegerDialog; +class ScSolverValueDialog; + +class ScSolverOptionsDialog : public weld::GenericDialogController +{ + css::uno::Sequence<OUString> maImplNames; + OUString maEngine; + css::uno::Sequence<css::beans::PropertyValue> maProperties; + + std::vector<std::unique_ptr<ScSolverOptionsString>> m_aOptions; + + std::unique_ptr<weld::ComboBox> m_xLbEngine; + std::unique_ptr<weld::TreeView> m_xLbSettings; + std::unique_ptr<weld::Button> m_xBtnEdit; + + std::shared_ptr<ScSolverIntegerDialog> m_xIntDialog; + std::shared_ptr<ScSolverValueDialog> m_xValDialog; + + DECL_LINK( EngineSelectHdl, weld::ComboBox&, void ); + DECL_LINK( SettingsSelHdl, weld::TreeView&, void ); + DECL_LINK( SettingsDoubleClickHdl, weld::TreeView&, bool ); + DECL_LINK( ButtonHdl, weld::Button&, void ); + + void ReadFromComponent(); + void FillListBox(); + void EditOption(); + +public: + ScSolverOptionsDialog( weld::Window* pParent, + const css::uno::Sequence<OUString>& rImplNames, + const css::uno::Sequence<OUString>& rDescriptions, + const OUString& rEngine, + const css::uno::Sequence<css::beans::PropertyValue>& rProperties ); + virtual ~ScSolverOptionsDialog() override; + + // already updated in selection handler + const OUString& GetEngine() const { return maEngine; } + const css::uno::Sequence<css::beans::PropertyValue>& GetProperties(); +}; + +class ScSolverIntegerDialog : public weld::GenericDialogController +{ + std::unique_ptr<weld::Frame> m_xFrame; + std::unique_ptr<weld::SpinButton> m_xNfValue; + +public: + ScSolverIntegerDialog(weld::Window* pParent); + virtual ~ScSolverIntegerDialog() override; + + void SetOptionName( const OUString& rName ); + void SetValue( sal_Int32 nValue ); + void SetMax( sal_Int32 nValue ); + sal_Int32 GetValue() const; +}; + +class ScSolverValueDialog : public weld::GenericDialogController +{ + std::unique_ptr<weld::Frame> m_xFrame; + std::unique_ptr<weld::Entry> m_xEdValue; + double m_fMaxValue; + +public: + ScSolverValueDialog(weld::Window* pParent); + virtual ~ScSolverValueDialog() override; + + void SetOptionName( const OUString& rName ); + void SetValue( double fValue ); + void SetMax( double fValue ); + double GetValue() const; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/solverutil.hxx b/sc/source/ui/inc/solverutil.hxx new file mode 100644 index 000000000..fd6a8f26b --- /dev/null +++ b/sc/source/ui/inc/solverutil.hxx @@ -0,0 +1,42 @@ +/* -*- 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_SC_SOURCE_UI_INC_SOLVERUTIL_HXX +#define INCLUDED_SC_SOURCE_UI_INC_SOLVERUTIL_HXX + +#include <com/sun/star/uno/Reference.hxx> +#include <com/sun/star/uno/Sequence.hxx> + +namespace com::sun::star { + namespace beans { struct PropertyValue; } + namespace sheet { class XSolver; } +} + +class ScSolverUtil +{ +public: + static void GetImplementations( css::uno::Sequence<OUString>& rImplNames, + css::uno::Sequence<OUString>& rDescriptions ); + static css::uno::Reference<css::sheet::XSolver> GetSolver( const OUString& rImplName ); + static css::uno::Sequence<css::beans::PropertyValue> GetDefaults( const OUString& rImplName ); +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/solvrdlg.hxx b/sc/source/ui/inc/solvrdlg.hxx new file mode 100644 index 000000000..66a031fbd --- /dev/null +++ b/sc/source/ui/inc/solvrdlg.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_SC_SOURCE_UI_INC_SOLVRDLG_HXX +#define INCLUDED_SC_SOURCE_UI_INC_SOLVRDLG_HXX + +#include <address.hxx> +#include "anyrefdg.hxx" + +enum ScSolverErr + { + SOLVERR_NOFORMULA, + SOLVERR_INVALID_FORMULA, + SOLVERR_INVALID_VARIABLE, + SOLVERR_INVALID_TARGETVALUE + }; + +class ScSolverDlg : public ScAnyRefDlgController +{ +public: + ScSolverDlg( SfxBindings* pB, SfxChildWindow* pCW, weld::Window* pParent, + ScDocument* pDocument, + const ScAddress& aCursorPos ); + virtual ~ScSolverDlg() override; + + virtual void SetReference( const ScRange& rRef, ScDocument& rDoc ) override; + virtual bool IsRefInputMode() const override; + virtual void SetActive() override; + virtual void Close() override; + +private: + ScAddress theFormulaCell; + ScAddress theVariableCell; + OUString theTargetValStr; + + ScDocument* pDoc; + const SCTAB nCurTab; + bool bDlgLostFocus; + const OUString errMsgInvalidVar; + const OUString errMsgInvalidForm; + const OUString errMsgNoFormula; + const OUString errMsgInvalidVal; + + formula::RefEdit* m_pEdActive; + + std::unique_ptr<weld::Label> m_xFtFormulaCell; + std::unique_ptr<formula::RefEdit> m_xEdFormulaCell; + std::unique_ptr<formula::RefButton> m_xRBFormulaCell; + + std::unique_ptr<weld::Entry> m_xEdTargetVal; + + std::unique_ptr<weld::Label> m_xFtVariableCell; + std::unique_ptr<formula::RefEdit> m_xEdVariableCell; + std::unique_ptr<formula::RefButton> m_xRBVariableCell; + + std::unique_ptr<weld::Button> m_xBtnOk; + std::unique_ptr<weld::Button> m_xBtnCancel; + + std::shared_ptr<weld::MessageDialog> m_xMessageBox; + + void Init(); + bool CheckTargetValue( const OUString& rStrVal ); + void RaiseError( ScSolverErr eError ); + + DECL_LINK( BtnHdl, weld::Button&, void ); + DECL_LINK( GetEditFocusHdl, formula::RefEdit&, void ); + DECL_LINK( LoseEditFocusHdl, formula::RefEdit&, void ); + + DECL_LINK( GetButtonFocusHdl, formula::RefButton&, void ); + DECL_LINK( LoseButtonFocusHdl, formula::RefButton&, void ); + + DECL_LINK( GetFocusHdl, weld::Widget&, void ); +}; + +#endif // INCLUDED_SC_SOURCE_UI_INC_SOLVRDLG_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/sortdlg.hxx b/sc/source/ui/inc/sortdlg.hxx new file mode 100644 index 000000000..c45143296 --- /dev/null +++ b/sc/source/ui/inc/sortdlg.hxx @@ -0,0 +1,55 @@ +/* -*- 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_SC_SOURCE_UI_INC_SORTDLG_HXX +#define INCLUDED_SC_SOURCE_UI_INC_SORTDLG_HXX + +#include <sfx2/tabdlg.hxx> +#include <vcl/weld.hxx> + +class ScSortDlg : public SfxTabDialogController +{ +public: + ScSortDlg(weld::Window* pParent, const SfxItemSet* pArgSet); + + void SetHeaders( bool bHeaders ) { bIsHeaders = bHeaders; } + void SetByRows ( bool bByRows ) { bIsByRows = bByRows; } + bool GetHeaders() const { return bIsHeaders; } + bool GetByRows () const { return bIsByRows; } + +private: + bool bIsHeaders; + bool bIsByRows; +}; + +class ScSortWarningDlg : public weld::GenericDialogController +{ +public: + ScSortWarningDlg(weld::Window* pParent, const OUString& rExtendText,const OUString& rCurrentText); + virtual ~ScSortWarningDlg() override; + DECL_LINK(BtnHdl, weld::Button&, void); +private: + std::unique_ptr<weld::Label> m_xFtText; + std::unique_ptr<weld::Button> m_xBtnExtSort; + std::unique_ptr<weld::Button> m_xBtnCurSort; +}; + +#endif // INCLUDED_SC_SOURCE_UI_INC_SORTDLG_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/sortkeydlg.hxx b/sc/source/ui/inc/sortkeydlg.hxx new file mode 100644 index 000000000..1ac699970 --- /dev/null +++ b/sc/source/ui/inc/sortkeydlg.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/. + */ + +#ifndef INCLUDED_SC_SOURCE_UI_INC_SORTKEYDLG_HXX +#define INCLUDED_SC_SOURCE_UI_INC_SORTKEYDLG_HXX + +#include <vector> +#include <memory> + +#include <vcl/weld.hxx> + +struct ScSortKeyItem +{ + std::unique_ptr<weld::Builder> m_xBuilder; + + std::unique_ptr<weld::Frame> m_xFrame; + std::unique_ptr<weld::ComboBox> m_xLbSort; + std::unique_ptr<weld::RadioButton> m_xBtnUp; + std::unique_ptr<weld::RadioButton> m_xBtnDown; + + ScSortKeyItem(weld::Container* pParent); + + void DisableField(); + void EnableField(); +}; + +typedef std::vector<std::unique_ptr<ScSortKeyItem> > ScSortKeyItems; + +class ScSortKeyWindow +{ +public: + ScSortKeyItems m_aSortKeyItems; +private: + weld::Container* m_pBox; + +public: + ScSortKeyWindow(weld::Container* pBox); + ~ScSortKeyWindow(); + + void AddSortKey( sal_uInt16 nItem ); +}; + +#endif // INCLUDED_SC_SOURCE_UI_INC_SORTKEYDLG_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/spelldialog.hxx b/sc/source/ui/inc/spelldialog.hxx new file mode 100644 index 000000000..655217bf8 --- /dev/null +++ b/sc/source/ui/inc/spelldialog.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_SC_SOURCE_UI_INC_SPELLDIALOG_HXX +#define INCLUDED_SC_SOURCE_UI_INC_SPELLDIALOG_HXX + +#include <memory> +#include <svx/SpellDialogChildWindow.hxx> +#include <document.hxx> + +class ScConversionEngineBase; +class ScSelectionState; +class ScTabViewShell; +class ScViewData; +class ScRangeList; + +/** Specialized spell check dialog child window for Calc. + + This derivation of the svx::SpellDialogChildWindow base class provides + Calc specific implementations of the virtual functions GetNextWrongSentence() + and ApplyChangedSentence(). + */ +class ScSpellDialogChildWindow : public svx::SpellDialogChildWindow +{ +public: + SFX_DECL_CHILDWINDOW_WITHID( ScSpellDialogChildWindow ); + + explicit ScSpellDialogChildWindow( vcl::Window* pParent, sal_uInt16 nId, + SfxBindings* pBindings, SfxChildWinInfo* pInfo ); + virtual ~ScSpellDialogChildWindow() override; + + /** This method makes the one from the base class public so that + it can be called from the view shell when one is created. + */ + void InvalidateSpellDialog(); + +protected: + /** Iterate over the sentences in all text shapes and stop at the + next sentence with spelling errors. While doing so the view + mode may be changed and text shapes are set into edit mode. + */ + virtual svx::SpellPortions GetNextWrongSentence( bool bRecheck ) override; + + /** This method is responsible for merging corrections made in the + spelling dialog back into the document. + */ + virtual void ApplyChangedSentence( const svx::SpellPortions& rChanged, bool bRecheck ) override; + virtual void GetFocus() override; + virtual void LoseFocus() override; + +private: + void Reset(); + void Init(); + + bool IsSelectionChanged(); + +private: + typedef ::std::unique_ptr< ScConversionEngineBase > ScConvEnginePtr; + typedef ::std::unique_ptr< ScSelectionState > ScSelectionStatePtr; + + ScConvEnginePtr mxEngine; + ScDocumentUniquePtr mxUndoDoc; + ScDocumentUniquePtr mxRedoDoc; + ScSelectionStatePtr mxOldSel; /// For cursor position in selection + tools::SvRef< ScRangeList > + mxOldRangeList; /// Original selection range for comparison. + ScTabViewShell* mpViewShell; + ScViewData* mpViewData; + ScDocShell* mpDocShell; + ScDocument* mpDoc; + bool mbNeedNextObj; + bool mbOldIdleEnabled; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/spelleng.hxx b/sc/source/ui/inc/spelleng.hxx new file mode 100644 index 000000000..48dbb826b --- /dev/null +++ b/sc/source/ui/inc/spelleng.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_SC_SOURCE_UI_INC_SPELLENG_HXX +#define INCLUDED_SC_SOURCE_UI_INC_SPELLENG_HXX + +#include <editutil.hxx> +#include "selectionstate.hxx" +#include "spellparam.hxx" + +class ScViewData; +class ScDocShell; +class ScDocument; +class SfxItemPool; + +namespace weld { class Window; } + +/** Base class for special type of edit engines, i.e. for spell checker and text conversion. */ +class ScConversionEngineBase : public ScEditEngineDefaulter +{ +public: + explicit ScConversionEngineBase( + SfxItemPool* pEnginePool, ScViewData& rViewData, + ScDocument* pUndoDoc, ScDocument* pRedoDoc ); + + virtual ~ScConversionEngineBase() override; + + /** Derived classes implement to convert all cells in the selection or sheet. */ + virtual void ConvertAll( EditView& rEditView ) = 0; + + /** Returns true, if at least one cell has been modified. */ + bool IsAnyModified() const { return mbIsAnyModified; } + /** Returns true, if the entire document/selection has been finished. */ + bool IsFinished() const { return mbFinished; } + +protected: + /** Implementation of cell iteration. Finds a cell that needs conversion. + @return true = Current cell needs conversion (i.e. spelling error found). */ + bool FindNextConversionCell(); + /** Restores the initial cursor position. */ + void RestoreCursorPos(); + + /** Derived classes return, if the current text needs conversion (i.e. spelling error found). + @return true = Current edit text needs conversion. */ + virtual bool NeedsConversion() = 0; + + /** Derived classes may show a query box that asks whether to restart at top of the sheet. + @descr Default here is no dialog and restart always. + @return true = Restart at top, false = Stop the conversion. */ + virtual bool ShowTableWrapDialog(); + /** Derived classes may show a message box stating that the conversion is finished. + @descr Default here is no dialog. */ + virtual void ShowFinishDialog(); + +private: + /** Fills the edit engine from a document cell. */ + void FillFromCell( SCCOL nCol, SCROW nRow, SCTAB nTab ); + +protected: // for usage in derived classes + ScViewData& mrViewData; + ScDocShell& mrDocShell; + ScDocument& mrDoc; + +private: + ScSelectionState maSelState; /// Selection data of the document. + ScDocument* mpUndoDoc; /// Document stores all old cells for UNDO action. + ScDocument* mpRedoDoc; /// Document stores all new cells for REDO action. + LanguageType meCurrLang; /// Current cell language. + SCCOL mnStartCol; /// Initial column index. + SCROW mnStartRow; /// Initial row index. + SCTAB mnStartTab; /// Initial sheet index. + SCCOL mnCurrCol; /// Current column index. + SCROW mnCurrRow; /// Current row index. + bool mbIsAnyModified; /// true = At least one cell has been changed. + bool mbInitialState; /// true = Not searched for a cell yet. + bool mbWrappedInTable; /// true = Already restarted at top of the sheet. + bool mbFinished; /// true = Entire document/selection finished. +}; + +/** Edit engine for spell checking. */ +class ScSpellingEngine : public ScConversionEngineBase +{ +public: + explicit ScSpellingEngine( + SfxItemPool* pEnginePool, + ScViewData& rViewData, + ScDocument* pUndoDoc, + ScDocument* pRedoDoc, + css::uno::Reference< css::linguistic2::XSpellChecker1 > const & xSpeller ); + + /** Checks spelling of all cells in the selection or sheet. */ + virtual void ConvertAll( EditView& rEditView ) override; + +protected: + /** Callback from edit engine to check the next cell. */ + virtual bool SpellNextDocument() override; + + /** Returns true, if the current text contains a spelling error. */ + virtual bool NeedsConversion() override; + + /** Show a query box that asks whether to restart at top of the sheet. + @return true = Restart at top, false = Stop the conversion. */ + virtual bool ShowTableWrapDialog() override; + /** Show a message box stating that spell checking is finished. */ + virtual void ShowFinishDialog() override; + +private: + /** Returns the spelling dialog if it is open. */ + weld::Window* GetDialogParent(); +}; + +/** Edit engine for text conversion. */ +class ScTextConversionEngine : public ScConversionEngineBase +{ +public: + explicit ScTextConversionEngine( + SfxItemPool* pEnginePool, + ScViewData& rViewData, + const ScConversionParam& rConvParam, + ScDocument* pUndoDoc, + ScDocument* pRedoDoc ); + + /** Converts all cells in the selection or sheet according to set language. */ + virtual void ConvertAll( EditView& rEditView ) override; + +protected: + /** Callback from edit engine to convert the next cell. */ + virtual bool ConvertNextDocument() override; + + /** Returns true, if the current text contains text to convert. */ + virtual bool NeedsConversion() override; + +private: + ScConversionParam maConvParam; /// Conversion parameters. +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/spellparam.hxx b/sc/source/ui/inc/spellparam.hxx new file mode 100644 index 000000000..96660b983 --- /dev/null +++ b/sc/source/ui/inc/spellparam.hxx @@ -0,0 +1,74 @@ +/* -*- 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_SC_SOURCE_UI_INC_SPELLPARAM_HXX +#define INCLUDED_SC_SOURCE_UI_INC_SPELLPARAM_HXX + +#include <vcl/font.hxx> + +/** Specifiers for sheet conversion (functions iterating over the sheet and modifying cells). */ +enum ScConversionType +{ + SC_CONVERSION_SPELLCHECK, /// Spell checker. + SC_CONVERSION_HANGULHANJA, /// Hangul-Hanja converter. + SC_CONVERSION_CHINESE_TRANSL /// Chinese simplified/traditional converter. +}; + +/** Parameters for conversion. */ +class ScConversionParam +{ +public: + /** Constructs an empty parameter struct with the passed conversion type. */ + explicit ScConversionParam( ScConversionType eConvType ); + + /** Constructs parameter struct for text conversion without changing the language. */ + explicit ScConversionParam( + ScConversionType eConvType, + LanguageType eLang, + sal_Int32 nOptions, + bool bIsInteractive ); + + /** Constructs parameter struct for text conversion with language change. */ + explicit ScConversionParam( + ScConversionType eConvType, + LanguageType eSourceLang, + LanguageType eTargetLang, + const vcl::Font& rTargetFont, + sal_Int32 nOptions, + bool bIsInteractive ); + + ScConversionType GetType() const { return meConvType; } + LanguageType GetSourceLang() const { return meSourceLang; } + LanguageType GetTargetLang() const { return meTargetLang; } + const vcl::Font* GetTargetFont() const { return mbUseTargetFont ? &maTargetFont : nullptr; } + sal_Int32 GetOptions() const { return mnOptions; } + bool IsInteractive() const { return mbIsInteractive; } + +private: + ScConversionType meConvType; /// Type of the conversion. + LanguageType meSourceLang; /// Source language for conversion. + LanguageType meTargetLang; /// Target language for conversion. + vcl::Font maTargetFont; /// Target font to be used if language has to be changed. + sal_Int32 mnOptions; /// Conversion options. + bool mbUseTargetFont; /// True = Use maTargetFont to change font during conversion. + bool mbIsInteractive; /// True = Text conversion has (specific) dialog that may be raised. +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/strindlg.hxx b/sc/source/ui/inc/strindlg.hxx new file mode 100644 index 000000000..8d14f5ec5 --- /dev/null +++ b/sc/source/ui/inc/strindlg.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/. + * + * 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_SC_SOURCE_UI_INC_STRINDLG_HXX +#define INCLUDED_SC_SOURCE_UI_INC_STRINDLG_HXX + +#include <vcl/weld.hxx> + +class ScStringInputDlg : public weld::GenericDialogController +{ +private: + std::unique_ptr<weld::Label> m_xLabel; + std::unique_ptr<weld::Entry> m_xEdInput; + +public: + ScStringInputDlg(weld::Window* pParent, + const OUString& rTitle, + const OUString& rEditTitle, + const OUString& rDefault, + const OString& sHelpId, const OString& sEditHelpId); + + OUString GetInputString() const + { + return m_xEdInput->get_text(); + } +}; + +#endif // INCLUDED_SC_SOURCE_UI_INC_STRINDLG_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/styledlg.hxx b/sc/source/ui/inc/styledlg.hxx new file mode 100644 index 000000000..2d3aa4241 --- /dev/null +++ b/sc/source/ui/inc/styledlg.hxx @@ -0,0 +1,44 @@ +/* -*- 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_SC_SOURCE_UI_INC_STYLEDLG_HXX +#define INCLUDED_SC_SOURCE_UI_INC_STYLEDLG_HXX + +#include <sfx2/styledlg.hxx> + +class SfxStyleSheetBase; + +class ScStyleDlg : public SfxStyleDialogController +{ +public: + ScStyleDlg(weld::Window* pParent, + SfxStyleSheetBase& rStyleBase, + bool bPage); + +protected: + virtual void PageCreated(const OString& rPageId, SfxTabPage& rTabPage) override; + virtual void RefreshInputSet() override; + +private: + bool m_bPage; +}; + +#endif // INCLUDED_SC_SOURCE_UI_INC_STYLEDLG_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/subtdlg.hxx b/sc/source/ui/inc/subtdlg.hxx new file mode 100644 index 000000000..d06c4ef2e --- /dev/null +++ b/sc/source/ui/inc/subtdlg.hxx @@ -0,0 +1,38 @@ +/* -*- 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_SC_SOURCE_UI_INC_SUBTDLG_HXX +#define INCLUDED_SC_SOURCE_UI_INC_SUBTDLG_HXX + +#include <sfx2/tabdlg.hxx> + +class ScSubTotalDlg : public SfxTabDialogController +{ +public: + ScSubTotalDlg(weld::Window* pParent, const SfxItemSet* pArgSet); + virtual ~ScSubTotalDlg() override; + +private: + std::unique_ptr<weld::Button> m_xBtnRemove; + DECL_LINK(RemoveHdl, weld::Button&, void); +}; + +#endif // INCLUDED_SC_SOURCE_UI_INC_SUBTDLG_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/tabbgcolordlg.hxx b/sc/source/ui/inc/tabbgcolordlg.hxx new file mode 100644 index 000000000..0eea402d1 --- /dev/null +++ b/sc/source/ui/inc/tabbgcolordlg.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_SC_SOURCE_UI_INC_TABBGCOLORDLG_HXX +#define INCLUDED_SC_SOURCE_UI_INC_TABBGCOLORDLG_HXX + +#include <svx/SvxColorValueSet.hxx> +#include <svx/PaletteManager.hxx> + +class ScTabBgColorDlg : public weld::GenericDialogController +{ +public: + ScTabBgColorDlg(weld::Window* pParent, + const OUString& rTitle, + const OUString& rTabBgColorNoColorText, + const Color& rDefaultColor); + virtual ~ScTabBgColorDlg() override; + + void GetSelectedColor( Color& rColor ) const; + + class ScTabBgColorValueSet : public SvxColorValueSet + { + public: + ScTabBgColorValueSet(std::unique_ptr<weld::ScrolledWindow> pWindow); + virtual ~ScTabBgColorValueSet() override; + + void SetDialog(ScTabBgColorDlg* pTabBgColorDlg) + { + m_pTabBgColorDlg = pTabBgColorDlg; + } + + virtual bool KeyInput( const KeyEvent& rKEvt ) override; + private: + ScTabBgColorDlg* m_pTabBgColorDlg; + }; + +private: + PaletteManager m_aPaletteManager; + Color m_aTabBgColor; + + std::unique_ptr<weld::ComboBox> m_xSelectPalette; + std::unique_ptr<ScTabBgColorValueSet> m_xTabBgColorSet; + std::unique_ptr<weld::CustomWeld> m_xTabBgColorSetWin; + std::unique_ptr<weld::Button> m_xBtnOk; + + void FillPaletteLB(); + + DECL_LINK(SelectPaletteLBHdl, weld::ComboBox&, void); + DECL_LINK(TabBgColorDblClickHdl_Impl, ValueSet*, void); + DECL_LINK(TabBgColorOKHdl_Impl, weld::Button&, void); +}; + +#endif // INCLUDED_SC_SOURCE_UI_INC_TABBGCOLORDLG_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/tabcont.hxx b/sc/source/ui/inc/tabcont.hxx new file mode 100644 index 000000000..5f41ac8c5 --- /dev/null +++ b/sc/source/ui/inc/tabcont.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_SC_SOURCE_UI_INC_TABCONT_HXX +#define INCLUDED_SC_SOURCE_UI_INC_TABCONT_HXX + +#include <types.hxx> +#include <svtools/tabbar.hxx> +#include <vcl/transfer.hxx> + +class ScViewData; + +// initial size +#define SC_TABBAR_DEFWIDTH 270 + +class ScTabControl : public TabBar, public DropTargetHelper, public DragSourceHelper +{ +private: + ScViewData* pViewData; + sal_uInt16 nMouseClickPageId; /// Last page ID after mouse button down/up + sal_uInt16 nSelPageIdByMouse; /// Selected page ID, if selected with mouse + bool bErrorShown; + + void DoDrag(); + + sal_uInt16 GetMaxId() const; + SCTAB GetPrivatDropPos(const Point& rPos ); + + DECL_LINK(ShowPageList, const CommandEvent&, void); + +protected: + virtual void Select() override; + virtual void Command( const CommandEvent& rCEvt ) override; + virtual void MouseButtonDown( const MouseEvent& rMEvt ) override; + virtual void MouseButtonUp( const MouseEvent& rMEvt ) 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; + + virtual bool StartRenaming() override; + virtual TabBarAllowRenamingReturnCode AllowRenaming() override; + virtual void EndRenaming() override; + virtual void Mirror() override; + + virtual void AddTabClick() override; + +public: + ScTabControl( vcl::Window* pParent, ScViewData* pData ); + virtual void dispose() override; + virtual ~ScTabControl() override; + + using TabBar::StartDrag; + + void UpdateInputContext(); + void UpdateStatus(); + + void SetSheetLayoutRTL( bool bSheetRTL ); + void SwitchToPageId( sal_uInt16 nId ); +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/tabopdlg.hxx b/sc/source/ui/inc/tabopdlg.hxx new file mode 100644 index 000000000..d9911794c --- /dev/null +++ b/sc/source/ui/inc/tabopdlg.hxx @@ -0,0 +1,96 @@ +/* -*- 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_SC_SOURCE_UI_INC_TABOPDLG_HXX +#define INCLUDED_SC_SOURCE_UI_INC_TABOPDLG_HXX + +#include <address.hxx> +#include "anyrefdg.hxx" + +enum ScTabOpErr +{ + TABOPERR_NOFORMULA = 1, + TABOPERR_NOCOLROW, + TABOPERR_WRONGFORMULA, + TABOPERR_WRONGROW, + TABOPERR_NOCOLFORMULA, + TABOPERR_WRONGCOL, + TABOPERR_NOROWFORMULA +}; + +class ScTabOpDlg : public ScAnyRefDlgController +{ +public: + ScTabOpDlg(SfxBindings* pB, SfxChildWindow* pCW, weld::Window* pParent, + ScDocument* pDocument, + const ScRefAddress& rCursorPos); + virtual ~ScTabOpDlg() override; + + virtual void SetReference( const ScRange& rRef, ScDocument& rDoc ) override; + virtual bool IsRefInputMode() const override { return true; } + virtual void SetActive() override; + + virtual void Close() override; + +private: + ScRefAddress theFormulaCell; + ScRefAddress theFormulaEnd; + ScRefAddress theRowCell; + ScRefAddress theColCell; + + ScDocument* pDoc; + const SCTAB nCurTab; + bool bDlgLostFocus; + const OUString errMsgNoFormula; + const OUString errMsgNoColRow; + const OUString errMsgWrongFormula; + const OUString errMsgWrongRowCol; + const OUString errMsgNoColFormula; + const OUString errMsgNoRowFormula; + + formula::RefEdit* m_pEdActive; + std::unique_ptr<weld::Label> m_xFtFormulaRange; + std::unique_ptr<formula::RefEdit> m_xEdFormulaRange; + std::unique_ptr<formula::RefButton> m_xRBFormulaRange; + + std::unique_ptr<weld::Label> m_xFtRowCell; + std::unique_ptr<formula::RefEdit> m_xEdRowCell; + std::unique_ptr<formula::RefButton> m_xRBRowCell; + + std::unique_ptr<weld::Label> m_xFtColCell; + std::unique_ptr<formula::RefEdit> m_xEdColCell; + std::unique_ptr<formula::RefButton> m_xRBColCell; + + std::unique_ptr<weld::Button> m_xBtnOk; + std::unique_ptr<weld::Button> m_xBtnCancel; + + void Init(); + void RaiseError( ScTabOpErr eError ); + + DECL_LINK( BtnHdl, weld::Button&, void ); + DECL_LINK( GetEditFocusHdl, formula::RefEdit&, void ); + DECL_LINK( LoseEditFocusHdl, formula::RefEdit&, void ); + DECL_LINK( GetButtonFocusHdl, formula::RefButton&, void ); + DECL_LINK( LoseButtonFocusHdl, formula::RefButton&, void ); + +}; + +#endif // INCLUDED_SC_SOURCE_UI_INC_TABOPDLG_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/tabpages.hxx b/sc/source/ui/inc/tabpages.hxx new file mode 100644 index 000000000..ba8e35e49 --- /dev/null +++ b/sc/source/ui/inc/tabpages.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_SC_SOURCE_UI_INC_TABPAGES_HXX +#define INCLUDED_SC_SOURCE_UI_INC_TABPAGES_HXX + +#include <sfx2/tabdlg.hxx> + +class ScTabPageProtection : public SfxTabPage +{ + static const sal_uInt16 pProtectionRanges[]; +public: + ScTabPageProtection(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rCoreAttrs); + static std::unique_ptr<SfxTabPage> Create(weld::Container* pPage, weld::DialogController* pController, + const SfxItemSet* rAttrSet); + virtual ~ScTabPageProtection() override; + + static const sal_uInt16* GetRanges () { return pProtectionRanges; } + virtual bool FillItemSet ( SfxItemSet* rCoreAttrs ) override; + virtual void Reset ( const SfxItemSet* ) override; + +protected: + virtual DeactivateRC DeactivatePage ( SfxItemSet* pSet ) override; + +private: + // current status: + bool bTriEnabled; // if before - DontCare + bool bDontCare; // all in TriState + bool bProtect; // secure individual settings for TriState + bool bHideForm; + bool bHideCell; + bool bHidePrint; + + weld::TriStateEnabled aHideCellState; + weld::TriStateEnabled aProtectState; + weld::TriStateEnabled aHideFormulaState; + weld::TriStateEnabled aHidePrintState; + + std::unique_ptr<weld::CheckButton> m_xBtnHideCell; + std::unique_ptr<weld::CheckButton> m_xBtnProtect; + std::unique_ptr<weld::CheckButton> m_xBtnHideFormula; + std::unique_ptr<weld::CheckButton> m_xBtnHidePrint; + + // Handler: + DECL_LINK(ProtectClickHdl, weld::ToggleButton&, void); + DECL_LINK(HideCellClickHdl, weld::ToggleButton&, void); + DECL_LINK(HideFormulaClickHdl, weld::ToggleButton&, void); + DECL_LINK(HidePrintClickHdl, weld::ToggleButton&, void); + void ButtonClick(weld::ToggleButton& rBox); + void UpdateButtons(); +}; + +#endif // INCLUDED_SC_SOURCE_UI_INC_TABPAGES_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/tabsplit.hxx b/sc/source/ui/inc/tabsplit.hxx new file mode 100644 index 000000000..193027f98 --- /dev/null +++ b/sc/source/ui/inc/tabsplit.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_SC_SOURCE_UI_INC_TABSPLIT_HXX +#define INCLUDED_SC_SOURCE_UI_INC_TABSPLIT_HXX + +#include <vcl/split.hxx> + +class ScViewData; + +class ScTabSplitter : public Splitter +{ +private: + const ScViewData *const pViewData; + bool bFixed; + +protected: + virtual void MouseButtonDown( const MouseEvent& rMEvt ) override; + +public: + ScTabSplitter( vcl::Window* pParent, WinBits nWinStyle, + const ScViewData* pData ); + virtual ~ScTabSplitter() override; + + void SetFixed(bool bSet); + virtual void Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& rPaintRect ) override; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/tabview.hxx b/sc/source/ui/inc/tabview.hxx new file mode 100644 index 000000000..794e10fb8 --- /dev/null +++ b/sc/source/ui/inc/tabview.hxx @@ -0,0 +1,607 @@ +/* -*- 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_SC_SOURCE_UI_INC_TABVIEW_HXX +#define INCLUDED_SC_SOURCE_UI_INC_TABVIEW_HXX + +#include <sal/config.h> + +#include <array> +#include <memory> +#include <vcl/scrbar.hxx> +#include <vcl/help.hxx> + +#include "hiranges.hxx" +#include "viewutil.hxx" +#include "select.hxx" +#include "gridwin.hxx" +#include "drawview.hxx" + +namespace editeng { + struct MisspellRanges; +} + +class ScEditEngineDefaulter; +class ScOutlineWindow; +class ScRowBar; +class ScColBar; +class ScTabControl; +class ScTabViewShell; +struct ScRangeFindData; +class SvBorder; +class FuPoor; +class Splitter; +class ScTabSplitter; +class SdrView; +class SdrObject; +class ScPageBreakData; +class SdrHdlList; +class TabBar; +namespace com::sun::star::chart2::data { struct HighlightedRange; } + +enum HeaderType +{ + COLUMN_HEADER, + ROW_HEADER, + BOTH_HEADERS +}; + +// Help - Window + +class ScCornerButton : public vcl::Window +{ +private: + ScViewData* pViewData; + +protected: + virtual void Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect ) override; + virtual void Resize() override; + virtual void MouseButtonDown( const MouseEvent& rMEvt ) override; +public: + ScCornerButton( vcl::Window* pParent, ScViewData* pData ); + virtual ~ScCornerButton() override; + + virtual void StateChanged( StateChangedType nType ) override; + virtual void DataChanged( const DataChangedEvent& rDCEvt ) override; +}; + +class ScExtraEditViewManager +{ +private: + enum ModifierTagType { Adder, Remover }; + +public: + ScExtraEditViewManager(ScTabViewShell* pThisViewShell, std::array<VclPtr<ScGridWindow>, 4> const & pGridWin) + : mpThisViewShell(pThisViewShell) + , mpGridWin(pGridWin) + , mpOtherEditView(nullptr) + , nTotalWindows(0) + {} + + ~ScExtraEditViewManager(); + + void Add(SfxViewShell* pViewShell, ScSplitPos eWhich); + + void Remove(SfxViewShell* pViewShell, ScSplitPos eWhich); + +private: + template<ModifierTagType ModifierTag> + void Apply(SfxViewShell* pViewShell, ScSplitPos eWhich); + + template<ModifierTagType ModifierTag> + void Modifier(ScGridWindow* pWin); + +private: + ScTabViewShell* mpThisViewShell; + std::array<VclPtr<ScGridWindow>, 4> const & mpGridWin; + EditView* mpOtherEditView; + int nTotalWindows; +}; + +class ScTabView +{ +private: + enum BlockMode { None = 0, Normal = 1, Own = 2 }; + + VclPtr<vcl::Window> pFrameWin; // First !!! + ScViewData aViewData; // must be at the front ! + + std::unique_ptr<ScViewSelectionEngine> pSelEngine; + ScViewFunctionSet aFunctionSet; + + std::unique_ptr<ScHeaderSelectionEngine> pHdrSelEng; + ScHeaderFunctionSet aHdrFunc; + + std::unique_ptr<ScDrawView> pDrawView; + + Size aFrameSize; // passed on as for DoResize + Point aBorderPos; + + // The ownership of these two is rather weird. we seem to need + // to keep an old copy alive for some period of time to avoid crashing. + FuPoor* pDrawActual; + FuPoor* pDrawOld; + + std::shared_ptr<weld::MessageDialog> m_xMessageBox; + + std::array<VclPtr<ScGridWindow>, 4> pGridWin; + std::array<VclPtr<ScColBar>, 2> pColBar; + std::array<VclPtr<ScRowBar>, 2> pRowBar; + std::array<VclPtr<ScOutlineWindow>, 2> pColOutline; + std::array<VclPtr<ScOutlineWindow>, 2> pRowOutline; + VclPtr<ScTabSplitter> pHSplitter; + VclPtr<ScTabSplitter> pVSplitter; + VclPtr<ScTabControl> pTabControl; + VclPtr<ScrollBar> aVScrollTop; + VclPtr<ScrollBar> aVScrollBottom; // initially visible + VclPtr<ScrollBar> aHScrollLeft; // initially visible + VclPtr<ScrollBar> aHScrollRight; + VclPtr<ScCornerButton> aCornerButton; + VclPtr<ScCornerButton> aTopButton; + VclPtr<ScrollBarBox> aScrollBarBox; + + std::unique_ptr<sdr::overlay::OverlayObjectList> mxInputHintOO; // help hint for data validation + + std::unique_ptr<ScPageBreakData> pPageBreakData; + std::vector<ScHighlightEntry> maHighlightRanges; + + ScDocumentUniquePtr pBrushDocument; // cell formats for format paint brush + std::unique_ptr<SfxItemSet> pDrawBrushSet; // drawing object attributes for paint brush + + Timer aScrollTimer; + VclPtr<ScGridWindow> pTimerWindow; + MouseEvent aTimerMEvt; + + ScExtraEditViewManager aExtraEditViewManager; + + void* nTipVisible; + tools::Rectangle aTipRectangle; + QuickHelpFlags nTipAlign; + OUString sTipString; + VclPtr<vcl::Window> sTopParent; + + long nPrevDragPos; + + BlockMode meBlockMode; // Marks block + + SCCOL nBlockStartX; + SCCOL nBlockStartXOrig; + SCCOL nBlockEndX; + + SCROW nBlockStartY; + SCROW nBlockStartYOrig; + SCROW nBlockEndY; + + SCTAB nBlockStartZ; + SCTAB nBlockEndZ; + + SCCOL nOldCurX; + SCROW nOldCurY; + + double mfPendingTabBarWidth; // Tab bar width relative to frame window width. + + SCROW mnLOKStartHeaderRow; + SCROW mnLOKEndHeaderRow; + SCCOL mnLOKStartHeaderCol; + SCCOL mnLOKEndHeaderCol; + + bool bMinimized:1; + bool bInUpdateHeader:1; + bool bInActivatePart:1; + bool bInZoomUpdate:1; + bool bMoveIsShift:1; + bool bDrawSelMode:1; // Only select draw objects ? + bool bLockPaintBrush:1; // keep for more than one use? + bool bDragging:1; // for scroll bars + bool bBlockNeg:1; // is no longer highlighted? + bool bBlockCols:1; // are whole columns selected? + bool bBlockRows:1; // are whole rows selected? + bool mbInlineWithScrollbar:1; // should inline with scrollbar? + + void Init(); + + void DoAddWin( ScGridWindow* pWin ); + + void InitScrollBar( ScrollBar& rScrollBar, long nMaxVal ); + DECL_LINK(ScrollHdl, ScrollBar*, void ); + DECL_LINK(EndScrollHdl, ScrollBar*, void ); + + DECL_LINK(SplitHdl, Splitter*, void); + void DoHSplit(long nSplitPos); + void DoVSplit(long nSplitPos); + + DECL_LINK( TimerHdl, Timer*, void ); + + void UpdateVarZoom(); + + static void SetScrollBar( ScrollBar& rScroll, long nRangeMax, long nVisible, long nPos, bool bLayoutRTL ); + static long GetScrollBarPos( const ScrollBar& rScroll ); + + void GetAreaMoveEndPosition(SCCOL nMovX, SCROW nMovY, ScFollowMode eMode, + SCCOL& rAreaX, SCROW& rAreaY, ScFollowMode& rMode); + + void SkipCursorHorizontal(SCCOL& rCurX, SCROW& rCurY, SCCOL nOldX, SCCOL nMovX); + void SkipCursorVertical(SCCOL& rCurX, SCROW& rCurY, SCROW nOldY, SCROW nMovY); + + /** + * + * @brief Update marks for a selected Range. This is a helper function + * for PaintRangeFinder. + * + * @param pData: Range to update for painting. + * @param nTab: Current tab. + * + **/ + + void PaintRangeFinderEntry (const ScRangeFindData* pData, SCTAB nTab); + +protected: + void UpdateHeaderWidth( const ScVSplitPos* pWhich = nullptr, + const SCROW* pPosY = nullptr ); + + void HideTip(); + void ShowRefTip(); + + void ZoomChanged(); + void UpdateShow(); + bool UpdateVisibleRange(); + void GetBorderSize( SvBorder& rBorder, const Size& rSize ); + + void ResetDrawDragMode(); + bool IsDrawTextEdit() const; + void DrawEnableAnim(bool bSet); + + void MakeDrawView( TriState nForceDesignMode ); + + void HideNoteMarker(); + + void UpdateIMap( SdrObject* pObj ); + +public: + /** make noncopyable */ + ScTabView(const ScTabView&) = delete; + const ScTabView& operator=(const ScTabView&) = delete; + + ScTabView( vcl::Window* pParent, ScDocShell& rDocSh, ScTabViewShell* pViewShell ); + ~ScTabView(); + + enum SplitMethod { SC_SPLIT_METHOD_FIRST_COL, SC_SPLIT_METHOD_FIRST_ROW, SC_SPLIT_METHOD_CURSOR }; + + void MakeDrawLayer(); + + void HideListBox(); + + bool HasHintWindow() const; + void RemoveHintWindow(); + void TestHintWindow(); + + DECL_LINK( TabBarResize, ::TabBar*, void ); + /** Sets an absolute tab bar width (in pixels). */ + void SetTabBarWidth( long nNewWidth ); + /** Sets a relative tab bar width. + @param fRelTabBarWidth Tab bar width relative to frame window width (0.0 ... 1.0). */ + SC_DLLPUBLIC void SetRelTabBarWidth( double fRelTabBarWidth ); + /** Sets a relative tab bar width. Tab bar is resized again in next DoResize(). + @param fRelTabBarWidth Tab bar width relative to frame window width (0.0 ... 1.0). */ + void SetPendingRelTabBarWidth( double fRelTabBarWidth ); + /** Returns the current tab bar width in pixels. */ + long GetTabBarWidth() const; + /** Returns the current tab bar width relative to the frame window width (0.0 ... 1.0). */ + SC_DLLPUBLIC static double GetRelTabBarWidth(); + /** Returns the pending tab bar width relative to the frame window width (0.0 ... 1.0). */ + double GetPendingRelTabBarWidth() const { return mfPendingTabBarWidth;} + + void DoResize( const Point& rOffset, const Size& rSize, bool bInner = false ); + void RepeatResize( bool bUpdateFix = true ); + void UpdateFixPos(); + Point GetGridOffset() const; + + bool IsDrawSelMode() const { return bDrawSelMode; } + void SetDrawSelMode(bool bNew) { bDrawSelMode = bNew; } + + void SetDrawFuncPtr(FuPoor* pFuncPtr) { pDrawActual = pFuncPtr; } + void SetDrawFuncOldPtr(FuPoor* pFuncPtr) { pDrawOld = pFuncPtr; } + FuPoor* GetDrawFuncPtr() { return pDrawActual; } + FuPoor* GetDrawFuncOldPtr() { return pDrawOld; } + + void DrawDeselectAll(); + void DrawMarkListHasChanged(); + void UpdateAnchorHandles(); + + ScPageBreakData* GetPageBreakData() { return pPageBreakData.get(); } + const std::vector<ScHighlightEntry>& GetHighlightRanges() const { return maHighlightRanges; } + + void UpdatePageBreakData( bool bForcePaint = false ); + + ScViewData& GetViewData() { return aViewData; } + const ScViewData& GetViewData() const { return aViewData; } + + ScViewFunctionSet& GetFunctionSet() { return aFunctionSet; } + ScViewSelectionEngine* GetSelEngine() { return pSelEngine.get(); } + + bool SelMouseButtonDown( const MouseEvent& rMEvt ); + + ScDrawView* GetScDrawView() { return pDrawView.get(); } + + bool IsMinimized() const { return bMinimized; } + + /** + * Called after moving, copying, inserting or deleting a sheet. + * + * @param bSameTabButMoved true if the same sheet as before is activated. + */ + void TabChanged( bool bSameTabButMoved = false ); + void SetZoom( const Fraction& rNewX, const Fraction& rNewY, bool bAll ); + SC_DLLPUBLIC void RefreshZoom(); + void SetPagebreakMode( bool bSet ); + + void UpdateLayerLocks(); + + void UpdateDrawTextOutliner(); + void DigitLanguageChanged(); + + static void UpdateInputLine(); + + void InitRefMode( SCCOL nCurX, SCROW nCurY, SCTAB nCurZ, ScRefType eType ); + void DoneRefMode( bool bContinue = false ); + void UpdateRef( SCCOL nCurX, SCROW nCurY, SCTAB nCurZ ); + void StopRefMode(); + + void StopMarking(); + void FakeButtonUp( ScSplitPos eWhich ); + + ScGridWindow* GetActiveWin(); + vcl::Window* GetWindowByPos( ScSplitPos ePos ) const { return pGridWin[ePos]; } + + ScSplitPos FindWindow( const vcl::Window* pWindow ) const; + + void SetActivePointer( PointerStyle nPointer ); + + void ActiveGrabFocus(); + + void ClickCursor( SCCOL nPosX, SCROW nPosY, bool bControl ); + + SC_DLLPUBLIC void SetCursor( SCCOL nPosX, SCROW nPosY, bool bNew = false ); + + SC_DLLPUBLIC void CellContentChanged(); + void SelectionChanged( bool bFromPaste = false ); + void CursorPosChanged(); + void UpdateInputContext(); + + void CheckSelectionTransfer(); + + void InvertHorizontal( ScVSplitPos eWhich, long nDragPos ); + void InvertVertical( ScHSplitPos eWhich, long nDragPos ); + + Point GetInsertPos() const; + + Point GetChartInsertPos( const Size& rSize, const ScRange& rCellRange ); + Point GetChartDialogPos( const Size& rDialogSize, const tools::Rectangle& rLogicChart ); + + void UpdateAutoFillMark( bool bFromPaste = false ); + + void ShowCursor(); + void HideAllCursors(); + void ShowAllCursors(); + + void AlignToCursor( SCCOL nCurX, SCROW nCurY, ScFollowMode eMode, + const ScSplitPos* pWhich = nullptr ); + + SvxZoomType GetZoomType() const; + void SetZoomType( SvxZoomType eNew, bool bAll ); + sal_uInt16 CalcZoom( SvxZoomType eType, sal_uInt16 nOldZoom ); + + bool HasPageFieldDataAtCursor() const; + void StartDataSelect(); + + // MoveCursorAbs - absolute + // MoveCursorRel - single cells + // MoveCursorPage - screen + // MoveCursorArea - Data block + // MoveCursorEnd - top left / user range + + SC_DLLPUBLIC void MoveCursorAbs( SCCOL nCurX, SCROW nCurY, ScFollowMode eMode, + bool bShift, bool bControl, + bool bKeepOld = false, bool bKeepSel = false ); + void MoveCursorRel( SCCOL nMovX, SCROW nMovY, ScFollowMode eMode, + bool bShift, bool bKeepSel = false ); + void MoveCursorPage( SCCOL nMovX, SCROW nMovY, ScFollowMode eMode, + bool bShift, bool bKeepSel = false ); + void MoveCursorArea( SCCOL nMovX, SCROW nMovY, ScFollowMode eMode, + bool bShift, bool bKeepSel = false ); + void MoveCursorEnd( SCCOL nMovX, SCROW nMovY, ScFollowMode eMode, + bool bShift, bool bKeepSel = false ); + void MoveCursorScreen( SCCOL nMovX, SCROW nMovY, ScFollowMode eMode, bool bShift ); + + void MoveCursorEnter( bool bShift ); // Shift for direction (select nothing) + + bool MoveCursorKeyInput( const KeyEvent& rKeyEvent ); + + void FindNextUnprot( bool bShift, bool bInSelection ); + + void GetPageMoveEndPosition(SCCOL nMovX, SCROW nMovY, SCCOL& rPageX, SCROW& rPageY); + + SC_DLLPUBLIC void SetTabNo( SCTAB nTab, bool bNew = false, bool bExtendSelection = false, bool bSameTabButMoved = false ); + void SelectNextTab( short nDir, bool bExtendSelection ); + void SelectTabPage( const sal_uInt16 nTab ); + + void ActivateView( bool bActivate, bool bFirst ); + void ActivatePart( ScSplitPos eWhich ); + bool IsInActivatePart() const { return bInActivatePart; } + + void SetTimer( ScGridWindow* pWin, const MouseEvent& rMEvt ); + void ResetTimer(); + + void ScrollX( long nDeltaX, ScHSplitPos eWhich, bool bUpdBars = true ); + void ScrollY( long nDeltaY, ScVSplitPos eWhich, bool bUpdBars = true ); + SC_DLLPUBLIC void ScrollLines( long nDeltaX, long nDeltaY ); // active + + bool ScrollCommand( const CommandEvent& rCEvt, ScSplitPos ePos ); + + void ScrollToObject( const SdrObject* pDrawObj ); + void MakeVisible( const tools::Rectangle& rHMMRect ); + + // Drawing + + void PaintArea( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, + ScUpdateMode eMode = ScUpdateMode::All ); + + void PaintGrid(); + + void PaintTopArea( SCCOL nStartCol, SCCOL nEndCol ); + void PaintTop(); + + void PaintLeftArea( SCROW nStartRow, SCROW nEndRow ); + void PaintLeft(); + + bool PaintExtras(); + + void RecalcPPT(); + + void CreateAnchorHandles(SdrHdlList& rHdl, const ScAddress& rAddress); + + void UpdateCopySourceOverlay(); + void UpdateSelectionOverlay(); + void UpdateShrinkOverlay(); + void UpdateAllOverlays(); + + void UpdateFormulas( SCCOL nStartCol = -1, SCROW nStartRow = -1, SCCOL nEndCol = -1, SCROW nEndRow = -1 ); + void InterpretVisible(); + void CheckNeedsRepaint(); + bool NeedsRepaint(); + + void PaintRangeFinder( long nNumber ); + void AddHighlightRange( const ScRange& rRange, const Color& rColor ); + void ClearHighlightRanges(); + + void DoChartSelection( const css::uno::Sequence< css::chart2::data::HighlightedRange > & rHilightRanges ); + void DoDPFieldPopup(OUString const & rPivotTableName, sal_Int32 nDimensionIndex, Point aPoint, Size aSize); + + long GetGridWidth( ScHSplitPos eWhich ); + long GetGridHeight( ScVSplitPos eWhich ); + + void UpdateScrollBars( HeaderType eHeaderType = BOTH_HEADERS ); + void SetNewVisArea(); + void SetTabProtectionSymbol( SCTAB nTab, const bool bProtect ); // for protection icon of a tab on tabbar + + void InvalidateAttribs(); + + void OnLibreOfficeKitTabChanged(); + void AddWindowToForeignEditView(SfxViewShell* pViewShell, ScSplitPos eWhich); + void RemoveWindowFromForeignEditView(SfxViewShell* pViewShell, ScSplitPos eWhich); + void MakeEditView( ScEditEngineDefaulter* pEngine, SCCOL nCol, SCROW nRow ); + void KillEditView( bool bNoPaint ); + void UpdateEditView(); + + // Blocks + + void SelectAll( bool bContinue = false ); + void SelectAllTables(); + void DeselectAllTables(); + + void MarkCursor( SCCOL nCurX, SCROW nCurY, SCTAB nCurZ, + bool bCols = false, bool bRows = false, bool bCellSelection = false ); + void InitBlockMode( SCCOL nCurX, SCROW nCurY, SCTAB nCurZ, + bool bTestNeg = false, + bool bCols = false, bool bRows = false, bool bForceNeg = false ); + void InitOwnBlockMode(); + void DoneBlockMode( bool bContinue = false ); + + bool IsBlockMode() const; + + void ExpandBlock(SCCOL nMovX, SCROW nMovY, ScFollowMode eMode); + void ExpandBlockPage(SCCOL nMovX, SCROW nMovY); + void ExpandBlockArea(SCCOL nMovX, SCROW nMovY); + + void MarkColumns(); + void MarkRows(); + + /** + * Called to select the specified full column. + * + * @param nCol: Column number to do operation on + * @param nModifier: 0, KEY_SHIFT, KEY_MOD1, KEY_SHIFT | KEY_MOD1 + */ + + void MarkColumns(SCCOL nCol, sal_Int16 nModifier); + /** + * Called to select the specified full row. + * + * @param nRow: Row number to do operation on + * @param nModifier: 0, KEY_SHIFT, KEY_MOD1, KEY_SHIFT | KEY_MOD1 + */ + void MarkRows(SCROW nRow, sal_Int16 nModifier); + + void MarkDataArea( bool bIncludeCursor = true ); + void MarkMatrixFormula(); + void Unmark(); + + void MarkRange( const ScRange& rRange, bool bSetCursor = true, bool bContinue = false ); + + bool IsMarking( SCCOL nCol, SCROW nRow, SCTAB nTab ) const; + + void PaintMarks( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow ); + void PaintBlock( bool bReset ); + + void SetMarkData( const ScMarkData& rNew ); + void MarkDataChanged(); + + void LockModifiers( sal_uInt16 nModifiers ); + sal_uInt16 GetLockedModifiers() const; + void ViewOptionsHasChanged( bool bHScrollChanged, + bool bGraphicsChanged); + + Point GetMousePosPixel(); + + void FreezeSplitters( bool bFreeze, SplitMethod eSplitMethod = SC_SPLIT_METHOD_CURSOR ); + void RemoveSplit(); + void SplitAtCursor(); + void SplitAtPixel( const Point& rPixel ); + void InvalidateSplit(); + + void ErrorMessage(const char* pGlobStrId); + + void EnableRefInput(bool bFlag); + + vcl::Window* GetFrameWin() const { return pFrameWin; } + + bool HasPaintBrush() const { return pBrushDocument || pDrawBrushSet; } + ScDocument* GetBrushDocument() const { return pBrushDocument.get(); } + SfxItemSet* GetDrawBrushSet() const { return pDrawBrushSet.get(); } + bool IsPaintBrushLocked() const { return bLockPaintBrush; } + void SetBrushDocument( ScDocumentUniquePtr pNew, bool bLock ); + void SetDrawBrushSet( std::unique_ptr<SfxItemSet> pNew, bool bLock ); + void ResetBrushDocument(); + + bool ContinueOnlineSpelling(); + void EnableAutoSpell( bool bEnable ); + void ResetAutoSpell(); + void SetAutoSpellData( SCCOL nPosX, SCROW nPosY, const std::vector<editeng::MisspellRanges>* pRanges ); + /// @see ScModelObj::getRowColumnHeaders(). + OUString getRowColumnHeaders(const tools::Rectangle& rRectangle); + static void OnLOKNoteStateChanged(const ScPostIt* pNote); + + SCROW GetLOKStartHeaderRow() const { return mnLOKStartHeaderRow; } + SCROW GetLOKEndHeaderRow() const { return mnLOKEndHeaderRow; } + SCCOL GetLOKStartHeaderCol() const { return mnLOKStartHeaderCol; } + SCCOL GetLOKEndHeaderCol() const { return mnLOKEndHeaderCol; } +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/tabvwsh.hxx b/sc/source/ui/inc/tabvwsh.hxx new file mode 100644 index 000000000..7975a9236 --- /dev/null +++ b/sc/source/ui/inc/tabvwsh.hxx @@ -0,0 +1,404 @@ +/* -*- 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_SC_SOURCE_UI_INC_TABVWSH_HXX +#define INCLUDED_SC_SOURCE_UI_INC_TABVWSH_HXX + +#include <com/sun/star/drawing/QRCode.hpp> +#include <formula/errorcodes.hxx> +#include <formula/opcode.hxx> +#include <svx/fmshell.hxx> +#include <sfx2/viewsh.hxx> +#include <editeng/svxenum.hxx> +#include <o3tl/deleter.hxx> +#include <scdllapi.h> +#include "dbfunc.hxx" +#include "target.hxx" +#include <shellids.hxx> +#include <tabprotection.hxx> +#include <com/sun/star/ui/dialogs/XDialogClosedListener.hpp> + +#include <memory> +#include <map> + +class SdrOle2Obj; +class SfxBindings; +class SfxChildWindow; +class SvxNumberInfoItem; +struct SfxChildWinInfo; + +class ScArea; +class ScAuditingShell; +class ScDrawShell; +class ScDrawTextObjectBar; +class ScEditShell; +class ScInputHandler; +class ScPivotShell; +class ScDrawFormShell; +class ScCellShell; +class ScOleObjectShell; +class ScGraphicShell; +class ScMediaShell; +class ScChartShell; +class ScPageBreakShell; +class ScDPObject; +class ScNavigatorSettings; +class ScRangeName; + +struct ScHeaderFieldData; + +namespace editeng { class SvxBorderLine; } + +namespace com::sun::star::frame { class XDispatchProviderInterceptor; } + +namespace svx { + class ExtrusionBar; + class FontworkBar; +} + +enum ObjectSelectionType +{ + OST_NONE, + OST_Cell, + OST_Editing, + OST_DrawText, + OST_Drawing, + OST_DrawForm, + OST_Pivot, + OST_Auditing, + OST_OleObject, + OST_Chart, + OST_Graphic, + OST_Media +}; + +class ScFormEditData; +class SC_DLLPUBLIC ScTabViewShell: public SfxViewShell, public ScDBFunc +{ +private: + ObjectSelectionType eCurOST; + sal_uInt16 nDrawSfxId; + sal_uInt16 nFormSfxId; + OUString sDrawCustom; // current custom shape type + std::unique_ptr<ScDrawShell> pDrawShell; + std::unique_ptr<ScDrawTextObjectBar> pDrawTextShell; + std::unique_ptr<ScEditShell> pEditShell; + std::unique_ptr<ScPivotShell> pPivotShell; + std::unique_ptr<ScAuditingShell> pAuditingShell; + std::unique_ptr<ScDrawFormShell> pDrawFormShell; + std::unique_ptr<ScCellShell> pCellShell; + std::unique_ptr<ScOleObjectShell> pOleObjectShell; + std::unique_ptr<ScChartShell> pChartShell; + std::unique_ptr<ScGraphicShell> pGraphicShell; + std::unique_ptr<ScMediaShell> pMediaShell; + std::unique_ptr<ScPageBreakShell> pPageBreakShell; + std::unique_ptr<svx::ExtrusionBar> pExtrusionBarShell; + std::unique_ptr<svx::FontworkBar> pFontworkBarShell; + + std::unique_ptr<FmFormShell> pFormShell; + + std::unique_ptr<ScFormEditData> mpFormEditData; + std::unique_ptr<ScInputHandler, o3tl::default_delete<ScInputHandler>> mpInputHandler; // for OLE input cell + + std::unique_ptr<::editeng::SvxBorderLine> pCurFrameLine; + + css::uno::Reference< css::frame::XDispatchProviderInterceptor > + xDisProvInterceptor; + + Point aWinPos; + + ScTabViewTarget aTarget; + std::unique_ptr<ScDPObject> pDialogDPObject; + + std::unique_ptr<ScNavigatorSettings> pNavSettings; + + // used in first Activate + bool bFirstActivate; + + bool bActiveDrawSh; + bool bActiveDrawTextSh; + bool bActiveDrawFormSh; + bool bActiveOleObjectSh; + bool bActiveChartSh; + bool bActiveGraphicSh; + bool bActiveMediaSh; + bool bActiveEditSh; + + bool bFormShellAtTop; // does the FormShell need to be on top? + + bool bDontSwitch; // Don't turn off EditShell + bool bInFormatDialog; // for GetSelectionText + + bool bReadOnly; // to detect status changes + + bool bIsActive; + + bool bForceFocusOnCurCell; // #i123629# + + bool bInPrepareClose; + bool bInDispose; + + sal_uInt16 nCurRefDlgId; + + std::unique_ptr<SfxBroadcaster> pAccessibilityBroadcaster; + + // ugly hack for Add button in ScNameDlg + std::map<OUString, std::unique_ptr<ScRangeName>> m_RangeMap; + bool mbInSwitch; + OUString maName; + OUString maScope; +private: + void Construct( TriState nForceDesignMode ); + + SfxShell* GetMySubShell() const; + + void DoReadUserData( const OUString& rData ); + void DoReadUserDataSequence( const css::uno::Sequence< css::beans::PropertyValue >& rSettings ); + bool IsSignatureLineSelected(); + bool IsSignatureLineSigned(); + bool IsQRCodeSelected(); + + DECL_LINK( SimpleRefClose, const OUString*, void ); + DECL_LINK( SimpleRefDone, const OUString&, void ); + DECL_LINK( SimpleRefAborted, const OUString&, void ); + DECL_LINK( SimpleRefChange, const OUString&, void ); + DECL_LINK( FormControlActivated, LinkParamNone*, void ); + DECL_LINK( DialogClosedHdl, css::ui::dialogs::DialogClosedEvent*, void ); + +protected: + virtual void Activate(bool bMDI) override; + virtual void Deactivate(bool bMDI) override; + virtual bool PrepareClose( bool bUI = true ) override; + + virtual void ShowCursor(bool bOn) override; + + virtual void Move() override; // notification + + virtual void InnerResizePixel( const Point &rOfs, const Size &rSize, bool inplaceEditModeChange ) override; // new + virtual void OuterResizePixel( const Point &rOfs, const Size &rSize ) override; + virtual void SetZoomFactor( const Fraction &rZoomX, const Fraction &rZoomY ) override; + + virtual void QueryObjAreaPixel( tools::Rectangle& rRect ) const override; + + virtual OUString GetSelectionText( bool bWholeWord = false ) override; + virtual bool HasSelection( bool bText = true ) const override; + + virtual void WriteUserData(OUString &, bool bBrowse = false) override; + virtual void ReadUserData(const OUString &, bool bBrowse = false) override; + virtual void WriteUserDataSequence (css::uno::Sequence < css::beans::PropertyValue >& ) override; + virtual void ReadUserDataSequence (const css::uno::Sequence < css::beans::PropertyValue >& ) override; + + virtual void UIDeactivated( SfxInPlaceClient* pClient ) override; + + virtual bool KeyInput( const KeyEvent &rKeyEvent ) override; + virtual SdrView* GetDrawView() const override; + +public: + SFX_DECL_INTERFACE(SCID_TABVIEW_SHELL) + SFX_DECL_VIEWFACTORY(ScTabViewShell); + +private: + /// SfxInterface initializer. + static void InitInterface_Impl(); + +public: + /** -> Clone Method for Factory + Created from a general shell and inherit as much as possible */ + ScTabViewShell( SfxViewFrame* pViewFrame, + SfxViewShell* pOldSh ); + + virtual ~ScTabViewShell() override; + + weld::Window* GetDialogParent(); + + bool IsRefInputMode() const; + void ExecuteInputDirect(); + + const ScInputHandler* GetInputHandler() const { return mpInputHandler.get(); } + ScInputHandler* GetInputHandler() { return mpInputHandler.get(); } + void UpdateInputHandler( bool bForce = false, bool bStopEditing = true ); + void UpdateInputHandlerCellAdjust( SvxCellHorJustify eJust ); + bool TabKeyInput(const KeyEvent& rKEvt); + bool SfxKeyInput(const KeyEvent& rKEvt); + + void SetActive(); + + ::editeng::SvxBorderLine* GetDefaultFrameLine() const { return pCurFrameLine.get(); } + void SetDefaultFrameLine(const ::editeng::SvxBorderLine* pLine ); + + void Execute( SfxRequest& rReq ); + void GetState( SfxItemSet& rSet ); + + void ExecuteTable( SfxRequest& rReq ); + void GetStateTable( SfxItemSet& rSet ); + + void WindowChanged(); + void ExecDraw(SfxRequest&); + void ExecDrawIns(SfxRequest& rReq); + void GetDrawState(SfxItemSet &rSet); + void GetDrawInsState(SfxItemSet &rSet); + void ExecGallery(const SfxRequest& rReq); + + void ExecChildWin(const SfxRequest& rReq); + + void ExecImageMap( SfxRequest& rReq ); + void GetImageMapState( SfxItemSet& rSet ); + + void ExecuteSave( SfxRequest& rReq ); + void GetSaveState( SfxItemSet& rSet ); + void ExecSearch( SfxRequest& rReq ); + + void ExecuteUndo(SfxRequest& rReq); + void GetUndoState(SfxItemSet &rSet); + + void ExecuteObject(const SfxRequest& rReq); + void GetObjectState(SfxItemSet &rSet); + + void ExecDrawOpt(const SfxRequest& rReq); + void GetDrawOptState(SfxItemSet &rSet); + + void UpdateDrawShell(); + void SetDrawShell( bool bActive ); + void SetDrawTextShell( bool bActive ); + + void SetPivotShell( bool bActive ); + void SetDialogDPObject( std::unique_ptr<ScDPObject> pObj ); + const ScDPObject* GetDialogDPObject() const { return pDialogDPObject.get(); } + + void SetDontSwitch(bool bFlag){bDontSwitch=bFlag;} + + void SetAuditShell( bool bActive ); + void SetDrawFormShell( bool bActive ); + void SetEditShell(EditView* pView, bool bActive ); + void SetOleObjectShell( bool bActive ); + void SetChartShell( bool bActive ); + void SetGraphicShell( bool bActive ); + void SetMediaShell( bool bActive ); + + void SetDrawShellOrSub(); + void SetCurSubShell( ObjectSelectionType eOST, bool bForce = false ); + + void SetFormShellAtTop( bool bSet ); + + ObjectSelectionType GetCurObjectSelectionType() const { return eCurOST; } + + virtual ErrCode DoVerb(long nVerb) override; + + void StopEditShell(); + bool IsDrawTextShell() const; + bool IsAuditShell() const; + + void SetDrawTextUndo( SfxUndoManager* pUndoMgr ); + + void FillFieldData( ScHeaderFieldData& rData ); + + virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override; + + ScNavigatorSettings* GetNavigatorSettings(); + + // Drucken: + virtual SfxPrinter* GetPrinter( bool bCreate = false ) override; + virtual sal_uInt16 SetPrinter( SfxPrinter* pNewPrinter, + SfxPrinterChangeFlags nDiffFlags = SFX_PRINTER_ALL ) override; + + virtual bool HasPrintOptionsPage() const override; + virtual std::unique_ptr<SfxTabPage> CreatePrintOptionsPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet &rOptions) override; + + void ConnectObject( const SdrOle2Obj* pObj ); + void ActivateObject( SdrOle2Obj* pObj, long nVerb ); + + void DeactivateOle(); + + static ScTabViewShell* GetActiveViewShell(); + + std::shared_ptr<SfxModelessDialogController> CreateRefDialogController(SfxBindings* pB, SfxChildWindow* pCW, + const SfxChildWinInfo* pInfo, + weld::Window* pParent, sal_uInt16 nSlotId); + + void UpdateOleZoom(); + + virtual const FmFormShell* GetFormShell() const override { return pFormShell.get(); } + virtual FmFormShell* GetFormShell() override { return pFormShell.get(); } + + void InsertURL( const OUString& rName, const OUString& rURL, const OUString& rTarget, + sal_uInt16 nMode ); + void InsertURLButton( const OUString& rName, const OUString& rURL, const OUString& rTarget, + const Point* pInsPos ); + void InsertURLField( const OUString& rName, const OUString& rURL, const OUString& rTarget ); + + bool SelectObject( const OUString& rName ); + + void SetInFormatDialog(bool bFlag) {bInFormatDialog=bFlag;} + + void ForceMove() { Move(); } + + static std::unique_ptr<SvxNumberInfoItem> MakeNumberInfoItem( ScDocument* pDoc, const ScViewData* pViewData ); + + static void UpdateNumberFormatter( const SvxNumberInfoItem& rInfoItem ); + + void ExecuteCellFormatDlg( SfxRequest& rReq, const OString &rTabPage); + + bool GetFunction( OUString& rFuncStr, FormulaError nErrCode ); + + void StartSimpleRefDialog( const OUString& rTitle, const OUString& rInitVal, + bool bCloseOnButtonUp, bool bSingleCell, bool bMultiSelection ); + void StopSimpleRefDialog(); + + void SetCurRefDlgId( sal_uInt16 nNew ); + + void AddAccessibilityObject( SfxListener& rObject ); + void RemoveAccessibilityObject( SfxListener& rObject ); + void BroadcastAccessibility( const SfxHint &rHint ); + bool HasAccessibilityObjects() const; + + bool ExecuteRetypePassDlg(ScPasswordHash eDesiredHash); + + using ScTabView::ShowCursor; + + bool IsActive() const { return bIsActive; } + OUString GetFormula(const ScAddress& rAddress); + bool UseSubTotal(ScRangeList* pRangeList); + OUString DoAutoSum(bool& rRangeFinder, bool& rSubTotal, const OpCode eCode); + + // ugly hack to call Define Names from Manage Names + void SwitchBetweenRefDialogs(SfxModelessDialogController* pDialog); + // #i123629# + bool GetForceFocusOnCurCell() const { return bForceFocusOnCurCell; } + void SetForceFocusOnCurCell(bool bFlag) { bForceFocusOnCurCell=bFlag; } + /// See SfxViewShell::getPart(). + int getPart() const override; + /// See SfxViewShell::afterCallbackRegistered(). + void afterCallbackRegistered() override; + /// See SfxViewShell::NotifyCursor(). + void NotifyCursor(SfxViewShell* pViewShell) const override; + /// Emits a LOK_CALLBACK_INVALIDATE_HEADER for all views whose current tab is equal to nCurrentTabIndex + static void notifyAllViewsHeaderInvalidation(HeaderType eHeaderType, SCTAB nCurrentTabIndex); + static void notifyAllViewsHeaderInvalidation(bool Columns, SCTAB nCurrentTabIndex); + static bool isAnyEditViewInRange(bool bColumns, SCCOLROW nStart, SCCOLROW nEnd); + css::uno::Reference<css::drawing::XShapes> getSelectedXShapes(); + static css::uno::Reference<css::datatransfer::XTransferable2> GetClipData(vcl::Window* pWin); + + void InitFormEditData(); + void ClearFormEditData(); + ScFormEditData* GetFormEditData() { return mpFormEditData.get(); } +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/target.hxx b/sc/source/ui/inc/target.hxx new file mode 100644 index 000000000..6c42308a6 --- /dev/null +++ b/sc/source/ui/inc/target.hxx @@ -0,0 +1,42 @@ +/* -*- 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_SC_SOURCE_UI_INC_TARGET_HXX +#define INCLUDED_SC_SOURCE_UI_INC_TARGET_HXX + +#include <svl/undo.hxx> + +class ScTabViewShell; + +class ScTabViewTarget : public SfxRepeatTarget +{ +private: + ScTabViewShell* pViewShell; + +public: + + ScTabViewTarget( ScTabViewShell* pShell ) : pViewShell( pShell ) {} + virtual ~ScTabViewTarget() override; + + ScTabViewShell* GetViewShell() const { return pViewShell; } +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/tbzoomsliderctrl.hxx b/sc/source/ui/inc/tbzoomsliderctrl.hxx new file mode 100644 index 000000000..bb3660fab --- /dev/null +++ b/sc/source/ui/inc/tbzoomsliderctrl.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_SC_SOURCE_UI_INC_TBZOOMSLIDERCTRL_HXX +#define INCLUDED_SC_SOURCE_UI_INC_TBZOOMSLIDERCTRL_HXX + +#include <vcl/customweld.hxx> +#include <vcl/window.hxx> +#include <svl/poolitem.hxx> +#include <vcl/InterimItemWindow.hxx> +#include <sfx2/tbxctrl.hxx> + +namespace com::sun::star::frame { class XDispatchProvider; } + +class SvxZoomSliderItem; + +class ScZoomSliderControl : public SfxToolBoxControl +{ +public: + SFX_DECL_TOOLBOX_CONTROL(); + ScZoomSliderControl( sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx ); + virtual ~ScZoomSliderControl() override; + + virtual void StateChanged( sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState ) override; + virtual VclPtr<InterimItemWindow> CreateItemWindow( vcl::Window *pParent ) override; +}; + +class ScZoomSlider final : public weld::CustomWidgetController +{ +private: + struct ScZoomSliderWnd_Impl; + std::unique_ptr<ScZoomSliderWnd_Impl> mpImpl; + css::uno::Reference<css::frame::XDispatchProvider> m_xDispatchProvider; + + sal_uInt16 Offset2Zoom(long nOffset) const; + long Zoom2Offset(sal_uInt16 nZoom) const; + + void DoPaint(vcl::RenderContext& rRenderContext); +public: + ScZoomSlider(const css::uno::Reference<css::frame::XDispatchProvider>& rDispatchProvider, + sal_uInt16 nCurrentZoom, vcl::Window*); + + void UpdateFromItem(const SvxZoomSliderItem* pZoomSliderItem); + + virtual bool MouseButtonDown( const MouseEvent& rMEvt ) override; + virtual bool MouseMove( const MouseEvent& rMEvt ) override; + virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) override; +}; + +class ScZoomSliderWnd final : public InterimItemWindow +{ +private: + std::unique_ptr<ScZoomSlider> mxWidget; + std::unique_ptr<weld::CustomWeld> mxWeld; + +public: + ScZoomSliderWnd(vcl::Window* pParent, const css::uno::Reference<css::frame::XDispatchProvider>& rDispatchProvider, + sal_uInt16 nCurrentZoom); + virtual ~ScZoomSliderWnd() override; + virtual void dispose() override; + void UpdateFromItem( const SvxZoomSliderItem* pZoomSliderItem ); +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/textdlgs.hxx b/sc/source/ui/inc/textdlgs.hxx new file mode 100644 index 000000000..f9d3a6dba --- /dev/null +++ b/sc/source/ui/inc/textdlgs.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_SC_SOURCE_UI_INC_TEXTDLGS_HXX +#define INCLUDED_SC_SOURCE_UI_INC_TEXTDLGS_HXX + +#include <sfx2/tabdlg.hxx> + +class SfxObjectShell; + +class ScCharDlg : public SfxTabDialogController +{ +private: + const SfxObjectShell& rDocShell; + + virtual void PageCreated(const OString& rId, SfxTabPage &rPage) override; +public: + ScCharDlg(weld::Window* pParent, const SfxItemSet* pAttr, const SfxObjectShell* pDocShell, bool bDrawText); +}; + +class ScParagraphDlg : public SfxTabDialogController +{ +private: + virtual void PageCreated(const OString& rId, SfxTabPage &rPage) override; +public: + ScParagraphDlg(weld::Window* pParent, const SfxItemSet* pAttr); +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/textimportoptions.hxx b/sc/source/ui/inc/textimportoptions.hxx new file mode 100644 index 000000000..3b50655c7 --- /dev/null +++ b/sc/source/ui/inc/textimportoptions.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_SC_SOURCE_UI_INC_TEXTIMPORTOPTIONS_HXX +#define INCLUDED_SC_SOURCE_UI_INC_TEXTIMPORTOPTIONS_HXX + +#include <vcl/weld.hxx> +#include <i18nlangtag/lang.h> + +class SvxLanguageBox; + +class ScTextImportOptionsDlg : public weld::GenericDialogController +{ +public: + ScTextImportOptionsDlg(weld::Window* pParent); + virtual ~ScTextImportOptionsDlg() override; + + LanguageType getLanguageType() const; + bool isDateConversionSet() const; + +private: + void init(); + +private: + std::unique_ptr<weld::Button> m_xBtnOk; + std::unique_ptr<weld::RadioButton> m_xRbAutomatic; + std::unique_ptr<weld::RadioButton> m_xRbCustom; + std::unique_ptr<weld::CheckButton> m_xBtnConvertDate; + std::unique_ptr<SvxLanguageBox> m_xLbCustomLang; + + DECL_LINK(OKHdl, weld::Button&, void); + DECL_LINK(RadioHdl, weld::ToggleButton&, void); +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/tpcalc.hxx b/sc/source/ui/inc/tpcalc.hxx new file mode 100644 index 000000000..21bc8c526 --- /dev/null +++ b/sc/source/ui/inc/tpcalc.hxx @@ -0,0 +1,77 @@ +/* -*- 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_SC_SOURCE_UI_INC_TPCALC_HXX +#define INCLUDED_SC_SOURCE_UI_INC_TPCALC_HXX + +#include <sfx2/tabdlg.hxx> +#include "editfield.hxx" + +class ScDocOptions; + +class ScTpCalcOptions : public SfxTabPage +{ +public: + ScTpCalcOptions(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rCoreSet); + static std::unique_ptr<SfxTabPage> Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rCoreSet); + virtual ~ScTpCalcOptions() override; + virtual bool FillItemSet ( SfxItemSet* rCoreSet ) override; + virtual void Reset ( const SfxItemSet* rCoreSet ) override; + virtual DeactivateRC DeactivatePage ( SfxItemSet* pSet ) override; + +private: + std::unique_ptr<ScDocOptions> pOldOptions; + std::unique_ptr<ScDocOptions> pLocalOptions; + sal_uInt16 nWhichCalc; + + std::unique_ptr<weld::CheckButton> m_xBtnIterate; + std::unique_ptr<weld::Label> m_xFtSteps; + std::unique_ptr<weld::SpinButton> m_xEdSteps; + std::unique_ptr<weld::Label> m_xFtEps; + std::unique_ptr<ScDoubleField> m_xEdEps; + + std::unique_ptr<weld::RadioButton> m_xBtnDateStd; + std::unique_ptr<weld::RadioButton> m_xBtnDateSc10; + std::unique_ptr<weld::RadioButton> m_xBtnDate1904; + + std::unique_ptr<weld::CheckButton> m_xBtnCase; + std::unique_ptr<weld::CheckButton> m_xBtnCalc; + std::unique_ptr<weld::CheckButton> m_xBtnMatch; + std::unique_ptr<weld::RadioButton> m_xBtnWildcards; + std::unique_ptr<weld::RadioButton> m_xBtnRegex; + std::unique_ptr<weld::RadioButton> m_xBtnLiteral; + std::unique_ptr<weld::CheckButton> m_xBtnLookUp; + std::unique_ptr<weld::CheckButton> m_xBtnGeneralPrec; + + std::unique_ptr<weld::Label> m_xFtPrec; + std::unique_ptr<weld::SpinButton> m_xEdPrec; + + std::unique_ptr<weld::CheckButton> m_xBtnThread; + +private: + void Init(); + + // Handler: + DECL_LINK( RadioClickHdl, weld::Button&, void ); + DECL_LINK( CheckClickHdl, weld::ToggleButton&, void ); +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/tpcompatibility.hxx b/sc/source/ui/inc/tpcompatibility.hxx new file mode 100644 index 000000000..4a61426a5 --- /dev/null +++ b/sc/source/ui/inc/tpcompatibility.hxx @@ -0,0 +1,32 @@ +/* -*- 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_SC_SOURCE_UI_INC_TPCOMPATIBILITY_HXX +#define INCLUDED_SC_SOURCE_UI_INC_TPCOMPATIBILITY_HXX + +#include <sfx2/tabdlg.hxx> + +class ScTpCompatOptions : public SfxTabPage +{ +public: + explicit ScTpCompatOptions(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rCoreAttrs); + static std::unique_ptr<SfxTabPage> Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rCoreAttrs); + virtual ~ScTpCompatOptions() override; + + virtual bool FillItemSet(SfxItemSet* rCoreAttrs) override; + virtual void Reset(const SfxItemSet* rCoreAttrs) override; + virtual DeactivateRC DeactivatePage(SfxItemSet* pSet ) override; + +private: + std::unique_ptr<weld::ComboBox> m_xLbKeyBindings; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/tpdefaults.hxx b/sc/source/ui/inc/tpdefaults.hxx new file mode 100644 index 000000000..b83017368 --- /dev/null +++ b/sc/source/ui/inc/tpdefaults.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_SC_SOURCE_UI_INC_TPDEFAULTS_HXX +#define INCLUDED_SC_SOURCE_UI_INC_TPDEFAULTS_HXX + +#include <sfx2/tabdlg.hxx> + +class ScTpDefaultsOptions : public SfxTabPage +{ +public: + explicit ScTpDefaultsOptions(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rCoreSet); + static std::unique_ptr<SfxTabPage> Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rCoreSet); + virtual ~ScTpDefaultsOptions() override; + + virtual bool FillItemSet(SfxItemSet* rCoreSet) override; + virtual void Reset(const SfxItemSet* rCoreSet) override; + virtual DeactivateRC DeactivatePage(SfxItemSet* pSet) override; + +private: + void CheckNumSheets(); + void CheckPrefix(); + void OnFocusPrefixInput(); + + DECL_LINK( NumModifiedHdl, weld::Entry&, void ); + DECL_LINK( PrefixModifiedHdl, weld::Entry&, void ); + DECL_LINK( PrefixEditOnFocusHdl, weld::Widget&, void ); + +private: + // Stores old Sheet Prefix + OUString maOldPrefixValue; + + std::unique_ptr<weld::SpinButton> m_xEdNSheets; + std::unique_ptr<weld::Entry> m_xEdSheetPrefix; + std::unique_ptr<weld::CheckButton> m_xEdJumboSheets; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/tpformula.hxx b/sc/source/ui/inc/tpformula.hxx new file mode 100644 index 000000000..3cda79900 --- /dev/null +++ b/sc/source/ui/inc/tpformula.hxx @@ -0,0 +1,85 @@ +/* -*- 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_SC_SOURCE_UI_INC_TPFORMULA_HXX +#define INCLUDED_SC_SOURCE_UI_INC_TPFORMULA_HXX + +#include <sfx2/tabdlg.hxx> + +#include <calcconfig.hxx> +#include <docoptio.hxx> + +class ScTpFormulaOptions : public SfxTabPage +{ +public: + explicit ScTpFormulaOptions(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rCoreSet); + static std::unique_ptr<SfxTabPage> Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rCoreSet); + virtual ~ScTpFormulaOptions() override; + + virtual bool FillItemSet(SfxItemSet* rCoreSet) override; + virtual void Reset( const SfxItemSet* rCoreSet ) override; + virtual DeactivateRC DeactivatePage(SfxItemSet* pSet ) override; + +private: + void ResetSeparators(); + void OnFocusSeparatorInput(weld::Entry* pEdit); + void UpdateCustomCalcRadioButtons(bool bDefault); + void LaunchCustomCalcSettings(); + + bool IsValidSeparator(const OUString& rSep) const; + + DECL_LINK( ButtonHdl, weld::Button&, void ); + DECL_LINK( SepInsertTextHdl, OUString&, bool ); + DECL_LINK( ColSepInsertTextHdl, OUString&, bool ); + DECL_LINK( RowSepInsertTextHdl, OUString&, bool ); + DECL_LINK( SepModifyHdl, weld::Entry&, void ); + DECL_LINK( SepEditOnFocusHdl, weld::Widget&, void ); + +private: + /** Stores old separator value of currently focused separator edit box. + This value is used to revert undesired value change. */ + OUString maOldSepValue; + + ScCalcConfig maSavedConfig; + ScCalcConfig maCurrentConfig; + + ScDocOptions maSavedDocOptions; + ScDocOptions maCurrentDocOptions; + + sal_Unicode mnDecSep; + + std::unique_ptr<weld::ComboBox> mxLbFormulaSyntax; + std::unique_ptr<weld::CheckButton> mxCbEnglishFuncName; + + std::unique_ptr<weld::RadioButton> mxBtnCustomCalcDefault; + std::unique_ptr<weld::RadioButton> mxBtnCustomCalcCustom; + std::unique_ptr<weld::Button> mxBtnCustomCalcDetails; + + std::unique_ptr<weld::Entry> mxEdSepFuncArg; + std::unique_ptr<weld::Entry> mxEdSepArrayCol; + std::unique_ptr<weld::Entry> mxEdSepArrayRow; + std::unique_ptr<weld::Button> mxBtnSepReset; + + std::unique_ptr<weld::ComboBox> mxLbOOXMLRecalcOptions; + std::unique_ptr<weld::ComboBox> mxLbODFRecalcOptions; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/tphf.hxx b/sc/source/ui/inc/tphf.hxx new file mode 100644 index 000000000..edd87f207 --- /dev/null +++ b/sc/source/ui/inc/tphf.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_SC_SOURCE_UI_INC_TPHF_HXX +#define INCLUDED_SC_SOURCE_UI_INC_TPHF_HXX + +#include <svx/hdft.hxx> + +class ScStyleDlg; + +class ScHFPage : public SvxHFPage +{ +public: + virtual ~ScHFPage() override; + + virtual void Reset( const SfxItemSet* rSet ) override; + virtual bool FillItemSet( SfxItemSet* rOutSet ) override; + + void SetPageStyle( const OUString& rName ) { aStrPageStyle = rName; } + void SetStyleDlg ( ScStyleDlg* pDlg ) { pStyleDlg = pDlg; } + +protected: + ScHFPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet, sal_uInt16 nSetId); + + virtual void ActivatePage( const SfxItemSet& rSet ) override; + virtual DeactivateRC DeactivatePage( SfxItemSet* pSet ) override; + +private: + SfxItemSet aDataSet; + OUString aStrPageStyle; + SvxPageUsage nPageUsage; + ScStyleDlg* pStyleDlg; + std::unique_ptr<weld::Button> m_xBtnEdit; + + DECL_LINK(BtnHdl, weld::Button&, void); + DECL_LINK(TurnOnHdl, weld::ToggleButton&, void); +}; + +class ScHeaderPage : public ScHFPage +{ +public: + static std::unique_ptr<SfxTabPage> Create( weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rSet ); + ScHeaderPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet); + static const sal_uInt16* GetRanges(); +}; + +class ScFooterPage : public ScHFPage +{ +public: + static std::unique_ptr<SfxTabPage> Create( weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rSet ); + ScFooterPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet); + static const sal_uInt16* GetRanges(); +}; + +#endif // INCLUDED_SC_SOURCE_UI_INC_TPHF_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/tphfedit.hxx b/sc/source/ui/inc/tphfedit.hxx new file mode 100644 index 000000000..85b8984c8 --- /dev/null +++ b/sc/source/ui/inc/tphfedit.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_SC_SOURCE_UI_INC_TPHFEDIT_HXX +#define INCLUDED_SC_SOURCE_UI_INC_TPHFEDIT_HXX + +#include <scdllapi.h> +#include <cppuhelper/weakref.hxx> +#include <tools/wintypes.hxx> +#include <svx/weldeditview.hxx> +#include <editeng/svxenum.hxx> +#include <vcl/customweld.hxx> + +#include <functional> + +namespace com::sun::star::accessibility { class XAccessible; } + +class ScHeaderEditEngine; +class ScPatternAttr; +class EditView; +class EditTextObject; +class SvxFieldItem; +class ScAccessibleEditObject; +namespace vcl { class Window; } + +enum ScEditWindowLocation +{ + Left, + Center, + Right +}; + +class SC_DLLPUBLIC ScEditWindow : public WeldEditView +{ +public: + ScEditWindow(ScEditWindowLocation eLoc, weld::Window* pParent); + virtual void SetDrawingArea(weld::DrawingArea* pArea) override; + virtual ~ScEditWindow() override; + + void SetFont( const ScPatternAttr& rPattern ); + void SetText( const EditTextObject& rTextObject ); + std::unique_ptr<EditTextObject> CreateTextObject(); + void SetCharAttributes(); + + void InsertField( const SvxFieldItem& rFld ); + + void SetNumType(SvxNumType eNumType); + + virtual css::uno::Reference< css::accessibility::XAccessible > CreateAccessible() override; + + ScHeaderEditEngine* GetEditEngine() const; + void SetObjectSelectHdl( const Link<ScEditWindow&,void>& aLink) { aObjectSelectLink = aLink; } + void SetGetFocusHdl(const std::function<void (ScEditWindow&)>& rLink) { m_GetFocusLink = rLink; } + +protected: + virtual void makeEditEngine() override; + virtual bool KeyInput( const KeyEvent& rKEvt ) override; + virtual bool MouseButtonDown(const MouseEvent& rMEvt) override; + virtual void GetFocus() override; + virtual void LoseFocus() override; + +private: + ScEditWindowLocation eLocation; + bool mbRTL; + weld::Window* mpDialog; + + css::uno::WeakReference< css::accessibility::XAccessible > xAcc; + ScAccessibleEditObject* pAcc; + + Link<ScEditWindow&,void> aObjectSelectLink; + std::function<void (ScEditWindow&)> m_GetFocusLink; + +}; + +#endif // INCLUDED_SC_SOURCE_UI_INC_TPHFEDIT_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/tpprint.hxx b/sc/source/ui/inc/tpprint.hxx new file mode 100644 index 000000000..4e2d0f917 --- /dev/null +++ b/sc/source/ui/inc/tpprint.hxx @@ -0,0 +1,43 @@ +/* -*- 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_SC_SOURCE_UI_INC_TPPRINT_HXX +#define INCLUDED_SC_SOURCE_UI_INC_TPPRINT_HXX + +#include <sfx2/tabdlg.hxx> + +class ScTpPrintOptions : public SfxTabPage +{ + std::unique_ptr<weld::CheckButton> m_xSkipEmptyPagesCB; + std::unique_ptr<weld::CheckButton> m_xSelectedSheetsCB; + std::unique_ptr<weld::CheckButton> m_xForceBreaksCB; + +public: + ScTpPrintOptions(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rCoreSet); + static std::unique_ptr<SfxTabPage> Create( weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rCoreSet ); + virtual ~ScTpPrintOptions() override; + + virtual bool FillItemSet( SfxItemSet* rCoreSet ) override; + virtual void Reset( const SfxItemSet* rCoreSet ) override; + virtual DeactivateRC DeactivatePage( SfxItemSet* pSet ) override; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/tpsort.hxx b/sc/source/ui/inc/tpsort.hxx new file mode 100644 index 000000000..1c59ef1a2 --- /dev/null +++ b/sc/source/ui/inc/tpsort.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_SC_SOURCE_UI_INC_TPSORT_HXX +#define INCLUDED_SC_SOURCE_UI_INC_TPSORT_HXX + +#include <vector> + +#include <sfx2/tabdlg.hxx> +#include <svtools/collatorres.hxx> +#include <svx/langbox.hxx> +#include <unotools/collatorwrapper.hxx> +#include <vcl/idle.hxx> + +#include "sortkeydlg.hxx" + +#include <address.hxx> +#include <sortparam.hxx> + +// +1 because one field is reserved for the "- undefined -" entry +#define SC_MAXFIELDS MAXCOLCOUNT+1 + +class ScViewData; + +// Sort Criteria + +class ScTabPageSortFields : public SfxTabPage +{ +public: + ScTabPageSortFields(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rArgSet); + static std::unique_ptr<SfxTabPage> Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rArgSet); + virtual ~ScTabPageSortFields() override; + + virtual bool FillItemSet ( SfxItemSet* rArgSet ) override; + virtual void Reset ( const SfxItemSet* rArgSet ) override; + +protected: + virtual void ActivatePage ( const SfxItemSet& rSet ) override; + virtual DeactivateRC DeactivatePage ( SfxItemSet* pSet ) override; + +private: + Idle m_aIdle; + + OUString aStrUndefined; + OUString aStrColumn; + OUString aStrRow; + + const sal_uInt16 nWhichSort; + ScViewData* pViewData; + ScSortParam aSortData; + std::vector<SCCOLROW> nFieldArr; + sal_uInt16 nFieldCount; + sal_uInt16 nSortKeyCount; + + bool bHasHeader; + bool bSortByRows; + + std::unique_ptr<weld::ScrolledWindow> m_xScrolledWindow; + std::unique_ptr<weld::Container> m_xBox; + ScSortKeyWindow m_aSortWin; + + void AddSortKey( sal_uInt16 nItem ); + +private: + void Init (); + void FillFieldLists ( sal_uInt16 nStartField ); + sal_uInt16 GetFieldSelPos ( SCCOLROW nField ); + void SetLastSortKey( sal_uInt16 nItem ); + + // Handler ------------------------ + DECL_LINK(SelectHdl, weld::ComboBox&, void); + DECL_LINK(ScrollToEndHdl, Timer*, void); +}; + +// Sort Options + +class ScDocument; + +class ScTabPageSortOptions : public SfxTabPage +{ +public: + ScTabPageSortOptions(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rArgSet); + static std::unique_ptr<SfxTabPage> Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* pArgSet); + + virtual bool FillItemSet ( SfxItemSet* rArgSet ) override; + virtual void Reset ( const SfxItemSet* rArgSet ) override; + +protected: + virtual void ActivatePage ( const SfxItemSet& rSet ) override; + virtual DeactivateRC DeactivatePage ( SfxItemSet* pSet ) override; + +private: + OUString aStrRowLabel; + OUString aStrColLabel; + OUString aStrUndefined; + + const sal_uInt16 nWhichSort; + ScSortParam aSortData; + ScViewData* pViewData; + ScDocument* pDoc; + ScAddress theOutPos; + + std::unique_ptr<CollatorResource> m_xColRes; + std::unique_ptr<CollatorWrapper> m_xColWrap; + + std::unique_ptr<weld::CheckButton> m_xBtnCase; + std::unique_ptr<weld::CheckButton> m_xBtnHeader; + std::unique_ptr<weld::CheckButton> m_xBtnFormats; + std::unique_ptr<weld::CheckButton> m_xBtnNaturalSort; + std::unique_ptr<weld::CheckButton> m_xBtnCopyResult; + std::unique_ptr<weld::ComboBox> m_xLbOutPos; + std::unique_ptr<weld::Entry> m_xEdOutPos; + std::unique_ptr<weld::CheckButton> m_xBtnSortUser; + std::unique_ptr<weld::ComboBox> m_xLbSortUser; + std::unique_ptr<SvxLanguageBox> m_xLbLanguage; + std::unique_ptr<weld::Label> m_xFtAlgorithm; + std::unique_ptr<weld::ComboBox> m_xLbAlgorithm; + std::unique_ptr<weld::RadioButton> m_xBtnTopDown; + std::unique_ptr<weld::RadioButton> m_xBtnLeftRight; + std::unique_ptr<weld::CheckButton> m_xBtnIncComments; + std::unique_ptr<weld::CheckButton> m_xBtnIncImages; + +private: + void Init (); + void FillUserSortListBox (); + + // Handler ------------------------ + DECL_LINK( EnableHdl, weld::ToggleButton&, void ); + DECL_LINK( SelOutPosHdl, weld::ComboBox&, void ); + void EdOutPosModHdl(); + DECL_LINK( SortDirHdl, weld::ToggleButton&, void ); + void FillAlgor(); + DECL_LINK( FillAlgorHdl, weld::ComboBox&, void ); +}; + +#endif // INCLUDED_SC_SOURCE_UI_INC_TPSORT_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/tpstat.hxx b/sc/source/ui/inc/tpstat.hxx new file mode 100644 index 000000000..71d3dd7cd --- /dev/null +++ b/sc/source/ui/inc/tpstat.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/. + * + * 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_SC_SOURCE_UI_INC_TPSTAT_HXX +#define INCLUDED_SC_SOURCE_UI_INC_TPSTAT_HXX + +#include <sfx2/tabdlg.hxx> + +class ScDocStatPage: public SfxTabPage +{ +public: + static std::unique_ptr<SfxTabPage> Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rSet); + ScDocStatPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet); + virtual ~ScDocStatPage() override; + +protected: + virtual bool FillItemSet( SfxItemSet* rSet ) override; + virtual void Reset ( const SfxItemSet* rSet ) override; + +private: + std::unique_ptr<weld::Label> m_xFtTables; + std::unique_ptr<weld::Label> m_xFtCells; + std::unique_ptr<weld::Label> m_xFtPages; + std::unique_ptr<weld::Label> m_xFtFormula; + std::unique_ptr<weld::Frame> m_xFrame; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/tpsubt.hxx b/sc/source/ui/inc/tpsubt.hxx new file mode 100644 index 000000000..f4e52a5a6 --- /dev/null +++ b/sc/source/ui/inc/tpsubt.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_SC_SOURCE_UI_INC_TPSUBT_HXX +#define INCLUDED_SC_SOURCE_UI_INC_TPSUBT_HXX + +#include <sfx2/tabdlg.hxx> +#include <global.hxx> + +// +1 because one field is reserved for the "- none -" entry +#define SC_MAXFIELDS MAXCOLCOUNT+1 + +class ScViewData; +class ScDocument; +struct ScSubTotalParam; + +class ScTpSubTotalGroup : public SfxTabPage +{ +protected: + ScTpSubTotalGroup(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rArgSet); + +public: + virtual ~ScTpSubTotalGroup() override; + + bool DoReset ( sal_uInt16 nGroupNo, + const SfxItemSet& rArgSet ); + bool DoFillItemSet ( sal_uInt16 nGroupNo, + SfxItemSet& rArgSet ); +protected: + const OUString aStrNone; + const OUString aStrColumn; + + ScViewData* pViewData; + ScDocument* pDoc; + + const sal_uInt16 nWhichSubTotals; + const ScSubTotalParam& rSubTotalData; + SCCOL nFieldArr[SC_MAXFIELDS]; + sal_uInt16 nFieldCount; + + std::unique_ptr<weld::ComboBox> mxLbGroup; + std::unique_ptr<weld::TreeView> mxLbColumns; + std::unique_ptr<weld::TreeView> mxLbFunctions; + +private: + void Init (); + void FillListBoxes (); + static ScSubTotalFunc LbPosToFunc ( sal_uInt16 nPos ); + static sal_uInt16 FuncToLbPos ( ScSubTotalFunc eFunc ); + sal_uInt16 GetFieldSelPos ( SCCOL nField ); + + // Handler ------------------------ + DECL_LINK( SelectListBoxHdl, weld::ComboBox&, void ); + DECL_LINK( SelectTreeListBoxHdl, weld::TreeView&, void ); + typedef std::pair<int, int> row_col; + DECL_LINK(CheckHdl, const row_col&, void); + void SelectHdl(const weld::Widget*); +}; + +class ScTpSubTotalGroup1 final : public ScTpSubTotalGroup +{ +public: + ScTpSubTotalGroup1( weld::Container* pPage, weld::DialogController* pController, + const SfxItemSet& rArgSet ); + static std::unique_ptr<SfxTabPage> Create ( weld::Container* pPage, weld::DialogController* pController, + const SfxItemSet* rArgSet ); + virtual ~ScTpSubTotalGroup1() override; + + virtual bool FillItemSet ( SfxItemSet* rArgSet ) override; + virtual void Reset ( const SfxItemSet* rArgSet ) override; +}; + +class ScTpSubTotalGroup2 final : public ScTpSubTotalGroup +{ +public: + ScTpSubTotalGroup2( weld::Container* pPage, weld::DialogController* pController, + const SfxItemSet& rArgSet ); + static std::unique_ptr<SfxTabPage> Create ( weld::Container* pPage, weld::DialogController* pController, + const SfxItemSet* rArgSet ); + virtual ~ScTpSubTotalGroup2() override; + + virtual bool FillItemSet ( SfxItemSet* rArgSet ) override; + virtual void Reset ( const SfxItemSet* rArgSet ) override; +}; + +class ScTpSubTotalGroup3 final : public ScTpSubTotalGroup +{ +public: + ScTpSubTotalGroup3( weld::Container* pPage, weld::DialogController* pController, + const SfxItemSet& rArgSet ); + static std::unique_ptr<SfxTabPage> Create ( weld::Container* pPage, weld::DialogController* pController, + const SfxItemSet* rArgSet ); + virtual ~ScTpSubTotalGroup3() override; + + virtual bool FillItemSet ( SfxItemSet* rArgSet ) override; + virtual void Reset ( const SfxItemSet* rArgSet ) override; +}; + +class ScTpSubTotalOptions final : public SfxTabPage +{ +public: + ScTpSubTotalOptions(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rArgSet); + static std::unique_ptr<SfxTabPage> Create ( weld::Container* pPage, weld::DialogController* pController, + const SfxItemSet* rArgSet ); + virtual ~ScTpSubTotalOptions() override; + + virtual bool FillItemSet ( SfxItemSet* rArgSet ) override; + virtual void Reset ( const SfxItemSet* rArgSet ) override; + +private: + void Init (); + void FillUserSortListBox (); + + // Handler ------------------------ + DECL_LINK(CheckHdl, weld::Button&, void); + + ScViewData* pViewData; + ScDocument* pDoc; + const sal_uInt16 nWhichSubTotals; + const ScSubTotalParam& rSubTotalData; + + std::unique_ptr<weld::CheckButton> m_xBtnPagebreak; + std::unique_ptr<weld::CheckButton> m_xBtnCase; + std::unique_ptr<weld::CheckButton> m_xBtnSort; + std::unique_ptr<weld::Label> m_xFlSort; + std::unique_ptr<weld::RadioButton> m_xBtnAscending; + std::unique_ptr<weld::RadioButton> m_xBtnDescending; + std::unique_ptr<weld::CheckButton> m_xBtnFormats; + std::unique_ptr<weld::CheckButton> m_xBtnUserDef; + std::unique_ptr<weld::ComboBox> m_xLbUserDef; +}; + +#endif // INCLUDED_SC_SOURCE_UI_INC_TPSUBT_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/tptable.hxx b/sc/source/ui/inc/tptable.hxx new file mode 100644 index 000000000..fe86f338e --- /dev/null +++ b/sc/source/ui/inc/tptable.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_SC_SOURCE_UI_INC_TPTABLE_HXX +#define INCLUDED_SC_SOURCE_UI_INC_TPTABLE_HXX + +#include <sfx2/tabdlg.hxx> + +class ScTablePage : public SfxTabPage +{ + static const sal_uInt16 pPageTableRanges[]; +public: + ScTablePage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rCoreSet); + static std::unique_ptr<SfxTabPage> Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rCoreSet); + virtual ~ScTablePage() override; + + static const sal_uInt16* GetRanges () { return pPageTableRanges; } + virtual bool FillItemSet ( SfxItemSet* rCoreSet ) override; + virtual void Reset ( const SfxItemSet* rCoreSet ) override; + virtual DeactivateRC DeactivatePage ( SfxItemSet* pSet ) override; + +private: + void ShowImage(); + +private: + sal_uInt16 m_nOrigScalePageWidth; + sal_uInt16 m_nOrigScalePageHeight; + + std::unique_ptr<weld::RadioButton> m_xBtnTopDown; + std::unique_ptr<weld::RadioButton> m_xBtnLeftRight; + std::unique_ptr<weld::Image> m_xBmpPageDir; + std::unique_ptr<weld::CheckButton> m_xBtnPageNo; + std::unique_ptr<weld::SpinButton> m_xEdPageNo; + + std::unique_ptr<weld::CheckButton> m_xBtnHeaders; + std::unique_ptr<weld::CheckButton> m_xBtnGrid; + std::unique_ptr<weld::CheckButton> m_xBtnNotes; + std::unique_ptr<weld::CheckButton> m_xBtnObjects; + std::unique_ptr<weld::CheckButton> m_xBtnCharts; + std::unique_ptr<weld::CheckButton> m_xBtnDrawings; + std::unique_ptr<weld::CheckButton> m_xBtnFormulas; + std::unique_ptr<weld::CheckButton> m_xBtnNullVals; + + std::unique_ptr<weld::ComboBox> m_xLbScaleMode; + std::unique_ptr<weld::Widget> m_xBxScaleAll; + std::unique_ptr<weld::MetricSpinButton> m_xEdScaleAll; + std::unique_ptr<weld::Widget> m_xGrHeightWidth; + std::unique_ptr<weld::SpinButton> m_xEdScalePageWidth; + std::unique_ptr<weld::CheckButton> m_xCbScalePageWidth; + std::unique_ptr<weld::SpinButton> m_xEdScalePageHeight; + std::unique_ptr<weld::CheckButton> m_xCbScalePageHeight; + std::unique_ptr<weld::Widget> m_xBxScalePageNum; + std::unique_ptr<weld::SpinButton> m_xEdScalePageNum; + +private: + + // Handler: + DECL_LINK(PageDirHdl, weld::ToggleButton&, void); + DECL_LINK(PageNoHdl, weld::ToggleButton&, void); + void PageNoHdl(const weld::ToggleButton* pBtn); + DECL_LINK(ScaleHdl, weld::ComboBox&, void); + DECL_LINK(ToggleHdl, weld::ToggleButton&, void); +}; + +#endif // INCLUDED_SC_SOURCE_UI_INC_TPTABLE_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/tpusrlst.hxx b/sc/source/ui/inc/tpusrlst.hxx new file mode 100644 index 000000000..c237da9a9 --- /dev/null +++ b/sc/source/ui/inc/tpusrlst.hxx @@ -0,0 +1,91 @@ +/* -*- 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_SC_SOURCE_UI_INC_TPUSRLST_HXX +#define INCLUDED_SC_SOURCE_UI_INC_TPUSRLST_HXX + +#include <sfx2/tabdlg.hxx> + +class ScUserList; +class ScDocument; +class ScViewData; +class ScRefAddress; + +class ScTpUserLists : public SfxTabPage +{ +public: + ScTpUserLists(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rArgSet); + static std::unique_ptr<SfxTabPage> Create(weld::Container* pPage, weld::DialogController* pController, + const SfxItemSet* rAttrSet); + virtual ~ScTpUserLists() override; + virtual bool FillItemSet ( SfxItemSet* rCoreAttrs ) override; + virtual void Reset ( const SfxItemSet* rCoreAttrs ) override; + virtual DeactivateRC DeactivatePage ( SfxItemSet* pSet ) override; + +private: + std::unique_ptr<weld::Label> mxFtLists; + std::unique_ptr<weld::TreeView> mxLbLists; + std::unique_ptr<weld::Label> mxFtEntries; + std::unique_ptr<weld::TextView> mxEdEntries; + std::unique_ptr<weld::Label> mxFtCopyFrom; + std::unique_ptr<weld::Entry> mxEdCopyFrom; + std::unique_ptr<weld::Button> mxBtnNew; + std::unique_ptr<weld::Button> mxBtnDiscard; + std::unique_ptr<weld::Button> mxBtnAdd; + std::unique_ptr<weld::Button> mxBtnModify; + std::unique_ptr<weld::Button> mxBtnRemove; + std::unique_ptr<weld::Button> mxBtnCopy; + + const OUString aStrQueryRemove; + const OUString aStrCopyList; + const OUString aStrCopyFrom; + const OUString aStrCopyErr; + + const sal_uInt16 nWhichUserLists; + std::unique_ptr<ScUserList> pUserLists; + + ScDocument* pDoc; + ScViewData* pViewData; + OUString aStrSelectedArea; + + bool bModifyMode; + bool bCancelMode; + bool bCopyDone; + sal_Int32 nCancelPos; + + void Init (); + size_t UpdateUserListBox (); + void UpdateEntries ( size_t nList ); + static void MakeListStr ( OUString& rListStr ); + void AddNewList ( const OUString& rEntriesStr ); + void RemoveList ( size_t nList ); + void ModifyList ( size_t nSelList, + const OUString& rEntriesStr ); + void CopyListFromArea ( const ScRefAddress& rStartPos, + const ScRefAddress& rEndPos ); + + // Handler: + DECL_LINK( LbSelectHdl, weld::TreeView&, void ); + DECL_LINK( BtnClickHdl, weld::Button&, void ); + DECL_LINK( EdEntriesModHdl, weld::TextView&, void); +}; + +#endif // INCLUDED_SC_SOURCE_UI_INC_TPUSRLST_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/tpview.hxx b/sc/source/ui/inc/tpview.hxx new file mode 100644 index 000000000..bed1e1325 --- /dev/null +++ b/sc/source/ui/inc/tpview.hxx @@ -0,0 +1,115 @@ +/* -*- 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_SC_SOURCE_UI_INC_TPVIEW_HXX +#define INCLUDED_SC_SOURCE_UI_INC_TPVIEW_HXX + +#include <sfx2/tabdlg.hxx> +#include <svx/colorbox.hxx> + +class ScViewOptions; + +class ScTpContentOptions : public SfxTabPage +{ + std::unique_ptr<ScViewOptions> m_xLocalOptions; + + std::unique_ptr<weld::ComboBox> m_xGridLB; + std::unique_ptr<weld::Label> m_xColorFT; + std::unique_ptr<ColorListBox> m_xColorLB; + std::unique_ptr<weld::CheckButton> m_xBreakCB; + std::unique_ptr<weld::CheckButton> m_xGuideLineCB; + + std::unique_ptr<weld::CheckButton> m_xFormulaCB; + std::unique_ptr<weld::CheckButton> m_xNilCB; + std::unique_ptr<weld::CheckButton> m_xAnnotCB; + std::unique_ptr<weld::CheckButton> m_xValueCB; + std::unique_ptr<weld::CheckButton> m_xAnchorCB; + std::unique_ptr<weld::CheckButton> m_xClipMarkCB; + std::unique_ptr<weld::CheckButton> m_xRangeFindCB; + + std::unique_ptr<weld::ComboBox> m_xObjGrfLB; + std::unique_ptr<weld::ComboBox> m_xDiagramLB; + std::unique_ptr<weld::ComboBox> m_xDrawLB; + + std::unique_ptr<weld::CheckButton> m_xSyncZoomCB; + + std::unique_ptr<weld::CheckButton> m_xRowColHeaderCB; + std::unique_ptr<weld::CheckButton> m_xHScrollCB; + std::unique_ptr<weld::CheckButton> m_xVScrollCB; + std::unique_ptr<weld::CheckButton> m_xTblRegCB; + std::unique_ptr<weld::CheckButton> m_xOutlineCB; + std::unique_ptr<weld::CheckButton> m_xSummaryCB; + + void InitGridOpt(); + DECL_LINK( GridHdl, weld::ComboBox&, void ); + DECL_LINK( SelLbObjHdl, weld::ComboBox&, void ); + DECL_LINK( CBHdl, weld::ToggleButton&, void ); + +public: + ScTpContentOptions(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rArgSet); + static std::unique_ptr<SfxTabPage> Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rCoreSet); + virtual ~ScTpContentOptions() override; + virtual bool FillItemSet ( SfxItemSet* rCoreSet ) override; + virtual void Reset ( const SfxItemSet* rCoreSet ) override; + virtual void ActivatePage( const SfxItemSet& ) override; + virtual DeactivateRC DeactivatePage( SfxItemSet* pSet ) override; + +}; + +class ScDocument; +class ScTpLayoutOptions : public SfxTabPage +{ + ScDocument *pDoc; + + std::unique_ptr<weld::ComboBox> m_xUnitLB; + std::unique_ptr<weld::MetricSpinButton> m_xTabMF; + + std::unique_ptr<weld::RadioButton> m_xAlwaysRB; + std::unique_ptr<weld::RadioButton> m_xRequestRB; + std::unique_ptr<weld::RadioButton> m_xNeverRB; + + std::unique_ptr<weld::CheckButton> m_xAlignCB; + std::unique_ptr<weld::ComboBox> m_xAlignLB; + std::unique_ptr<weld::CheckButton> m_xEditModeCB; + std::unique_ptr<weld::CheckButton> m_xFormatCB; + std::unique_ptr<weld::CheckButton> m_xExpRefCB; + std::unique_ptr<weld::CheckButton> m_xSortRefUpdateCB; + std::unique_ptr<weld::CheckButton> m_xMarkHdrCB; + std::unique_ptr<weld::CheckButton> m_xTextFmtCB; + std::unique_ptr<weld::CheckButton> m_xReplWarnCB; + std::unique_ptr<weld::CheckButton> m_xLegacyCellSelectionCB; + + DECL_LINK(MetricHdl, weld::ComboBox&, void ); + DECL_LINK( AlignHdl, weld::ToggleButton&, void ); + + +public: + ScTpLayoutOptions(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rArgSet ); + static std::unique_ptr<SfxTabPage> Create(weld::Container* pPage, weld::DialogController* pController, + const SfxItemSet* rCoreSet); + virtual ~ScTpLayoutOptions() override; + virtual bool FillItemSet ( SfxItemSet* rCoreSet ) override; + virtual void Reset ( const SfxItemSet* rCoreSet ) override; + virtual void ActivatePage( const SfxItemSet& ) override; + virtual DeactivateRC DeactivatePage( SfxItemSet* pSet ) override; +}; + +#endif // INCLUDED_SC_SOURCE_UI_INC_TPVIEW_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/transobj.hxx b/sc/source/ui/inc/transobj.hxx new file mode 100644 index 000000000..dc046fdfe --- /dev/null +++ b/sc/source/ui/inc/transobj.hxx @@ -0,0 +1,115 @@ +/* -*- 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_SC_SOURCE_UI_INC_TRANSOBJ_HXX +#define INCLUDED_SC_SOURCE_UI_INC_TRANSOBJ_HXX + +#include <vcl/transfer.hxx> +#include <address.hxx> +#include <document.hxx> +#include <sfx2/objsh.hxx> + + +class ScDocShell; +class ScMarkData; +enum class ScDragSrc; + +namespace com::sun::star { + namespace sheet { + class XSheetCellRanges; + } +} + +class SAL_DLLPUBLIC_RTTI ScTransferObj : public TransferDataContainer +{ +private: + ScDocumentUniquePtr m_pDoc; + ScRange m_aBlock; + SCROW m_nNonFiltered; // non-filtered rows + TransferableObjectDescriptor m_aObjDesc; + SfxObjectShellRef m_aDocShellRef; + SfxObjectShellRef m_aDrawPersistRef; + css::uno::Reference<css::sheet::XSheetCellRanges> m_xDragSourceRanges; + SCCOL m_nDragHandleX; + SCROW m_nDragHandleY; + SCCOL m_nSourceCursorX; + SCROW m_nSourceCursorY; + SCTAB m_nVisibleTab; + ScDragSrc m_nDragSourceFlags; + bool m_bDragWasInternal; + bool m_bUsedForLink; + bool m_bHasFiltered; // if has filtered rows + bool m_bUseInApi; // to recognize clipboard content copied from API + + // #i123405# added parameter to allow size calculation without limitation + // to PageSize, e.g. used for Metafile creation for clipboard. + void InitDocShell(bool bLimitToPageSize); + static void StripRefs( ScDocument* pDoc, SCCOL nStartX, SCROW nStartY, + SCCOL nEndX, SCROW nEndY, + ScDocument* pDestDoc ); + static void PaintToDev( OutputDevice* pDev, ScDocument* pDoc, double nPrintFactor, + const ScRange& rBlock ); + static void GetAreaSize( const ScDocument* pDoc, SCTAB nTab1, SCTAB nTab2, SCROW& nRow, SCCOL& nCol ); + +public: + ScTransferObj( ScDocumentUniquePtr pClipDoc, const TransferableObjectDescriptor& rDesc ); + virtual ~ScTransferObj() override; + + virtual void AddSupportedFormats() override; + virtual bool GetData( const css::datatransfer::DataFlavor& rFlavor, const OUString& rDestDoc ) override; + virtual bool WriteObject( tools::SvRef<SotStorageStream>& rxOStm, void* pUserObject, sal_uInt32 nUserObjectId, + const css::datatransfer::DataFlavor& rFlavor ) override; + virtual void DragFinished( sal_Int8 nDropAction ) override; + virtual sal_Bool SAL_CALL isComplex() override; + + ScDocument* GetDocument() const { return m_pDoc.get(); } // owned by ScTransferObj + const ScRange& GetRange() const { return m_aBlock; } + SCROW GetNonFilteredRows() const { return m_nNonFiltered; } + SCCOL GetDragHandleX() const { return m_nDragHandleX; } + SCROW GetDragHandleY() const { return m_nDragHandleY; } + bool WasSourceCursorInSelection() const; + SCCOL GetSourceCursorX() const { return m_nSourceCursorX; } + SCROW GetSourceCursorY() const { return m_nSourceCursorY; } + SCTAB GetVisibleTab() const { return m_nVisibleTab; } + ScDragSrc GetDragSourceFlags() const { return m_nDragSourceFlags; } + bool HasFilteredRows() const { return m_bHasFiltered; } + bool GetUseInApi() const { return m_bUseInApi; } + ScDocShell* GetSourceDocShell(); + ScDocument* GetSourceDocument(); + ScMarkData GetSourceMarkData() const; + + void SetDrawPersist( const SfxObjectShellRef& rRef ); + void SetDragHandlePos( SCCOL nX, SCROW nY ); + void SetSourceCursorPos( SCCOL nX, SCROW nY ); + void SetVisibleTab( SCTAB nNew ); + void SetDragSource( ScDocShell* pSourceShell, const ScMarkData& rMark ); + void SetDragSourceFlags( ScDragSrc nFlags ); + void SetDragWasInternal(); + SC_DLLPUBLIC void SetUseInApi( bool bSet ); + + static SC_DLLPUBLIC ScTransferObj* GetOwnClipboard(const css::uno::Reference<css::datatransfer::XTransferable2>&); + + static SfxObjectShell* SetDrawClipDoc( bool bAnyOle ); // update ScGlobal::xDrawClipDocShellRef + virtual sal_Int64 SAL_CALL getSomething( const com::sun::star::uno::Sequence< sal_Int8 >& rId ) override; + static const com::sun::star::uno::Sequence< sal_Int8 >& getUnoTunnelId(); +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/uiitems.hxx b/sc/source/ui/inc/uiitems.hxx new file mode 100644 index 000000000..180e8e71a --- /dev/null +++ b/sc/source/ui/inc/uiitems.hxx @@ -0,0 +1,282 @@ +/* -*- 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_SC_SOURCE_UI_INC_UIITEMS_HXX +#define INCLUDED_SC_SOURCE_UI_INC_UIITEMS_HXX + +#include <scdllapi.h> +#include <sortparam.hxx> +#include <subtotalparam.hxx> +#include <paramisc.hxx> +#include <svl/poolitem.hxx> + +#include <memory> +#include <vector> + +namespace editeng { + struct MisspellRanges; +} + +class ScEditEngineDefaulter; +class EditTextObject; +class ScViewData; +class ScDPSaveData; +struct ScQueryParam; + +// Items + +class ScInputStatusItem : public SfxPoolItem +{ + ScAddress aCursorPos; + ScAddress aStartPos; + ScAddress aEndPos; + OUString aString; + std::unique_ptr<EditTextObject> pEditData; + const std::vector<editeng::MisspellRanges>* mpMisspellRanges; + +public: + + ScInputStatusItem( sal_uInt16 nWhich, + const ScAddress& rCurPos, + const ScAddress& rStartPos, + const ScAddress& rEndPos, + const OUString& rString, + const EditTextObject* pData ); + ScInputStatusItem( const ScInputStatusItem& rItem ); + virtual ~ScInputStatusItem() override; + + virtual bool operator==( const SfxPoolItem& ) const override; + virtual ScInputStatusItem* Clone( SfxItemPool *pPool = nullptr ) const override; + + const ScAddress& GetPos() const { return aCursorPos; } + + const OUString& GetString() const { return aString; } + const EditTextObject* GetEditData() const { return pEditData.get(); } + + void SetMisspellRanges( const std::vector<editeng::MisspellRanges>* pRanges ); + const std::vector<editeng::MisspellRanges>* GetMisspellRanges() const { return mpMisspellRanges;} +}; + +#define SC_TAB_INSERTED 1 +#define SC_TAB_DELETED 2 +#define SC_TAB_MOVED 3 +#define SC_TAB_COPIED 4 +#define SC_TAB_HIDDEN 5 +#define SC_TABS_INSERTED 6 +#define SC_TABS_DELETED 7 + +class ScTablesHint : public SfxHint +{ + sal_uInt16 nId; + SCTAB nTab1; + SCTAB nTab2; + +public: + ScTablesHint(sal_uInt16 nNewId, SCTAB nTable1, SCTAB nTable2=0); + virtual ~ScTablesHint() override; + + sal_uInt16 GetTablesHintId() const { return nId; } + SCTAB GetTab1() const { return nTab1; } + SCTAB GetTab2() const { return nTab2; } +}; + +class ScEditViewHint : public SfxHint +{ + ScEditEngineDefaulter* pEditEngine; + ScAddress aCursorPos; + +public: + ScEditViewHint() = delete; + ScEditViewHint( ScEditEngineDefaulter* pEngine, const ScAddress& rCurPos ); + virtual ~ScEditViewHint() override; + + SCCOL GetCol() const { return aCursorPos.Col(); } + SCROW GetRow() const { return aCursorPos.Row(); } + SCTAB GetTab() const { return aCursorPos.Tab(); } + ScEditEngineDefaulter* GetEngine() const { return pEditEngine; } +}; + +class ScIndexHint : public SfxHint +{ + sal_uInt16 nIndex; + +public: + ScIndexHint(SfxHintId nNewId, sal_uInt16 nIdx); + virtual ~ScIndexHint() override; + + sal_uInt16 GetIndex() const { return nIndex; } +}; + +// Parameter item for the sort dialog: + +class SC_DLLPUBLIC ScSortItem : public SfxPoolItem +{ +public: + ScSortItem( sal_uInt16 nWhich, + ScViewData* ptrViewData, + const ScSortParam* pSortData ); + ScSortItem( sal_uInt16 nWhich, + const ScSortParam* pSortData ); + + virtual bool operator==( const SfxPoolItem& ) const override; + virtual ScSortItem* Clone( SfxItemPool *pPool = nullptr ) const override; + virtual bool QueryValue( css::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const override; + + ScViewData* GetViewData () const { return pViewData; } + const ScSortParam& GetSortData () const { return theSortData; } + +private: + ScViewData* pViewData; + ScSortParam theSortData; +}; + +class SC_DLLPUBLIC ScQueryItem : public SfxPoolItem +{ +public: + ScQueryItem( sal_uInt16 nWhich, + ScViewData* ptrViewData, + const ScQueryParam* pQueryData ); + ScQueryItem( sal_uInt16 nWhich, + const ScQueryParam* pQueryData ); + ScQueryItem( const ScQueryItem& rItem ); + virtual ~ScQueryItem() override; + + virtual bool operator==( const SfxPoolItem& ) const override; + virtual ScQueryItem* Clone( SfxItemPool *pPool = nullptr ) const override; + + ScViewData* GetViewData () const { return pViewData; } + const ScQueryParam& GetQueryData() const; + + bool GetAdvancedQuerySource(ScRange& rSource) const; + void SetAdvancedQuerySource(const ScRange* pSource); + +private: + std::unique_ptr<ScQueryParam> mpQueryData; + ScViewData* pViewData; + ScRange aAdvSource; + bool bIsAdvanced; +}; + +class SC_DLLPUBLIC ScSubTotalItem : public SfxPoolItem +{ +public: + ScSubTotalItem( sal_uInt16 nWhich, + ScViewData* ptrViewData, + const ScSubTotalParam* pSubTotalData ); + ScSubTotalItem( sal_uInt16 nWhich, + const ScSubTotalParam* pSubTotalData ); + + virtual bool operator==( const SfxPoolItem& ) const override; + virtual ScSubTotalItem* Clone( SfxItemPool *pPool = nullptr ) const override; + virtual bool QueryValue( css::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const override; + + ScViewData* GetViewData () const { return pViewData; } + const ScSubTotalParam& GetSubTotalData() const { return theSubTotalData; } + +private: + ScViewData* pViewData; + ScSubTotalParam theSubTotalData; +}; + +class SC_DLLPUBLIC ScUserListItem : public SfxPoolItem +{ +public: + ScUserListItem( sal_uInt16 nWhich ); + ScUserListItem( const ScUserListItem& rItem ); + virtual ~ScUserListItem() override; + + virtual bool operator==( const SfxPoolItem& ) const override; + virtual ScUserListItem* Clone( SfxItemPool *pPool = nullptr ) const override; + + void SetUserList ( const ScUserList& rUserList ); + ScUserList* GetUserList () const { return pUserList.get(); } + +private: + std::unique_ptr<ScUserList> pUserList; +}; + +class ScConsolidateItem : public SfxPoolItem +{ +public: + ScConsolidateItem( sal_uInt16 nWhich, + const ScConsolidateParam* pParam ); + + virtual bool operator==( const SfxPoolItem& ) const override; + virtual ScConsolidateItem* Clone( SfxItemPool *pPool = nullptr ) const override; + + const ScConsolidateParam& GetData() const { return theConsData; } + +private: + ScConsolidateParam theConsData; +}; + +class ScPivotItem : public SfxPoolItem +{ +public: + ScPivotItem( sal_uInt16 nWhich, const ScDPSaveData* pData, + const ScRange* pRange, bool bNew ); + ScPivotItem( const ScPivotItem& rItem ); + virtual ~ScPivotItem() override; + + virtual bool operator==( const SfxPoolItem& ) const override; + virtual ScPivotItem* Clone( SfxItemPool *pPool = nullptr ) const override; + + const ScDPSaveData& GetData() const { return *pSaveData; } + const ScRange& GetDestRange() const { return aDestRange; } + bool IsNewSheet() const { return bNewSheet; } + +private: + std::unique_ptr<ScDPSaveData> pSaveData; + ScRange aDestRange; + bool bNewSheet; +}; + +class ScSolveItem : public SfxPoolItem +{ +public: + ScSolveItem( sal_uInt16 nWhich, + const ScSolveParam* pParam ); + + virtual bool operator==( const SfxPoolItem& ) const override; + virtual ScSolveItem* Clone( SfxItemPool *pPool = nullptr ) const override; + + const ScSolveParam& GetData() const { return theSolveData; } + +private: + ScSolveParam theSolveData; +}; + +class ScTabOpItem : public SfxPoolItem +{ +public: + ScTabOpItem( sal_uInt16 nWhich, + const ScTabOpParam* pParam ); + + virtual bool operator==( const SfxPoolItem& ) const override; + virtual ScTabOpItem* Clone( SfxItemPool *pPool = nullptr ) const override; + + const ScTabOpParam& GetData() const { return theTabOpData; } + +private: + ScTabOpParam theTabOpData; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/uiobject.hxx b/sc/source/ui/inc/uiobject.hxx new file mode 100644 index 000000000..3f9294329 --- /dev/null +++ b/sc/source/ui/inc/uiobject.hxx @@ -0,0 +1,68 @@ +/* -*- 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/. + */ + +#include <memory> +#include <vcl/uitest/uiobject.hxx> + +class ScGridWindow; +class ScDBFunc; +class ScDrawView; +class ScTabViewShell; + +class ScGridWinUIObject : public WindowUIObject +{ + VclPtr<ScGridWindow> mxGridWindow; + +public: + + ScGridWinUIObject(const VclPtr<ScGridWindow>& xGridWin); + + virtual StringMap get_state() override; + + virtual void execute(const OUString& rAction, + const StringMap& rParameters) override; + + virtual std::unique_ptr<UIObject> get_child(const OUString& rID) override; + + static std::unique_ptr<UIObject> create(vcl::Window* pWindow); + + virtual std::set<OUString> get_children() const override; + +protected: + + virtual OUString get_name() const override; + +private: + + ScDBFunc* getDBFunc(); + ScDrawView* getDrawView(); + ScTabViewShell* getViewShell(); +}; + +class ScNavigatorDlg; + +class ScNavigatorDlgUIObject : public WindowUIObject +{ + VclPtr<ScNavigatorDlg> mxScNavigatorDlg; + +public: + + ScNavigatorDlgUIObject(const VclPtr<ScNavigatorDlg>& xScNavigatorDlg); + + virtual void execute(const OUString& rAction, + const StringMap& rParameters) override; + + static std::unique_ptr<UIObject> create(vcl::Window* pWindow); + +protected: + + virtual OUString get_name() const override; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/undobase.hxx b/sc/source/ui/inc/undobase.hxx new file mode 100644 index 000000000..d497e798e --- /dev/null +++ b/sc/source/ui/inc/undobase.hxx @@ -0,0 +1,181 @@ +/* -*- 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_SC_SOURCE_UI_INC_UNDOBASE_HXX +#define INCLUDED_SC_SOURCE_UI_INC_UNDOBASE_HXX + +#include <svl/undo.hxx> +#include <address.hxx> +#include "docsh.hxx" + +#include <memory> +#include <map> + +class SdrUndoAction; +class ScRefUndoData; +class ScDBData; + +class ScSimpleUndo: public SfxUndoAction +{ + ScSimpleUndo(const ScSimpleUndo&) = delete; + +public: + typedef std::map<SCTAB, std::unique_ptr<sc::ColumnSpanSet>> DataSpansType; + + ScSimpleUndo( ScDocShell* pDocSh ); + + virtual bool Merge( SfxUndoAction *pNextAction ) override; + /// See SfxUndoAction::GetViewShellId(). + ViewShellId GetViewShellId() const override; + +protected: + ScDocShell* pDocShell; + std::unique_ptr<SfxUndoAction> + pDetectiveUndo; + ViewShellId mnViewShellId; + + bool IsPaintLocked() const { return pDocShell->IsPaintLocked(); } + + bool SetViewMarkData( const ScMarkData& rMarkData ); + + void BeginUndo(); + void EndUndo(); + void BeginRedo(); + void EndRedo(); + + void BroadcastChanges( const ScRange& rRange ); + + /** + * Broadcast changes on specified spans. + * + * @param rSpans container that specifies all spans whose changes need to + * be broadcasted. + */ + void BroadcastChanges( const DataSpansType& rSpans ); + + static void ShowTable( SCTAB nTab ); + static void ShowTable( const ScRange& rRange ); +}; + +enum ScBlockUndoMode { SC_UNDO_SIMPLE, SC_UNDO_MANUALHEIGHT, SC_UNDO_AUTOHEIGHT }; + +class ScBlockUndo: public ScSimpleUndo +{ +public: + ScBlockUndo( ScDocShell* pDocSh, const ScRange& rRange, + ScBlockUndoMode eBlockMode ); + virtual ~ScBlockUndo() override; + +protected: + ScRange aBlockRange; + std::unique_ptr<SdrUndoAction> pDrawUndo; + ScBlockUndoMode eMode; + + void BeginUndo(); + void EndUndo(); +// void BeginRedo(); + void EndRedo(); + + bool AdjustHeight(); + void ShowBlock(); +}; + +class ScMultiBlockUndo: public ScSimpleUndo +{ +public: + ScMultiBlockUndo(ScDocShell* pDocSh, const ScRangeList& rRanges); + virtual ~ScMultiBlockUndo() override; + +protected: + ScRangeList maBlockRanges; + std::unique_ptr<SdrUndoAction> mpDrawUndo; + + void BeginUndo(); + void EndUndo(); + void EndRedo(); + + void ShowBlock(); +}; + +// for functions that act on a database range - takes care of the unnamed database range +// (collected separately, before the undo action, for showing dialogs etc.) + +class ScDBFuncUndo: public ScSimpleUndo +{ +protected: + std::unique_ptr<ScDBData> pAutoDBRange; + ScRange aOriginalRange; + +public: + ScDBFuncUndo( ScDocShell* pDocSh, const ScRange& rOriginal ); + virtual ~ScDBFuncUndo() override; + + void BeginUndo(); + void EndUndo(); + void BeginRedo(); + void EndRedo(); +}; + +class ScMoveUndo: public ScSimpleUndo // with references +{ +public: + ScMoveUndo( ScDocShell* pDocSh, + ScDocumentUniquePtr pRefDoc, std::unique_ptr<ScRefUndoData> pRefData ); + virtual ~ScMoveUndo() override; + +protected: + std::unique_ptr<SdrUndoAction> pDrawUndo; + ScDocumentUniquePtr pRefUndoDoc; + std::unique_ptr<ScRefUndoData> pRefUndoData; + + void BeginUndo(); + void EndUndo(); +// void BeginRedo(); +// void EndRedo(); + +private: + void UndoRef(); +}; + +class ScUndoWrapper: public SfxUndoAction // for manual merging of actions +{ + std::unique_ptr<SfxUndoAction> pWrappedUndo; + ViewShellId mnViewShellId; + +public: + ScUndoWrapper( std::unique_ptr<SfxUndoAction> pUndo ); + virtual ~ScUndoWrapper() override; + + SfxUndoAction* GetWrappedUndo() { return pWrappedUndo.get(); } + void ForgetWrappedUndo(); + + virtual void Undo() override; + virtual void Redo() override; + virtual void Repeat(SfxRepeatTarget& rTarget) override; + virtual bool CanRepeat(SfxRepeatTarget& rTarget) const override; + virtual bool Merge( SfxUndoAction *pNextAction ) override; + virtual OUString GetComment() const override; + virtual OUString GetRepeatComment(SfxRepeatTarget&) const override; + /// See SfxUndoAction::GetViewShellId(). + ViewShellId GetViewShellId() const override; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/undoblk.hxx b/sc/source/ui/inc/undoblk.hxx new file mode 100644 index 000000000..a4a8ba034 --- /dev/null +++ b/sc/source/ui/inc/undoblk.hxx @@ -0,0 +1,986 @@ +/* -*- 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_SC_SOURCE_UI_INC_UNDOBLK_HXX +#define INCLUDED_SC_SOURCE_UI_INC_UNDOBLK_HXX + +#include "undobase.hxx" +#include <markdata.hxx> +#include "spellparam.hxx" +#include "cellmergeoption.hxx" +#include <paramisc.hxx> +#include <editeng/boxitem.hxx> + +#include <memory> + +class ScDocShell; +class ScOutlineTable; +class ScPatternAttr; +class SvxSearchItem; +class SdrUndoAction; +class ScEditDataArray; + +class ScUndoInsertCells: public ScMoveUndo +{ +public: + ScUndoInsertCells( ScDocShell* pNewDocShell, + const ScRange& rRange, + SCTAB nNewCount, std::unique_ptr<SCTAB[]> pNewTabs, std::unique_ptr<SCTAB[]> pNewScenarios, + InsCellCmd eNewCmd, ScDocumentUniquePtr pUndoDocument, std::unique_ptr<ScRefUndoData> pRefData, + bool bNewPartOfPaste ); + virtual ~ScUndoInsertCells() override; + + virtual void Undo() override; + virtual void Redo() override; + virtual void Repeat( SfxRepeatTarget& rTarget ) override; + virtual bool CanRepeat( SfxRepeatTarget& rTarget ) const override; + + virtual OUString GetComment() const override; + + virtual bool Merge( SfxUndoAction *pNextAction ) override; + +private: + ScRange aEffRange; + SCTAB nCount; + std::unique_ptr<SCTAB[]> + pTabs; + std::unique_ptr<SCTAB[]> + pScenarios; + sal_uLong nEndChangeAction; + InsCellCmd eCmd; + bool bPartOfPaste; + std::unique_ptr<SfxUndoAction> + pPasteUndo; + + void DoChange ( const bool bUndo ); + void SetChangeTrack(); +}; + +class ScUndoDeleteCells: public ScMoveUndo +{ +public: + ScUndoDeleteCells( ScDocShell* pNewDocShell, + const ScRange& rRange, + SCTAB nNewCount, std::unique_ptr<SCTAB[]> pNewTabs, std::unique_ptr<SCTAB[]> pNewScenarios, + DelCellCmd eNewCmd, ScDocumentUniquePtr pUndoDocument, std::unique_ptr<ScRefUndoData> pRefData ); + virtual ~ScUndoDeleteCells() override; + + virtual void Undo() override; + virtual void Redo() override; + virtual void Repeat(SfxRepeatTarget& rTarget) override; + virtual bool CanRepeat(SfxRepeatTarget& rTarget) const override; + + virtual OUString GetComment() const override; + +private: + ScRange aEffRange; + SCTAB nCount; + std::unique_ptr<SCTAB[]> + pTabs; + std::unique_ptr<SCTAB[]> + pScenarios; + sal_uLong nStartChangeAction; + sal_uLong nEndChangeAction; + DelCellCmd eCmd; + + void DoChange ( const bool bUndo ); + void SetChangeTrack(); +}; + +class ScUndoDeleteMulti: public ScMoveUndo +{ +public: + + ScUndoDeleteMulti( ScDocShell* pNewDocShell, + bool bNewRows, bool bNeedsRefresh, SCTAB nNewTab, + const std::vector<sc::ColRowSpan>& rSpans, + ScDocumentUniquePtr pUndoDocument, std::unique_ptr<ScRefUndoData> pRefData ); + + virtual ~ScUndoDeleteMulti() override; + + virtual void Undo() override; + virtual void Redo() override; + virtual void Repeat(SfxRepeatTarget& rTarget) override; + virtual bool CanRepeat(SfxRepeatTarget& rTarget) const override; + + virtual OUString GetComment() const override; + +private: + bool mbRows:1; + bool mbRefresh:1; + SCTAB nTab; + std::vector<sc::ColRowSpan> maSpans; + sal_uLong nStartChangeAction; + sal_uLong nEndChangeAction; + + void DoChange() const; + void SetChangeTrack(); +}; + +class ScUndoCut: public ScBlockUndo +{ +public: + ScUndoCut(ScDocShell* pNewDocShell, + const ScRange& aRange, // adjusted for merged cells + const ScAddress& aOldEnd, // end position without adjustment + const ScMarkData& rMark, // selected sheets + ScDocumentUniquePtr pNewUndoDoc); + virtual ~ScUndoCut() override; + + virtual void Undo() override; + virtual void Redo() override; + virtual void Repeat(SfxRepeatTarget& rTarget) override; + virtual bool CanRepeat(SfxRepeatTarget& rTarget) const override; + + virtual OUString GetComment() const override; + +private: + ScMarkData aMarkData; + ScDocumentUniquePtr + pUndoDoc; + ScRange aExtendedRange; + sal_uLong nStartChangeAction; + sal_uLong nEndChangeAction; + + void DoChange( const bool bUndo ); + void SetChangeTrack(); +}; + +struct ScUndoPasteOptions +{ + ScPasteFunc nFunction; + bool bSkipEmpty; + bool bTranspose; + bool bAsLink; + InsCellCmd eMoveMode; + + ScUndoPasteOptions() : + nFunction( ScPasteFunc::NONE ), + bSkipEmpty( false ), + bTranspose( false ), + bAsLink( false ), + eMoveMode( INS_NONE ) + {} +}; + +class ScUndoPaste: public ScMultiBlockUndo +{ +public: + ScUndoPaste(ScDocShell* pNewDocShell, const ScRangeList& rRanges, + const ScMarkData& rMark, + ScDocumentUniquePtr pNewUndoDoc, ScDocumentUniquePtr pNewRedoDoc, + InsertDeleteFlags nNewFlags, + std::unique_ptr<ScRefUndoData> pRefData, + bool bRedoIsFilled = true, + const ScUndoPasteOptions* pOptions = nullptr); + virtual ~ScUndoPaste() override; + + virtual void Undo() override; + virtual void Redo() override; + virtual void Repeat(SfxRepeatTarget& rTarget) override; + virtual bool CanRepeat(SfxRepeatTarget& rTarget) const override; + + virtual OUString GetComment() const override; + +private: + ScMarkData aMarkData; + ScDocumentUniquePtr pUndoDoc; + ScDocumentUniquePtr pRedoDoc; + InsertDeleteFlags nFlags; + std::unique_ptr<ScRefUndoData> pRefUndoData; + std::unique_ptr<ScRefUndoData> pRefRedoData; + sal_uLong nStartChangeAction; + sal_uLong nEndChangeAction; + bool bRedoFilled; + ScUndoPasteOptions aPasteOptions; + + void DoChange(bool bUndo); + void SetChangeTrack(); +}; + +class ScUndoDragDrop: public ScMoveUndo +{ +public: + ScUndoDragDrop( ScDocShell* pNewDocShell, + const ScRange& rRange, const ScAddress& aNewDestPos, bool bNewCut, + ScDocumentUniquePtr pUndoDocument, + bool bScenario ); + virtual ~ScUndoDragDrop() override; + + virtual void Undo() override; + virtual void Redo() override; + virtual void Repeat(SfxRepeatTarget& rTarget) override; + virtual bool CanRepeat(SfxRepeatTarget& rTarget) const override; + + virtual OUString GetComment() const override; + +private: + sal_uInt16 mnPaintExtFlags; + ScRangeList maPaintRanges; + + ScRange aSrcRange; + ScRange aDestRange; + sal_uLong nStartChangeAction; + sal_uLong nEndChangeAction; + bool bCut; + bool bKeepScenarioFlags; + + void PaintArea( ScRange aRange, sal_uInt16 nExtFlags ) const; + void DoUndo( ScRange aRange ); + + void SetChangeTrack(); +}; + +class ScUndoDeleteContents: public ScSimpleUndo +{ +public: + ScUndoDeleteContents( ScDocShell* pNewDocShell, + const ScMarkData& rMark, + const ScRange& rRange, + ScDocumentUniquePtr&& pNewUndoDoc, bool bNewMulti, + InsertDeleteFlags nNewFlags, bool bObjects ); + virtual ~ScUndoDeleteContents() override; + + virtual void Undo() override; + virtual void Redo() override; + virtual void Repeat(SfxRepeatTarget& rTarget) override; + virtual bool CanRepeat(SfxRepeatTarget& rTarget) const override; + + virtual OUString GetComment() const override; + + void SetDataSpans( const std::shared_ptr<DataSpansType>& pSpans ); + +private: + std::shared_ptr<DataSpansType> mpDataSpans; // Spans of non-empty cells. + + ScRange aRange; + ScMarkData aMarkData; + ScDocumentUniquePtr pUndoDoc; // Block mark and deleted data + std::unique_ptr<SdrUndoAction> pDrawUndo; // Deleted objects + sal_uLong nStartChangeAction; + sal_uLong nEndChangeAction; + InsertDeleteFlags nFlags; + bool bMulti; // Multi selection + + void DoChange( const bool bUndo ); + void SetChangeTrack(); +}; + +class ScUndoFillTable: public ScSimpleUndo +{ +public: + ScUndoFillTable( ScDocShell* pNewDocShell, + const ScMarkData& rMark, + SCCOL nStartX, SCROW nStartY, SCTAB nStartZ, + SCCOL nEndX, SCROW nEndY, SCTAB nEndZ, + ScDocumentUniquePtr pNewUndoDoc, bool bNewMulti, SCTAB nSrc, + InsertDeleteFlags nFlg, ScPasteFunc nFunc, bool bSkip, bool bLink ); + virtual ~ScUndoFillTable() override; + + virtual void Undo() override; + virtual void Redo() override; + virtual void Repeat(SfxRepeatTarget& rTarget) override; + virtual bool CanRepeat(SfxRepeatTarget& rTarget) const override; + + virtual OUString GetComment() const override; + +private: + ScRange aRange; + ScMarkData aMarkData; + ScDocumentUniquePtr + pUndoDoc; // Block mark and deleted data + sal_uLong nStartChangeAction; + sal_uLong nEndChangeAction; + InsertDeleteFlags nFlags; + ScPasteFunc nFunction; + SCTAB nSrcTab; + bool bMulti; // Multi selection + bool bSkipEmpty; + bool bAsLink; + + void DoChange( const bool bUndo ); + void SetChangeTrack(); +}; + +class ScUndoSelectionAttr: public ScSimpleUndo +{ +public: + ScUndoSelectionAttr( ScDocShell* pNewDocShell, + const ScMarkData& rMark, + SCCOL nStartX, SCROW nStartY, SCTAB nStartZ, + SCCOL nEndX, SCROW nEndY, SCTAB nEndZ, + ScDocumentUniquePtr pNewUndoDoc, bool bNewMulti, + const ScPatternAttr* pNewApply, + const SvxBoxItem* pNewOuter = nullptr, + const SvxBoxInfoItem* pNewInner = nullptr, + const ScRange* pRangeCover = nullptr ); + virtual ~ScUndoSelectionAttr() override; + + virtual void Undo() override; + virtual void Redo() override; + virtual void Repeat(SfxRepeatTarget& rTarget) override; + virtual bool CanRepeat(SfxRepeatTarget& rTarget) const override; + + virtual OUString GetComment() const override; + + ScEditDataArray* GetDataArray(); +private: + ScMarkData aMarkData; + ScRange aRange; + ScRange aRangeCover; + std::unique_ptr<ScEditDataArray> mpDataArray; + ScDocumentUniquePtr pUndoDoc; + bool bMulti; + ScPatternAttr* pApplyPattern; + SvxBoxItem* pLineOuter; + SvxBoxInfoItem* pLineInner; + + void DoChange( const bool bUndo ); + void ChangeEditData( const bool bUndo ); +}; + +class ScUndoWidthOrHeight: public ScSimpleUndo +{ +public: + ScUndoWidthOrHeight( ScDocShell* pNewDocShell, + const ScMarkData& rMark, + SCCOLROW nNewStart, SCTAB nNewStartTab, + SCCOLROW nNewEnd, SCTAB nNewEndTab, + ScDocumentUniquePtr pNewUndoDoc, + const std::vector<sc::ColRowSpan>& rRanges, + std::unique_ptr<ScOutlineTable> pNewUndoTab, + ScSizeMode eNewMode, sal_uInt16 nNewSizeTwips, + bool bNewWidth ); + virtual ~ScUndoWidthOrHeight() override; + + virtual void Undo() override; + virtual void Redo() override; + virtual void Repeat(SfxRepeatTarget& rTarget) override; + virtual bool CanRepeat(SfxRepeatTarget& rTarget) const override; + + virtual OUString GetComment() const override; + +private: + ScMarkData aMarkData; + SCCOLROW nStart; + SCCOLROW nEnd; + SCTAB nStartTab; + SCTAB nEndTab; + ScDocumentUniquePtr pUndoDoc; + std::unique_ptr<ScOutlineTable> pUndoTab; + std::vector<sc::ColRowSpan> maRanges; + sal_uInt16 nNewSize; + bool bWidth; + ScSizeMode eMode; + std::unique_ptr<SdrUndoAction> pDrawUndo; +}; + +class ScUndoAutoFill: public ScBlockUndo +{ +public: + ScUndoAutoFill( ScDocShell* pNewDocShell, + const ScRange& rRange, const ScRange& rSourceArea, + ScDocumentUniquePtr pNewUndoDoc, const ScMarkData& rMark, + FillDir eNewFillDir, + FillCmd eNewFillCmd, FillDateCmd eNewFillDateCmd, + double fNewStartValue, double fNewStepValue, double fNewMaxValue ); + virtual ~ScUndoAutoFill() override; + + virtual void Undo() override; + virtual void Redo() override; + virtual void Repeat(SfxRepeatTarget& rTarget) override; + virtual bool CanRepeat(SfxRepeatTarget& rTarget) const override; + + virtual OUString GetComment() const override; + +private: + ScRange aSource; + ScMarkData aMarkData; + ScDocumentUniquePtr + pUndoDoc; + FillDir eFillDir; + FillCmd eFillCmd; + FillDateCmd eFillDateCmd; + double fStartValue; + double fStepValue; + double fMaxValue; + sal_uLong nStartChangeAction; + sal_uLong nEndChangeAction; + + void SetChangeTrack(); +}; + +class ScUndoMerge: public ScSimpleUndo +{ +public: + ScUndoMerge( ScDocShell* pNewDocShell, const ScCellMergeOption& rOption, + bool bMergeContents, ScDocumentUniquePtr pUndoDoc, + std::unique_ptr<SdrUndoAction> pDrawUndo); + virtual ~ScUndoMerge() override; + + virtual void Undo() override; + virtual void Redo() override; + virtual void Repeat(SfxRepeatTarget& rTarget) override; + virtual bool CanRepeat(SfxRepeatTarget& rTarget) const override; + + virtual OUString GetComment() const override; + +private: + ScCellMergeOption maOption; + bool mbMergeContents; // Merge contents in Redo(). + ScDocumentUniquePtr mxUndoDoc; // when data is merged + std::unique_ptr<SdrUndoAction> mpDrawUndo; + + void DoChange( bool bUndo ) const; +}; + +class ScUndoAutoFormat: public ScBlockUndo +{ +public: + ScUndoAutoFormat( ScDocShell* pNewDocShell, + const ScRange& rRange, ScDocumentUniquePtr pNewUndoDoc, + const ScMarkData& rMark, + bool bNewSize, sal_uInt16 nNewFormatNo ); + virtual ~ScUndoAutoFormat() override; + + virtual void Undo() override; + virtual void Redo() override; + virtual void Repeat(SfxRepeatTarget& rTarget) override; + virtual bool CanRepeat(SfxRepeatTarget& rTarget) const override; + + virtual OUString GetComment() const override; + +private: + ScDocumentUniquePtr + pUndoDoc; // deleted data + ScMarkData aMarkData; + bool bSize; + sal_uInt16 nFormatNo; +}; + +class ScUndoReplace: public ScSimpleUndo +{ +public: + ScUndoReplace( ScDocShell* pNewDocShell, + const ScMarkData& rMark, + SCCOL nCurX, SCROW nCurY, SCTAB nCurZ, + const OUString& rNewUndoStr, ScDocumentUniquePtr pNewUndoDoc, + const SvxSearchItem* pItem ); + virtual ~ScUndoReplace() override; + + virtual void Undo() override; + virtual void Redo() override; + virtual void Repeat(SfxRepeatTarget& rTarget) override; + virtual bool CanRepeat(SfxRepeatTarget& rTarget) const override; + + virtual OUString GetComment() const override; + +private: + ScAddress aCursorPos; + ScMarkData aMarkData; + OUString aUndoStr; // Data at single selection + ScDocumentUniquePtr pUndoDoc; // Block mark and deleted data + std::unique_ptr<SvxSearchItem> pSearchItem; + sal_uLong nStartChangeAction; + sal_uLong nEndChangeAction; + + void SetChangeTrack(); +}; + +class ScUndoTabOp: public ScSimpleUndo +{ +public: + ScUndoTabOp( ScDocShell* pNewDocShell, + SCCOL nStartX, SCROW nStartY, SCTAB nStartZ, + SCCOL nEndX, SCROW nEndY, SCTAB nEndZ, + ScDocumentUniquePtr pNewUndoDoc, + const ScRefAddress& rFormulaCell, + const ScRefAddress& rFormulaEnd, + const ScRefAddress& rRowCell, + const ScRefAddress& rColCell, + ScTabOpParam::Mode eMode ); + virtual ~ScUndoTabOp() override; + + virtual void Undo() override; + virtual void Redo() override; + virtual void Repeat(SfxRepeatTarget& rTarget) override; + virtual bool CanRepeat(SfxRepeatTarget& rTarget) const override; + + virtual OUString GetComment() const override; + +private: + ScRange aRange; + ScDocumentUniquePtr + pUndoDoc; // Deleted data + ScRefAddress theFormulaCell; + ScRefAddress theFormulaEnd; + ScRefAddress theRowCell; + ScRefAddress theColCell; + ScTabOpParam::Mode meMode; +}; + +class ScUndoConversion : public ScSimpleUndo +{ +public: + + ScUndoConversion( ScDocShell* pNewDocShell, const ScMarkData& rMark, + SCCOL nCurX, SCROW nCurY, SCTAB nCurZ, ScDocumentUniquePtr pNewUndoDoc, + SCCOL nNewX, SCROW nNewY, SCTAB nNewZ, ScDocumentUniquePtr pNewRedoDoc, + const ScConversionParam& rConvParam ); + virtual ~ScUndoConversion() override; + + virtual void Undo() override; + virtual void Redo() override; + virtual void Repeat(SfxRepeatTarget& rTarget) override; + virtual bool CanRepeat(SfxRepeatTarget& rTarget) const override; + + virtual OUString GetComment() const override; + +private: + ScMarkData aMarkData; + ScAddress aCursorPos; + ScDocumentUniquePtr pUndoDoc; // Block mark and deleted data + ScAddress aNewCursorPos; + ScDocumentUniquePtr pRedoDoc; // Block mark and new data + sal_uLong nStartChangeAction; + sal_uLong nEndChangeAction; + ScConversionParam maConvParam; /// Conversion type and parameters. + + void DoChange( ScDocument* pRefDoc, const ScAddress& rCursorPos ); + void SetChangeTrack(); +}; + +class ScUndoRefConversion: public ScSimpleUndo +{ +public: + ScUndoRefConversion( ScDocShell* pNewDocShell, + const ScRange& aMarkRange, const ScMarkData& rMark, + ScDocumentUniquePtr pNewUndoDoc, ScDocumentUniquePtr pNewRedoDoc, bool bNewMulti); + virtual ~ScUndoRefConversion() override; + + virtual void Undo() override; + virtual void Redo() override; + virtual void Repeat(SfxRepeatTarget& rTarget) override; + virtual bool CanRepeat(SfxRepeatTarget& rTarget) const override; + + virtual OUString GetComment() const override; + +private: + ScMarkData aMarkData; + ScDocumentUniquePtr pUndoDoc; + ScDocumentUniquePtr pRedoDoc; + ScRange aRange; + bool bMulti; + sal_uLong nStartChangeAction; + sal_uLong nEndChangeAction; + + void DoChange( ScDocument* pRefDoc); + void SetChangeTrack(); +}; + +class ScUndoListNames: public ScBlockUndo +{ +public: + ScUndoListNames(ScDocShell* pNewDocShell, + const ScRange& rRange, + ScDocumentUniquePtr pNewUndoDoc, ScDocumentUniquePtr pNewRedoDoc); + + virtual void Undo() override; + virtual void Redo() override; + virtual void Repeat(SfxRepeatTarget& rTarget) override; + virtual bool CanRepeat(SfxRepeatTarget& rTarget) const override; + + virtual OUString GetComment() const override; + +private: + ScDocumentUniquePtr xUndoDoc; + ScDocumentUniquePtr xRedoDoc; + + void DoChange( ScDocument* pSrcDoc ) const; +}; + +class ScUndoConditionalFormat : public ScSimpleUndo +{ +public: + ScUndoConditionalFormat( ScDocShell* pNewDocShell, + ScDocumentUniquePtr pUndoDoc, ScDocumentUniquePtr pRedoDoc, const ScRange& rRange); + virtual ~ScUndoConditionalFormat() override; + + virtual void Undo() override; + virtual void Redo() override; + virtual void Repeat(SfxRepeatTarget& rTarget) override; + virtual bool CanRepeat(SfxRepeatTarget& rTarget) const override; + + virtual OUString GetComment() const override; + +private: + void DoChange(ScDocument* pDoc); + ScDocumentUniquePtr mpUndoDoc; + ScDocumentUniquePtr mpRedoDoc; + ScRange maRange; +}; + +class ScUndoConditionalFormatList : public ScSimpleUndo +{ +public: + ScUndoConditionalFormatList( ScDocShell* pNewDocShell, + ScDocumentUniquePtr pUndoDoc, ScDocumentUniquePtr pRedoDoc, SCTAB nTab); + virtual ~ScUndoConditionalFormatList() override; + + virtual void Undo() override; + virtual void Redo() override; + virtual void Repeat(SfxRepeatTarget& rTarget) override; + virtual bool CanRepeat(SfxRepeatTarget& rTarget) const override; + + virtual OUString GetComment() const override; + +private: + void DoChange(const ScDocument* pDoc); + ScDocumentUniquePtr mpUndoDoc; + ScDocumentUniquePtr mpRedoDoc; + SCTAB mnTab; +}; + +class ScUndoUseScenario: public ScSimpleUndo +{ +public: + ScUndoUseScenario( ScDocShell* pNewDocShell, + const ScMarkData& rMark, + const ScArea& rDestArea, ScDocumentUniquePtr pNewUndoDoc, + const OUString& rNewName ); + virtual ~ScUndoUseScenario() override; + + virtual void Undo() override; + virtual void Redo() override; + virtual void Repeat(SfxRepeatTarget& rTarget) override; + virtual bool CanRepeat(SfxRepeatTarget& rTarget) const override; + + virtual OUString GetComment() const override; + +private: + ScDocumentUniquePtr + pUndoDoc; + ScRange aRange; + ScMarkData aMarkData; + OUString aName; +}; + +class ScUndoSelectionStyle: public ScSimpleUndo +{ +public: + ScUndoSelectionStyle( ScDocShell* pNewDocShell, + const ScMarkData& rMark, + const ScRange& rRange, + const OUString& rName, + ScDocumentUniquePtr pNewUndoDoc ); + virtual ~ScUndoSelectionStyle() override; + + virtual void Undo() override; + virtual void Redo() override; + virtual void Repeat(SfxRepeatTarget& rTarget) override; + virtual bool CanRepeat(SfxRepeatTarget& rTarget) const override; + + virtual OUString GetComment() const override; + +private: + ScMarkData aMarkData; + ScDocumentUniquePtr + pUndoDoc; + OUString aStyleName; + ScRange aRange; + + void DoChange( const bool bUndo ); +}; + +class ScUndoRefreshLink: public ScSimpleUndo +{ +public: + ScUndoRefreshLink(ScDocShell* pNewDocShell, + ScDocumentUniquePtr pNewUndoDoc); + + virtual void Undo() override; + virtual void Redo() override; + virtual void Repeat(SfxRepeatTarget& rTarget) override; + virtual bool CanRepeat(SfxRepeatTarget& rTarget) const override; + + virtual OUString GetComment() const override; + +private: + ScDocumentUniquePtr xUndoDoc; + ScDocumentUniquePtr xRedoDoc; +}; + +class ScUndoEnterMatrix: public ScBlockUndo +{ +public: + ScUndoEnterMatrix( ScDocShell* pNewDocShell, + const ScRange& rArea, + ScDocumentUniquePtr pNewUndoDoc, + const OUString& rForm ); + virtual ~ScUndoEnterMatrix() override; + + virtual void Undo() override; + virtual void Redo() override; + virtual void Repeat(SfxRepeatTarget& rTarget) override; + virtual bool CanRepeat(SfxRepeatTarget& rTarget) const override; + + virtual OUString GetComment() const override; + +private: + ScDocumentUniquePtr + pUndoDoc; + OUString aFormula; + sal_uLong nStartChangeAction; + sal_uLong nEndChangeAction; + + void SetChangeTrack(); +}; + +class ScUndoInsertAreaLink : public ScSimpleUndo +{ +public: + ScUndoInsertAreaLink( ScDocShell* pShell, + const OUString& rDocName, + const OUString& rFltName, const OUString& rOptions, + const OUString& rAreaName, const ScRange& rDestRange, + sal_uLong nRefreshDelay ); + virtual ~ScUndoInsertAreaLink() override; + + virtual void Undo() override; + virtual void Redo() override; + virtual void Repeat(SfxRepeatTarget& rTarget) override; + virtual bool CanRepeat(SfxRepeatTarget& rTarget) const override; + + virtual OUString GetComment() const override; + +private: + OUString aDocName; + OUString aFltName; + OUString aOptions; + OUString aAreaName; + ScRange aRange; + sal_uLong nRefreshDelay; +}; + +class ScUndoRemoveAreaLink : public ScSimpleUndo +{ +public: + ScUndoRemoveAreaLink( ScDocShell* pShell, + const OUString& rDocName, + const OUString& rFltName, const OUString& rOptions, + const OUString& rAreaName, const ScRange& rDestRange, + sal_uLong nRefreshDelay ); + virtual ~ScUndoRemoveAreaLink() override; + + virtual void Undo() override; + virtual void Redo() override; + virtual void Repeat(SfxRepeatTarget& rTarget) override; + virtual bool CanRepeat(SfxRepeatTarget& rTarget) const override; + + virtual OUString GetComment() const override; + +private: + OUString aDocName; + OUString aFltName; + OUString aOptions; + OUString aAreaName; + ScRange aRange; + sal_uLong nRefreshDelay; +}; + +class ScUndoUpdateAreaLink : public ScSimpleUndo //! also change BlockUndo? +{ +public: + ScUndoUpdateAreaLink(ScDocShell* pShell, + const OUString& rOldD, + const OUString& rOldF, const OUString& rOldO, + const OUString& rOldA, const ScRange& rOldR, + sal_uLong nOldRD, + const OUString& rNewD, + const OUString& rNewF, const OUString& rNewO, + const OUString& rNewA, const ScRange& rNewR, + sal_uLong nNewRD, + ScDocumentUniquePtr pUndo, ScDocumentUniquePtr pRedo, + bool bDoInsert); + + virtual void Undo() override; + virtual void Redo() override; + virtual void Repeat(SfxRepeatTarget& rTarget) override; + virtual bool CanRepeat(SfxRepeatTarget& rTarget) const override; + + virtual OUString GetComment() const override; + +private: + OUString aOldDoc; + OUString aOldFlt; + OUString aOldOpt; + OUString aOldArea; + ScRange aOldRange; + OUString aNewDoc; + OUString aNewFlt; + OUString aNewOpt; + OUString aNewArea; + ScRange aNewRange; + ScDocumentUniquePtr xUndoDoc; + ScDocumentUniquePtr xRedoDoc; + sal_uLong nOldRefresh; + sal_uLong nNewRefresh; + bool bWithInsert; + + void DoChange( const bool bUndo ) const; +}; + +class ScUndoIndent: public ScBlockUndo +{ +public: + ScUndoIndent( ScDocShell* pNewDocShell, const ScMarkData& rMark, + ScDocumentUniquePtr pNewUndoDoc, bool bIncrement ); + virtual ~ScUndoIndent() override; + + virtual void Undo() override; + virtual void Redo() override; + virtual void Repeat(SfxRepeatTarget& rTarget) override; + virtual bool CanRepeat(SfxRepeatTarget& rTarget) const override; + + virtual OUString GetComment() const override; + +private: + ScMarkData aMarkData; + ScDocumentUniquePtr + pUndoDoc; + bool bIsIncrement; +}; + +class ScUndoTransliterate: public ScBlockUndo +{ +public: + ScUndoTransliterate( ScDocShell* pNewDocShell, const ScMarkData& rMark, + ScDocumentUniquePtr pNewUndoDoc, TransliterationFlags nType ); + virtual ~ScUndoTransliterate() override; + + virtual void Undo() override; + virtual void Redo() override; + virtual void Repeat(SfxRepeatTarget& rTarget) override; + virtual bool CanRepeat(SfxRepeatTarget& rTarget) const override; + + virtual OUString GetComment() const override; + +private: + ScMarkData aMarkData; + ScDocumentUniquePtr + pUndoDoc; + TransliterationFlags + nTransliterationType; +}; + +class ScUndoClearItems: public ScBlockUndo +{ +public: + ScUndoClearItems( ScDocShell* pNewDocShell, const ScMarkData& rMark, + ScDocumentUniquePtr pNewUndoDoc, const sal_uInt16* pW ); + virtual ~ScUndoClearItems() override; + + virtual void Undo() override; + virtual void Redo() override; + virtual void Repeat(SfxRepeatTarget& rTarget) override; + virtual bool CanRepeat(SfxRepeatTarget& rTarget) const override; + + virtual OUString GetComment() const override; + +private: + ScMarkData aMarkData; + ScDocumentUniquePtr + pUndoDoc; + std::unique_ptr<sal_uInt16[]> + pWhich; +}; + +class ScUndoRemoveBreaks: public ScSimpleUndo +{ +public: + ScUndoRemoveBreaks( ScDocShell* pNewDocShell, + SCTAB nNewTab, ScDocumentUniquePtr pNewUndoDoc ); + virtual ~ScUndoRemoveBreaks() override; + + virtual void Undo() override; + virtual void Redo() override; + virtual void Repeat(SfxRepeatTarget& rTarget) override; + virtual bool CanRepeat(SfxRepeatTarget& rTarget) const override; + + virtual OUString GetComment() const override; + +private: + SCTAB nTab; + ScDocumentUniquePtr + pUndoDoc; +}; + +class ScUndoRemoveMerge: public ScBlockUndo +{ +public: + ScUndoRemoveMerge( ScDocShell* pNewDocShell, + const ScCellMergeOption& rOption, + ScDocumentUniquePtr pNewUndoDoc ); + ScUndoRemoveMerge( ScDocShell* pNewDocShell, + const ScRange& rRange, + ScDocumentUniquePtr pNewUndoDoc ); + virtual ~ScUndoRemoveMerge() override; + + virtual void Undo() override; + virtual void Redo() override; + virtual void Repeat(SfxRepeatTarget& rTarget) override; + virtual bool CanRepeat(SfxRepeatTarget& rTarget) const override; + + virtual OUString GetComment() const override; + + ScDocument* GetUndoDoc(); + void AddCellMergeOption( const ScCellMergeOption& rOption ); + +private: + void SetCurTab(); + + std::vector<ScCellMergeOption> maOptions; + ScDocumentUniquePtr pUndoDoc; +}; + +class ScUndoBorder: public ScBlockUndo +{ +public: + ScUndoBorder(ScDocShell* pNewDocShell, + const ScRangeList& rRangeList, + ScDocumentUniquePtr pNewUndoDoc, + const SvxBoxItem& rNewOuter, + const SvxBoxInfoItem& rNewInner); + + virtual void Undo() override; + virtual void Redo() override; + virtual void Repeat(SfxRepeatTarget& rTarget) override; + virtual bool CanRepeat(SfxRepeatTarget& rTarget) const override; + + virtual OUString GetComment() const override; + +private: + ScDocumentUniquePtr xUndoDoc; + std::unique_ptr<ScRangeList> xRanges; + std::unique_ptr<SvxBoxItem> xOuter; + std::unique_ptr<SvxBoxInfoItem> xInner; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/undocell.hxx b/sc/source/ui/inc/undocell.hxx new file mode 100644 index 000000000..aebd1eabe --- /dev/null +++ b/sc/source/ui/inc/undocell.hxx @@ -0,0 +1,372 @@ +/* -*- 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_SC_SOURCE_UI_INC_UNDOCELL_HXX +#define INCLUDED_SC_SOURCE_UI_INC_UNDOCELL_HXX + +#include "undobase.hxx" +#include <detdata.hxx> +#include <postit.hxx> +#include <cellvalue.hxx> +#include <cellvalues.hxx> +#include <editeng/editobj.hxx> + +#include <memory> + +class ScDocShell; +class ScPatternAttr; +class ScRangeName; +class ScFormulaCell; + +class ScUndoCursorAttr: public ScSimpleUndo +{ +public: + ScUndoCursorAttr( ScDocShell* pNewDocShell, + SCCOL nNewCol, SCROW nNewRow, SCTAB nNewTab, + const ScPatternAttr* pOldPat, const ScPatternAttr* pNewPat, + const ScPatternAttr* pApplyPat ); + virtual ~ScUndoCursorAttr() override; + + virtual void Undo() override; + virtual void Redo() override; + virtual void Repeat(SfxRepeatTarget& rTarget) override; + virtual bool CanRepeat(SfxRepeatTarget& rTarget) const override; + + virtual OUString GetComment() const override; + + /** once the objects are passed to this class, their life-cycle is + managed by this class; the calling function must pass new'ed + objects to this method. */ + void SetEditData( std::unique_ptr<EditTextObject> pOld, std::unique_ptr<EditTextObject> pNew ); + +private: + SCCOL nCol; + SCROW nRow; + SCTAB nTab; + ScPatternAttr* pOldPattern; + ScPatternAttr* pNewPattern; + ScPatternAttr* pApplyPattern; + std::unique_ptr<EditTextObject> pOldEditData; + std::unique_ptr<EditTextObject> pNewEditData; + + void DoChange( const ScPatternAttr* pWhichPattern, const std::unique_ptr<EditTextObject>& pEditData ) const; +}; + +class ScUndoEnterData: public ScSimpleUndo +{ +public: + + struct Value + { + SCTAB mnTab; + bool mbHasFormat; + sal_uInt32 mnFormat; + ScCellValue maCell; + + Value(); + }; + + typedef std::vector<Value> ValuesType; + + ScUndoEnterData( + ScDocShell* pNewDocShell, const ScAddress& rPos, + ValuesType& rOldValues, const OUString& rNewStr, std::unique_ptr<EditTextObject> pObj ); + + virtual void Undo() override; + virtual void Redo() override; + virtual void Repeat(SfxRepeatTarget& rTarget) override; + virtual bool CanRepeat(SfxRepeatTarget& rTarget) const override; + + virtual OUString GetComment() const override; + +private: + ValuesType maOldValues; + + OUString maNewString; + std::unique_ptr<EditTextObject> mpNewEditData; + sal_uLong mnEndChangeAction; + ScAddress maPos; + + void DoChange() const; + void SetChangeTrack(); +}; + +class ScUndoEnterValue: public ScSimpleUndo +{ +public: + ScUndoEnterValue( + ScDocShell* pNewDocShell, const ScAddress& rNewPos, + const ScCellValue& rUndoCell, double nVal ); + + virtual ~ScUndoEnterValue() override; + + virtual void Undo() override; + virtual void Redo() override; + virtual void Repeat(SfxRepeatTarget& rTarget) override; + virtual bool CanRepeat(SfxRepeatTarget& rTarget) const override; + + virtual OUString GetComment() const override; + +private: + ScAddress aPos; + ScCellValue maOldCell; + double nValue; + sal_uLong nEndChangeAction; + + void SetChangeTrack(); +}; + +class ScUndoSetCell : public ScSimpleUndo +{ +public: + ScUndoSetCell( ScDocShell* pDocSh, const ScAddress& rPos, const ScCellValue& rOldVal, const ScCellValue& rNewVal ); + + virtual ~ScUndoSetCell() override; + + virtual void Undo() override; + virtual void Redo() override; + virtual void Repeat( SfxRepeatTarget& rTarget ) override; + virtual bool CanRepeat( SfxRepeatTarget& rTarget ) const override; + virtual OUString GetComment() const override; + +private: + void SetChangeTrack(); + void SetValue( const ScCellValue& rVal ); + void MoveCursorToCell(); + +private: + ScAddress maPos; + ScCellValue maOldValue; + ScCellValue maNewValue; + sal_uLong mnEndChangeAction; +}; + +class ScUndoPageBreak: public ScSimpleUndo +{ +public: + ScUndoPageBreak( ScDocShell* pNewDocShell, + SCCOL nNewCol, SCROW nNewRow, SCTAB nNewTab, + bool bNewColumn, bool bNewInsert ); + virtual ~ScUndoPageBreak() override; + + virtual void Undo() override; + virtual void Redo() override; + virtual void Repeat(SfxRepeatTarget& rTarget) override; + virtual bool CanRepeat(SfxRepeatTarget& rTarget) const override; + + virtual OUString GetComment() const override; + +private: + SCCOL nCol; + SCROW nRow; + SCTAB nTab; + bool bColumn; // Column or row break + bool bInsert; // Insert or Delete + + void DoChange( bool bInsert ) const; +}; + +class ScUndoPrintZoom: public ScSimpleUndo +{ +public: + ScUndoPrintZoom( ScDocShell* pNewDocShell, SCTAB nT, + sal_uInt16 nOS, sal_uInt16 nOP, sal_uInt16 nNS, sal_uInt16 nNP ); + virtual ~ScUndoPrintZoom() override; + + virtual void Undo() override; + virtual void Redo() override; + virtual void Repeat(SfxRepeatTarget& rTarget) override; + virtual bool CanRepeat(SfxRepeatTarget& rTarget) const override; + + virtual OUString GetComment() const override; + +private: + SCTAB nTab; + sal_uInt16 nOldScale; + sal_uInt16 nOldPages; + sal_uInt16 nNewScale; + sal_uInt16 nNewPages; + + void DoChange( bool bUndo ); +}; + +class ScUndoThesaurus: public ScSimpleUndo +{ +public: + ScUndoThesaurus( ScDocShell* pNewDocShell, + SCCOL nNewCol, SCROW nNewRow, SCTAB nNewTab, + const ScCellValue& rOldText, const ScCellValue& rNewText ); + virtual ~ScUndoThesaurus() override; + + virtual void Undo() override; + virtual void Redo() override; + virtual void Repeat(SfxRepeatTarget& rTarget) override; + virtual bool CanRepeat(SfxRepeatTarget& rTarget) const override; + + virtual OUString GetComment() const override; + +private: + SCCOL nCol; + SCROW nRow; + SCTAB nTab; + sal_uLong nEndChangeAction; + + ScCellValue maOldText; + ScCellValue maNewText; + + void DoChange( bool bUndo, const ScCellValue& rText ); + void SetChangeTrack( const ScCellValue& rOldCell ); +}; + +/** Undo action for inserting, removing, and replacing a cell note. */ +class ScUndoReplaceNote : public ScSimpleUndo +{ +public: + + /** Constructs an undo action for inserting or removing a cell note. */ + ScUndoReplaceNote( + ScDocShell& rDocShell, + const ScAddress& rPos, + const ScNoteData& rNoteData, + bool bInsert, + std::unique_ptr<SdrUndoAction> pDrawUndo ); + + /** Constructs an undo action for replacing a cell note with another. */ + ScUndoReplaceNote( + ScDocShell& rDocShell, + const ScAddress& rPos, + const ScNoteData& rOldData, + const ScNoteData& rNewData, + std::unique_ptr<SdrUndoAction> pDrawUndo ); + + virtual ~ScUndoReplaceNote() override; + + virtual void Undo() override; + virtual void Redo() override; + virtual void Repeat( SfxRepeatTarget& rTarget ) override; + virtual bool CanRepeat( SfxRepeatTarget& rTarget ) const override; + + virtual OUString GetComment() const override; + +private: + void DoInsertNote( const ScNoteData& rNoteData ); + void DoRemoveNote( const ScNoteData& rNoteData ); + +private: + ScAddress maPos; + ScNoteData maOldData; + ScNoteData maNewData; + std::unique_ptr<SdrUndoAction> mpDrawUndo; +}; + +/** Undo action for showing or hiding a cell note caption. */ +class ScUndoShowHideNote : public ScSimpleUndo +{ +public: + ScUndoShowHideNote( ScDocShell& rDocShell, const ScAddress& rPos, bool bShow ); + virtual ~ScUndoShowHideNote() override; + + virtual void Undo() override; + virtual void Redo() override; + virtual void Repeat( SfxRepeatTarget& rTarget ) override; + virtual bool CanRepeat( SfxRepeatTarget& rTarget ) const override; + + virtual OUString GetComment() const override; + +private: + ScAddress maPos; + bool mbShown; +}; + +class ScUndoDetective: public ScSimpleUndo +{ +public: + ScUndoDetective( ScDocShell* pNewDocShell, + std::unique_ptr<SdrUndoAction> pDraw, const ScDetOpData* pOperation, + std::unique_ptr<ScDetOpList> pUndoList = nullptr ); + virtual ~ScUndoDetective() override; + + virtual void Undo() override; + virtual void Redo() override; + virtual void Repeat(SfxRepeatTarget& rTarget) override; + virtual bool CanRepeat(SfxRepeatTarget& rTarget) const override; + + virtual OUString GetComment() const override; + +private: + bool bIsDelete; + std::unique_ptr<ScDetOpList> pOldList; + sal_uInt16 nAction; + ScAddress aPos; + std::unique_ptr<SdrUndoAction> pDrawUndo; +}; + +class ScUndoRangeNames: public ScSimpleUndo +{ +public: + //use nTab = -1 for global range names + ScUndoRangeNames( ScDocShell* pNewDocShell, + std::unique_ptr<ScRangeName> pOld, std::unique_ptr<ScRangeName> pNew , SCTAB nTab); + virtual ~ScUndoRangeNames() override; + + virtual void Undo() override; + virtual void Redo() override; + virtual void Repeat(SfxRepeatTarget& rTarget) override; + virtual bool CanRepeat(SfxRepeatTarget& rTarget) const override; + + virtual OUString GetComment() const override; + +private: + std::unique_ptr<ScRangeName> pOldRanges; + std::unique_ptr<ScRangeName> pNewRanges; + SCTAB mnTab; + + void DoChange( bool bUndo ); +}; + +namespace sc { + +class UndoSetCells : public ScSimpleUndo +{ + ScAddress maTopPos; + CellValues maOldValues; + CellValues maNewValues; + + void DoChange( const CellValues& rValues ); + +public: + UndoSetCells( ScDocShell* pDocSh, const ScAddress& rTopPos ); + virtual ~UndoSetCells() override; + + virtual void Undo() override; + virtual void Redo() override; + + virtual bool CanRepeat( SfxRepeatTarget& ) const override; + virtual OUString GetComment() const override; + + CellValues& GetOldValues() { return maOldValues;} + void SetNewValues( const std::vector<double>& rVals ); + void SetNewValues( const std::vector<ScFormulaCell*>& rVals ); +}; + +} // namespace sc + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/undoconvert.hxx b/sc/source/ui/inc/undoconvert.hxx new file mode 100644 index 000000000..d792cde71 --- /dev/null +++ b/sc/source/ui/inc/undoconvert.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_SC_UNDOCONVERT_HXX +#define INCLUDED_SC_UNDOCONVERT_HXX + +#include "undobase.hxx" +#include <cellvalues.hxx> + +namespace sc { + +class UndoFormulaToValue : public ScSimpleUndo +{ + TableValues maUndoValues; + +public: + UndoFormulaToValue( ScDocShell* pDocSh, TableValues& rUndoValues ); + + virtual OUString GetComment() const override; + virtual void Undo() override; + virtual void Redo() override; + +private: + void Execute(); +}; + +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/undodat.hxx b/sc/source/ui/inc/undodat.hxx new file mode 100644 index 000000000..6cde8b10e --- /dev/null +++ b/sc/source/ui/inc/undodat.hxx @@ -0,0 +1,449 @@ +/* -*- 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_SC_SOURCE_UI_INC_UNDODAT_HXX +#define INCLUDED_SC_SOURCE_UI_INC_UNDODAT_HXX + +#include "undobase.hxx" +#include "refundo.hxx" +#include <dpobject.hxx> +#include <olinetab.hxx> +#include <rangeutl.hxx> +#include <rangelst.hxx> +#include <queryparam.hxx> +#include <subtotalparam.hxx> + +#include <memory> + +class ScDocShell; +class SdrUndoAction; + +class ScUndoDoOutline: public ScSimpleUndo +{ +public: + ScUndoDoOutline( ScDocShell* pNewDocShell, + SCCOLROW nNewStart, SCCOLROW nNewEnd, SCTAB nNewTab, + ScDocumentUniquePtr pNewUndoDoc, bool bNewColumns, + sal_uInt16 nNewLevel, sal_uInt16 nNewEntry, bool bNewShow ); + virtual ~ScUndoDoOutline() override; + + virtual void Undo() override; + virtual void Redo() override; + virtual void Repeat(SfxRepeatTarget& rTarget) override; + virtual bool CanRepeat(SfxRepeatTarget& rTarget) const override; + + virtual OUString GetComment() const override; + +private: + SCCOLROW nStart; + SCCOLROW nEnd; + SCTAB nTab; + ScDocumentUniquePtr + pUndoDoc; + bool bColumns; + sal_uInt16 nLevel; + sal_uInt16 nEntry; + bool bShow; +}; + +class ScUndoMakeOutline: public ScSimpleUndo +{ +public: + ScUndoMakeOutline( ScDocShell* pNewDocShell, + SCCOL nStartX, SCROW nStartY, SCTAB nStartZ, + SCCOL nEndX, SCROW nEndY, SCTAB nEndZ, + std::unique_ptr<ScOutlineTable> pNewUndoTab, + bool bNewColumns, bool bNewMake ); + virtual ~ScUndoMakeOutline() override; + + virtual void Undo() override; + virtual void Redo() override; + virtual void Repeat(SfxRepeatTarget& rTarget) override; + virtual bool CanRepeat(SfxRepeatTarget& rTarget) const override; + + virtual OUString GetComment() const override; + +private: + ScAddress aBlockStart; + ScAddress aBlockEnd; + std::unique_ptr<ScOutlineTable> + pUndoTable; + bool bColumns; + bool bMake; +}; + +class ScUndoOutlineLevel: public ScSimpleUndo +{ +public: + ScUndoOutlineLevel(ScDocShell* pNewDocShell, + SCCOLROW nNewStart, SCCOLROW nNewEnd, SCTAB nNewTab, + ScDocumentUniquePtr pNewUndoDoc, std::unique_ptr<ScOutlineTable> pNewUndoTab, + bool bNewColumns, sal_uInt16 nNewLevel); + + virtual void Undo() override; + virtual void Redo() override; + virtual void Repeat(SfxRepeatTarget& rTarget) override; + virtual bool CanRepeat(SfxRepeatTarget& rTarget) const override; + + virtual OUString GetComment() const override; + +private: + SCCOLROW nStart; + SCCOLROW nEnd; + SCTAB nTab; + ScDocumentUniquePtr xUndoDoc; + std::unique_ptr<ScOutlineTable> xUndoTable; + bool bColumns; + sal_uInt16 nLevel; +}; + +class ScUndoOutlineBlock: public ScSimpleUndo +{ +public: + ScUndoOutlineBlock(ScDocShell* pNewDocShell, + SCCOL nStartX, SCROW nStartY, SCTAB nStartZ, + SCCOL nEndX, SCROW nEndY, SCTAB nEndZ, + ScDocumentUniquePtr pNewUndoDoc, std::unique_ptr<ScOutlineTable> pNewUndoTab, + bool bNewShow); + + virtual void Undo() override; + virtual void Redo() override; + virtual void Repeat(SfxRepeatTarget& rTarget) override; + virtual bool CanRepeat(SfxRepeatTarget& rTarget) const override; + + virtual OUString GetComment() const override; + +private: + ScAddress aBlockStart; + ScAddress aBlockEnd; + ScDocumentUniquePtr xUndoDoc; + std::unique_ptr<ScOutlineTable> xUndoTable; + bool bShow; +}; + +class ScUndoRemoveAllOutlines: public ScSimpleUndo +{ +public: + ScUndoRemoveAllOutlines(ScDocShell* pNewDocShell, + SCCOL nStartX, SCROW nStartY, SCTAB nStartZ, + SCCOL nEndX, SCROW nEndY, SCTAB nEndZ, + ScDocumentUniquePtr pNewUndoDoc, std::unique_ptr<ScOutlineTable> pNewUndoTab); + + virtual void Undo() override; + virtual void Redo() override; + virtual void Repeat(SfxRepeatTarget& rTarget) override; + virtual bool CanRepeat(SfxRepeatTarget& rTarget) const override; + + virtual OUString GetComment() const override; + +private: + ScAddress aBlockStart; + ScAddress aBlockEnd; + ScDocumentUniquePtr xUndoDoc; + std::unique_ptr<ScOutlineTable> xUndoTable; +}; + +class ScUndoAutoOutline: public ScSimpleUndo +{ +public: + ScUndoAutoOutline(ScDocShell* pNewDocShell, + SCCOL nStartX, SCROW nStartY, SCTAB nStartZ, + SCCOL nEndX, SCROW nEndY, SCTAB nEndZ, + ScDocumentUniquePtr pNewUndoDoc, std::unique_ptr<ScOutlineTable> pNewUndoTab); + + virtual void Undo() override; + virtual void Redo() override; + virtual void Repeat(SfxRepeatTarget& rTarget) override; + virtual bool CanRepeat(SfxRepeatTarget& rTarget) const override; + + virtual OUString GetComment() const override; + +private: + ScAddress aBlockStart; + ScAddress aBlockEnd; + ScDocumentUniquePtr xUndoDoc; + std::unique_ptr<ScOutlineTable> xUndoTable; +}; + +class ScUndoSubTotals: public ScDBFuncUndo +{ +public: + ScUndoSubTotals(ScDocShell* pNewDocShell, SCTAB nNewTab, + const ScSubTotalParam& rNewParam, SCROW nNewEndY, + ScDocumentUniquePtr pNewUndoDoc, std::unique_ptr<ScOutlineTable> pNewUndoTab, + std::unique_ptr<ScRangeName> pNewUndoRange, std::unique_ptr<ScDBCollection> pNewUndoDB); + + virtual void Undo() override; + virtual void Redo() override; + virtual void Repeat(SfxRepeatTarget& rTarget) override; + virtual bool CanRepeat(SfxRepeatTarget& rTarget) const override; + + virtual OUString GetComment() const override; + +private: + SCTAB nTab; + ScSubTotalParam aParam; // The original passed parameter + SCROW nNewEndRow; // Size of result + ScDocumentUniquePtr xUndoDoc; + std::unique_ptr<ScOutlineTable> xUndoTable; + std::unique_ptr<ScRangeName> xUndoRange; + std::unique_ptr<ScDBCollection> xUndoDB; +}; + +class ScUndoQuery: public ScDBFuncUndo +{ +public: + ScUndoQuery( ScDocShell* pNewDocShell, SCTAB nNewTab, + const ScQueryParam& rParam, ScDocumentUniquePtr pNewUndoDoc, + std::unique_ptr<ScDBCollection> pNewUndoDB, const ScRange* pOld, + bool bSize, const ScRange* pAdvSrc ); + virtual ~ScUndoQuery() override; + + virtual void Undo() override; + virtual void Redo() override; + virtual void Repeat(SfxRepeatTarget& rTarget) override; + virtual bool CanRepeat(SfxRepeatTarget& rTarget) const override; + + virtual OUString GetComment() const override; + +private: + std::unique_ptr<SdrUndoAction> pDrawUndo; + SCTAB nTab; + ScQueryParam aQueryParam; + ScDocumentUniquePtr xUndoDoc; + std::unique_ptr<ScDBCollection> xUndoDB; // due to source and target range + ScRange aOldDest; + ScRange aAdvSource; + bool bIsAdvanced; + bool bDestArea; + bool bDoSize; +}; + +class ScUndoAutoFilter: public ScDBFuncUndo +{ +private: + OUString aDBName; + bool bFilterSet; + + void DoChange( bool bUndo ); + +public: + ScUndoAutoFilter( ScDocShell* pNewDocShell, const ScRange& rRange, + const OUString& rName, bool bSet ); + virtual ~ScUndoAutoFilter() override; + + virtual void Undo() override; + virtual void Redo() override; + virtual void Repeat(SfxRepeatTarget& rTarget) override; + virtual bool CanRepeat(SfxRepeatTarget& rTarget) const override; + + virtual OUString GetComment() const override; +}; + +class ScUndoDBData: public ScSimpleUndo +{ +public: + ScUndoDBData( ScDocShell* pNewDocShell, + std::unique_ptr<ScDBCollection> pNewUndoColl, + std::unique_ptr<ScDBCollection> pNewRedoColl ); + virtual ~ScUndoDBData() override; + + virtual void Undo() override; + virtual void Redo() override; + virtual void Repeat(SfxRepeatTarget& rTarget) override; + virtual bool CanRepeat(SfxRepeatTarget& rTarget) const override; + + virtual OUString GetComment() const override; + +private: + std::unique_ptr<ScDBCollection> pUndoColl; + std::unique_ptr<ScDBCollection> pRedoColl; +}; + +class ScUndoImportData: public ScSimpleUndo +{ +public: + ScUndoImportData(ScDocShell* pNewDocShell, SCTAB nNewTab, + const ScImportParam& rParam, SCCOL nNewEndX, SCROW nNewEndY, + SCCOL nNewFormula, + ScDocumentUniquePtr pNewUndoDoc, ScDocumentUniquePtr pNewRedoDoc, + std::unique_ptr<ScDBData> pNewUndoData, std::unique_ptr<ScDBData> pNewRedoData); + + virtual void Undo() override; + virtual void Redo() override; + virtual void Repeat(SfxRepeatTarget& rTarget) override; + virtual bool CanRepeat(SfxRepeatTarget& rTarget) const override; + + virtual OUString GetComment() const override; + +private: + SCTAB nTab; + ScImportParam aImportParam; + SCCOL nEndCol; + SCROW nEndRow; + ScDocumentUniquePtr xUndoDoc; + ScDocumentUniquePtr xRedoDoc; + std::unique_ptr<ScDBData> xUndoDBData; + std::unique_ptr<ScDBData> xRedoDBData; + SCCOL nFormulaCols; + bool bRedoFilled; +}; + +class ScUndoRepeatDB: public ScSimpleUndo +{ +public: + ScUndoRepeatDB(ScDocShell* pNewDocShell, SCTAB nNewTab, + SCCOL nStartX, SCROW nStartY, SCCOL nEndX, SCROW nEndY, + SCROW nResultEndRow, SCCOL nCurX, SCROW nCurY, + ScDocumentUniquePtr pNewUndoDoc, std::unique_ptr<ScOutlineTable> pNewUndoTab, + std::unique_ptr<ScRangeName> pNewUndoRange, std::unique_ptr<ScDBCollection> pNewUndoDB, + const ScRange* pOldQ, const ScRange* pNewQ); + + virtual void Undo() override; + virtual void Redo() override; + virtual void Repeat(SfxRepeatTarget& rTarget) override; + virtual bool CanRepeat(SfxRepeatTarget& rTarget) const override; + + virtual OUString GetComment() const override; + +private: + ScAddress aBlockStart; + ScAddress aBlockEnd; + SCROW nNewEndRow; + ScAddress aCursorPos; + ScDocumentUniquePtr xUndoDoc; + std::unique_ptr<ScOutlineTable> xUndoTable; + std::unique_ptr<ScRangeName> xUndoRange; + std::unique_ptr<ScDBCollection> xUndoDB; + ScRange aOldQuery; + ScRange aNewQuery; + bool bQuerySize; +}; + +class ScUndoDataPilot: public ScSimpleUndo +{ +public: + ScUndoDataPilot(ScDocShell* pNewDocShell, + ScDocumentUniquePtr pOldDoc, ScDocumentUniquePtr pNewDoc, + const ScDPObject* pOldObj, const ScDPObject* pNewObj, + bool bMove); + + virtual void Undo() override; + virtual void Redo() override; + virtual void Repeat(SfxRepeatTarget& rTarget) override; + virtual bool CanRepeat(SfxRepeatTarget& rTarget) const override; + + virtual OUString GetComment() const override; + +private: + ScDocumentUniquePtr xOldUndoDoc; + ScDocumentUniquePtr xNewUndoDoc; + std::unique_ptr<ScDPObject> xOldDPObject; + std::unique_ptr<ScDPObject> xNewDPObject; + bool bAllowMove; +}; + +class ScUndoConsolidate: public ScSimpleUndo +{ +public: + ScUndoConsolidate(ScDocShell* pNewDocShell, + const ScArea& rArea, const ScConsolidateParam& rPar, + ScDocumentUniquePtr pNewUndoDoc, bool bReference, + SCROW nInsCount, std::unique_ptr<ScOutlineTable> pTab, + std::unique_ptr<ScDBData> pData); + + virtual void Undo() override; + virtual void Redo() override; + virtual void Repeat(SfxRepeatTarget& rTarget) override; + virtual bool CanRepeat(SfxRepeatTarget& rTarget) const override; + + virtual OUString GetComment() const override; + +private: + ScArea aDestArea; + ScDocumentUniquePtr xUndoDoc; + ScConsolidateParam aParam; + bool bInsRef; + SCSIZE nInsertCount; + std::unique_ptr<ScOutlineTable> xUndoTab; + std::unique_ptr<ScDBData> xUndoData; +}; + +class ScUndoChartData: public ScSimpleUndo +{ +public: + ScUndoChartData( ScDocShell* pNewDocShell, + const OUString& rName, const ScRange& rNew, + bool bColHdr, bool bRowHdr, bool bAdd ); + ScUndoChartData( ScDocShell* pNewDocShell, + const OUString& rName, const ScRangeListRef& rNew, + bool bColHdr, bool bRowHdr, bool bAdd ); + virtual ~ScUndoChartData() override; + + virtual void Undo() override; + virtual void Redo() override; + virtual void Repeat(SfxRepeatTarget& rTarget) override; + virtual bool CanRepeat(SfxRepeatTarget& rTarget) const override; + + virtual OUString GetComment() const override; + +private: + OUString aChartName; + ScRangeListRef aOldRangeListRef; + bool bOldColHeaders; + bool bOldRowHeaders; +// ScRange aNewRange; + ScRangeListRef aNewRangeListRef; + bool bNewColHeaders; + bool bNewRowHeaders; + bool bAddRange; + + void Init(); +}; + +class ScUndoDataForm: public ScBlockUndo +{ +public: + ScUndoDataForm(ScDocShell* pNewDocShell, + SCCOL nStartX, SCROW nStartY, SCTAB nStartZ, + SCCOL nEndX, SCROW nEndY, SCTAB nEndZ, + const ScMarkData& rMark, + ScDocumentUniquePtr pNewUndoDoc, ScDocumentUniquePtr pNewRedoDoc, + std::unique_ptr<ScRefUndoData> pRefData); + virtual void Undo() override; + virtual void Redo() override; + virtual void Repeat(SfxRepeatTarget& rTarget) override; + virtual bool CanRepeat(SfxRepeatTarget& rTarget) const override; + + virtual OUString GetComment() const override; + +private: + std::unique_ptr<ScMarkData> mxMarkData; + ScDocumentUniquePtr xUndoDoc; + ScDocumentUniquePtr xRedoDoc; + std::unique_ptr<ScRefUndoData> xRefUndoData; + std::unique_ptr<ScRefUndoData> xRefRedoData; + bool bRedoFilled; + + void DoChange( const bool bUndo ); +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/undodraw.hxx b/sc/source/ui/inc/undodraw.hxx new file mode 100644 index 000000000..0950d9d57 --- /dev/null +++ b/sc/source/ui/inc/undodraw.hxx @@ -0,0 +1,55 @@ +/* -*- 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_SC_SOURCE_UI_INC_UNDODRAW_HXX +#define INCLUDED_SC_SOURCE_UI_INC_UNDODRAW_HXX + +#include <memory> +#include <svl/undo.hxx> + +class ScDocShell; + +class ScUndoDraw: public SfxUndoAction +{ + std::unique_ptr<SfxUndoAction> pDrawUndo; + ScDocShell* pDocShell; + ViewShellId mnViewShellId; + + void UpdateSubShell(); + +public: + ScUndoDraw( std::unique_ptr<SfxUndoAction> pUndo, ScDocShell* pDocSh ); + virtual ~ScUndoDraw() override; + + std::unique_ptr<SfxUndoAction> ReleaseDrawUndo() { return std::move(pDrawUndo); } + + virtual void Undo() override; + virtual void Redo() override; + virtual void Repeat(SfxRepeatTarget& rTarget) override; + virtual bool CanRepeat(SfxRepeatTarget& rTarget) const override; + virtual bool Merge( SfxUndoAction *pNextAction ) override; + virtual OUString GetComment() const override; + virtual OUString GetRepeatComment(SfxRepeatTarget&) const override; + /// See SfxUndoAction::GetViewShellId(). + ViewShellId GetViewShellId() const override; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/undoolk.hxx b/sc/source/ui/inc/undoolk.hxx new file mode 100644 index 000000000..a8e03577c --- /dev/null +++ b/sc/source/ui/inc/undoolk.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_SC_SOURCE_UI_INC_UNDOOLK_HXX +#define INCLUDED_SC_SOURCE_UI_INC_UNDOOLK_HXX + +class SdrUndoAction; +class ScDocument; + +std::unique_ptr<SdrUndoAction> GetSdrUndoAction( ScDocument* pDoc ); +void DoSdrUndoAction ( SdrUndoAction* pUndoAction, ScDocument* pDoc ); +void RedoSdrUndoAction ( SdrUndoAction* pUndoAction ); +void EnableDrawAdjust ( ScDocument* pDoc, bool bEnable ); + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/undosort.hxx b/sc/source/ui/inc/undosort.hxx new file mode 100644 index 000000000..d44827ffa --- /dev/null +++ b/sc/source/ui/inc/undosort.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_SC_UNDOSORT_HXX +#define INCLUDED_SC_UNDOSORT_HXX + +#include "undobase.hxx" +#include <sortparam.hxx> + +namespace sc { + +class UndoSort : public ScSimpleUndo +{ + ReorderParam maParam; + +public: + UndoSort( ScDocShell* pDocSh, const ReorderParam& rParam ); + + virtual OUString GetComment() const override; + virtual void Undo() override; + virtual void Redo() override; + +private: + void Execute( bool bUndo ); +}; + +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/undostyl.hxx b/sc/source/ui/inc/undostyl.hxx new file mode 100644 index 000000000..0e27014fb --- /dev/null +++ b/sc/source/ui/inc/undostyl.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_SC_SOURCE_UI_INC_UNDOSTYL_HXX +#define INCLUDED_SC_SOURCE_UI_INC_UNDOSTYL_HXX + +#include <memory> +#include <svl/style.hxx> +#include "undobase.hxx" + +class ScDocShell; + +class ScStyleSaveData +{ +private: + OUString aName; + OUString aParent; + std::unique_ptr<SfxItemSet> xItems; + +public: + ScStyleSaveData(); + ScStyleSaveData( const ScStyleSaveData& rOther ); + ScStyleSaveData& operator=( const ScStyleSaveData& rOther ); + + void InitFromStyle( const SfxStyleSheetBase* pSource ); + + const OUString& GetName() const { return aName; } + const OUString& GetParent() const { return aParent; } + const SfxItemSet* GetItems() const { return xItems.get(); } +}; + +class ScUndoModifyStyle: public ScSimpleUndo +{ +private: + SfxStyleFamily eFamily; + ScStyleSaveData aOldData; + ScStyleSaveData aNewData; + + static void DoChange( ScDocShell* pDocSh, + const OUString& rName, SfxStyleFamily eStyleFamily, + const ScStyleSaveData& rData ); + +public: + ScUndoModifyStyle( ScDocShell* pDocSh, + SfxStyleFamily eFam, + const ScStyleSaveData& rOld, + const ScStyleSaveData& rNew ); + virtual ~ScUndoModifyStyle() override; + + virtual void Undo() override; + virtual void Redo() override; + virtual void Repeat(SfxRepeatTarget& rTarget) override; + virtual bool CanRepeat(SfxRepeatTarget& rTarget) const override; + + virtual OUString GetComment() const override; +}; + +class ScUndoApplyPageStyle: public ScSimpleUndo +{ +public: + ScUndoApplyPageStyle( ScDocShell* pDocSh, const OUString& rNewStyle ); + virtual ~ScUndoApplyPageStyle() override; + + void AddSheetAction( SCTAB nTab, const OUString& rOld ); + + virtual void Undo() override; + virtual void Redo() override; + virtual void Repeat(SfxRepeatTarget& rTarget) override; + virtual bool CanRepeat(SfxRepeatTarget& rTarget) const override; + + virtual OUString GetComment() const override; + +private: + struct ApplyStyleEntry + { + SCTAB mnTab; + OUString maOldStyle; + explicit ApplyStyleEntry( SCTAB nTab, const OUString& rOldStyle ); + }; + typedef ::std::vector< ApplyStyleEntry > ApplyStyleVec; + + ApplyStyleVec maEntries; + OUString maNewStyle; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/undotab.hxx b/sc/source/ui/inc/undotab.hxx new file mode 100644 index 000000000..d9e50709a --- /dev/null +++ b/sc/source/ui/inc/undotab.hxx @@ -0,0 +1,474 @@ +/* -*- 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_SC_SOURCE_UI_INC_UNDOTAB_HXX +#define INCLUDED_SC_SOURCE_UI_INC_UNDOTAB_HXX + +#include "undobase.hxx" +#include <tools/color.hxx> +#include <tabbgcolor.hxx> + +#include <memory> +#include <vector> + +class ScDocShell; +class SdrUndoAction; +class ScPrintRangeSaver; +class SdrObject; +class ScDocProtection; +class ScTableProtection; +class ScMarkData; + +class ScUndoInsertTab : public ScSimpleUndo +{ +public: + ScUndoInsertTab( + ScDocShell* pNewDocShell, + SCTAB nTabNum, + bool bApp, + const OUString& rNewName); + virtual ~ScUndoInsertTab() override; + + virtual void Undo() override; + virtual void Redo() override; + virtual void Repeat(SfxRepeatTarget& rTarget) override; + virtual bool CanRepeat(SfxRepeatTarget& rTarget) const override; + + virtual OUString GetComment() const override; + +private: + OUString sNewName; + std::unique_ptr<SdrUndoAction> pDrawUndo; + sal_uLong nEndChangeAction; + SCTAB nTab; + bool bAppend; + + void SetChangeTrack(); +}; + +class ScUndoInsertTables : public ScSimpleUndo +{ +public: + ScUndoInsertTables( + ScDocShell* pNewDocShell, + SCTAB nTabNum, + const std::vector<OUString>& newNameList); + virtual ~ScUndoInsertTables() override; + + virtual void Undo() override; + virtual void Redo() override; + virtual void Repeat(SfxRepeatTarget& rTarget) override; + virtual bool CanRepeat(SfxRepeatTarget& rTarget) const override; + + virtual OUString GetComment() const override; + +private: + + std::unique_ptr<SdrUndoAction> pDrawUndo; + std::vector<OUString> aNameList; + sal_uLong nStartChangeAction; + sal_uLong nEndChangeAction; + SCTAB nTab; + + void SetChangeTrack(); +}; + +class ScUndoDeleteTab: public ScMoveUndo +{ +public: + ScUndoDeleteTab( + ScDocShell* pNewDocShell, + const std::vector<SCTAB> &theTabs, //SCTAB nNewTab, + ScDocumentUniquePtr pUndoDocument, + std::unique_ptr<ScRefUndoData> pRefData ); + virtual ~ScUndoDeleteTab() override; + + virtual void Undo() override; + virtual void Redo() override; + virtual void Repeat(SfxRepeatTarget& rTarget) override; + virtual bool CanRepeat(SfxRepeatTarget& rTarget) const override; + + virtual OUString GetComment() const override; + +private: + std::vector<SCTAB> theTabs; + sal_uLong nStartChangeAction; + sal_uLong nEndChangeAction; + + void SetChangeTrack(); +}; + +class ScUndoRenameTab: public ScSimpleUndo +{ +public: + ScUndoRenameTab( + ScDocShell* pNewDocShell, + SCTAB nT, + const OUString& rOldName, + const OUString& rNewName); + virtual ~ScUndoRenameTab() override; + + virtual void Undo() override; + virtual void Redo() override; + virtual void Repeat(SfxRepeatTarget& rTarget) override; + virtual bool CanRepeat(SfxRepeatTarget& rTarget) const override; + + virtual OUString GetComment() const override; + +private: + SCTAB nTab; + OUString sOldName; + OUString sNewName; + + void DoChange( SCTAB nTab, const OUString& rName ) const; +}; + +class ScUndoMoveTab: public ScSimpleUndo +{ +public: + ScUndoMoveTab( + ScDocShell* pNewDocShell, + std::unique_ptr<std::vector<SCTAB>> pOldTabs, + std::unique_ptr<std::vector<SCTAB>> pNewTabs, + std::unique_ptr<std::vector< OUString>> pOldNames = nullptr, + std::unique_ptr<std::vector< OUString>> pNewNames = nullptr ); + + virtual ~ScUndoMoveTab() override; + + virtual void Undo() override; + virtual void Redo() override; + virtual void Repeat(SfxRepeatTarget& rTarget) override; + virtual bool CanRepeat(SfxRepeatTarget& rTarget) const override; + + virtual OUString GetComment() const override; + +private: + std::unique_ptr< ::std::vector<SCTAB> > mpOldTabs; + std::unique_ptr< ::std::vector<SCTAB> > mpNewTabs; + std::unique_ptr< ::std::vector< OUString> > mpOldNames; + std::unique_ptr< ::std::vector< OUString> > mpNewNames; + + void DoChange( bool bUndo ) const; +}; + +class ScUndoCopyTab: public ScSimpleUndo +{ +public: + ScUndoCopyTab( + ScDocShell* pNewDocShell, + std::unique_ptr<std::vector<SCTAB>> pOldTabs, + std::unique_ptr<std::vector<SCTAB>> pNewTabs, + std::unique_ptr<std::vector< OUString>> pNewNames = nullptr ); + + virtual ~ScUndoCopyTab() override; + + virtual void Undo() override; + virtual void Redo() override; + virtual void Repeat(SfxRepeatTarget& rTarget) override; + virtual bool CanRepeat(SfxRepeatTarget& rTarget) const override; + + virtual OUString GetComment() const override; + +private: + std::unique_ptr< ::std::vector<SCTAB> > mpOldTabs; + std::unique_ptr< ::std::vector<SCTAB> > mpNewTabs; + std::unique_ptr< ::std::vector< OUString> > mpNewNames; + std::unique_ptr<SdrUndoAction> pDrawUndo; + + void DoChange() const; +}; + +class ScUndoTabColor: public ScSimpleUndo +{ +public: + ScUndoTabColor( + ScDocShell* pNewDocShell, + SCTAB nT, + const Color& aOTabBgColor, + const Color& aNTabBgColor); + ScUndoTabColor( + ScDocShell* pNewDocShell, + const ScUndoTabColorInfo::List& rUndoTabColorList); + virtual ~ScUndoTabColor() override; + + virtual void Undo() override; + virtual void Redo() override; + virtual void Repeat(SfxRepeatTarget& rTarget) override; + virtual bool CanRepeat(SfxRepeatTarget& rTarget) const override; + + virtual OUString GetComment() const override; + +private: + ScUndoTabColorInfo::List aTabColorList; + + void DoChange(bool bUndoType) const; +}; + +class ScUndoMakeScenario: public ScSimpleUndo +{ +public: + ScUndoMakeScenario( + ScDocShell* pNewDocShell, + SCTAB nSrc, SCTAB nDest, + const OUString& rN, const OUString& rC, + const Color& rCol, ScScenarioFlags nF, + const ScMarkData& rMark ); + virtual ~ScUndoMakeScenario() override; + + virtual void Undo() override; + virtual void Redo() override; + virtual void Repeat(SfxRepeatTarget& rTarget) override; + virtual bool CanRepeat(SfxRepeatTarget& rTarget) const override; + + virtual OUString GetComment() const override; + +private: + std::unique_ptr<ScMarkData> mpMarkData; + SCTAB nSrcTab; + SCTAB nDestTab; + OUString aName; + OUString aComment; + Color aColor; + ScScenarioFlags nFlags; + std::unique_ptr<SdrUndoAction> pDrawUndo; +}; + +class ScUndoImportTab : public ScSimpleUndo +{ +public: + ScUndoImportTab( + ScDocShell* pShell, + SCTAB nNewTab, SCTAB nNewCount ); + virtual ~ScUndoImportTab() override; + + virtual void Undo() override; + virtual void Redo() override; + virtual void Repeat(SfxRepeatTarget& rTarget) override; + virtual bool CanRepeat(SfxRepeatTarget& rTarget) const override; + + virtual OUString GetComment() const override; + +private: + SCTAB nTab; + SCTAB nCount; + ScDocumentUniquePtr xRedoDoc; + std::unique_ptr<SdrUndoAction> pDrawUndo; + + void DoChange() const; +}; + +class ScUndoRemoveLink : public ScSimpleUndo +{ +public: + ScUndoRemoveLink( // Call before delete! + ScDocShell* pShell, + const OUString& rDoc ); + virtual ~ScUndoRemoveLink() override; + + virtual void Undo() override; + virtual void Redo() override; + virtual void Repeat(SfxRepeatTarget& rTarget) override; + virtual bool CanRepeat(SfxRepeatTarget& rTarget) const override; + + virtual OUString GetComment() const override; + +private: + OUString aDocName; + OUString aFltName; + OUString aOptions; + sal_uLong nRefreshDelay; + sal_uInt16 nCount; + std::unique_ptr<SCTAB[]> + pTabs; + std::unique_ptr<ScLinkMode[]> + pModes; + std::unique_ptr<OUString[]> + pTabNames; + + void DoChange( bool bLink ) const; +}; + +class ScUndoShowHideTab : public ScSimpleUndo +{ +public: + ScUndoShowHideTab( + ScDocShell* pShell, + const std::vector<SCTAB>& newUndoTabs, + bool bNewShow ); + virtual ~ScUndoShowHideTab() override; + + virtual void Undo() override; + virtual void Redo() override; + virtual void Repeat(SfxRepeatTarget& rTarget) override; + virtual bool CanRepeat(SfxRepeatTarget& rTarget) const override; + + virtual OUString GetComment() const override; + +private: + std::vector<SCTAB> undoTabs; + bool bShow; + + void DoChange( bool bShow ) const; +}; + +/** This class implements undo & redo of document protect & unprotect + operations. */ +class ScUndoDocProtect : public ScSimpleUndo +{ +public: + ScUndoDocProtect(ScDocShell* pShell, ::std::unique_ptr<ScDocProtection> && pProtectSettings); + virtual ~ScUndoDocProtect() override; + + virtual void Undo() override; + virtual void Redo() override; + virtual void Repeat(SfxRepeatTarget& rTarget) override; + virtual bool CanRepeat(SfxRepeatTarget& rTarget) const override; + + virtual OUString GetComment() const override; + +private: + ::std::unique_ptr<ScDocProtection> mpProtectSettings; + + void DoProtect(bool bProtect); +}; + +/** This class implements undo & redo of both protect and unprotect of + sheet. */ +class ScUndoTabProtect : public ScSimpleUndo +{ +public: + ScUndoTabProtect(ScDocShell* pShell, SCTAB nTab, + std::unique_ptr<ScTableProtection> && pProtectSettings); + virtual ~ScUndoTabProtect() override; + + virtual void Undo() override; + virtual void Redo() override; + virtual void Repeat(SfxRepeatTarget& rTarget) override; + virtual bool CanRepeat(SfxRepeatTarget& rTarget) const override; + + virtual OUString GetComment() const override; + +private: + SCTAB mnTab; + ::std::unique_ptr<ScTableProtection> mpProtectSettings; + + void DoProtect(bool bProtect); +}; + +class ScUndoPrintRange : public ScSimpleUndo +{ +public: + ScUndoPrintRange( ScDocShell* pShell, SCTAB nNewTab, + std::unique_ptr<ScPrintRangeSaver> pOld, + std::unique_ptr<ScPrintRangeSaver> pNew ); + virtual ~ScUndoPrintRange() override; + + virtual void Undo() override; + virtual void Redo() override; + virtual void Repeat(SfxRepeatTarget& rTarget) override; + virtual bool CanRepeat(SfxRepeatTarget& rTarget) const override; + + virtual OUString GetComment() const override; + +private: + SCTAB nTab; + std::unique_ptr<ScPrintRangeSaver> pOldRanges; + std::unique_ptr<ScPrintRangeSaver> pNewRanges; + + void DoChange( bool bUndo ); +}; + +class ScUndoScenarioFlags: public ScSimpleUndo +{ +public: + ScUndoScenarioFlags( + ScDocShell* pNewDocShell, SCTAB nT, + const OUString& rON, const OUString& rNN, + const OUString& rOC, const OUString& rNC, + const Color& rOCol, const Color& rNCol, + ScScenarioFlags nOF, ScScenarioFlags nNF); + + virtual ~ScUndoScenarioFlags() override; + + virtual void Undo() override; + virtual void Redo() override; + virtual void Repeat(SfxRepeatTarget& rTarget) override; + virtual bool CanRepeat(SfxRepeatTarget& rTarget) const override; + + virtual OUString GetComment() const override; + +private: + SCTAB nTab; + OUString aOldName; + OUString aNewName; + OUString aOldComment; + OUString aNewComment; + Color aOldColor; + Color aNewColor; + ScScenarioFlags nOldFlags; + ScScenarioFlags nNewFlags; +}; + +class ScUndoRenameObject: public ScSimpleUndo +{ +public: + ScUndoRenameObject( + ScDocShell* pNewDocShell, const OUString& rPN, + const OUString& rON, const OUString& rNN ); + + virtual ~ScUndoRenameObject() override; + + virtual void Undo() override; + virtual void Redo() override; + virtual void Repeat(SfxRepeatTarget& rTarget) override; + virtual bool CanRepeat(SfxRepeatTarget& rTarget) const override; + + virtual OUString GetComment() const override; + +private: + OUString aPersistName; // to find object (works only for OLE objects) + OUString aOldName; + OUString aNewName; + + SdrObject* GetObject(); +}; + +class ScUndoLayoutRTL : public ScSimpleUndo +{ +public: + ScUndoLayoutRTL( ScDocShell* pShell, SCTAB nNewTab, bool bNewRTL ); + virtual ~ScUndoLayoutRTL() override; + + virtual void Undo() override; + virtual void Redo() override; + virtual void Repeat(SfxRepeatTarget& rTarget) override; + virtual bool CanRepeat(SfxRepeatTarget& rTarget) const override; + + virtual OUString GetComment() const override; + +private: + SCTAB nTab; + bool bRTL; + + void DoChange( bool bNew ); +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/undoutil.hxx b/sc/source/ui/inc/undoutil.hxx new file mode 100644 index 000000000..b95af8a19 --- /dev/null +++ b/sc/source/ui/inc/undoutil.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_SC_SOURCE_UI_INC_UNDOUTIL_HXX +#define INCLUDED_SC_SOURCE_UI_INC_UNDOUTIL_HXX + +#include <address.hxx> + +class ScDocShell; +class ScDBData; +class ScDocument; + +class ScUndoUtil +{ +public: + /** Mark Block (invisible - has to be repainted) */ + static void MarkSimpleBlock( const ScDocShell* pDocShell, + SCCOL nStartX, SCROW nStartY, SCTAB nStartZ, + SCCOL nEndX, SCROW nEndY, SCTAB nEndZ ); + static void MarkSimpleBlock( const ScDocShell* pDocShell, + const ScAddress& rBlockStart, + const ScAddress& rBlockEnd ); + static void MarkSimpleBlock( const ScDocShell* pDocShell, + const ScRange& rRange ); + + static void PaintMore( ScDocShell* pDocShell, + const ScRange& rRange ); + + /** Search for Data base range in Document ("untitled" or by region) + create new if not found */ + static ScDBData* GetOldDBData( const ScDBData* pUndoData, ScDocument* pDoc, SCTAB nTab, + SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 ); +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/validate.hxx b/sc/source/ui/inc/validate.hxx new file mode 100644 index 000000000..3f64e1485 --- /dev/null +++ b/sc/source/ui/inc/validate.hxx @@ -0,0 +1,277 @@ +/* -*- 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_SC_SOURCE_UI_INC_VALIDATE_HXX +#define INCLUDED_SC_SOURCE_UI_INC_VALIDATE_HXX + +#include <sfx2/tabdlg.hxx> + +#include "anyrefdg.hxx" +#include <sc.hrc> + +struct ScRefHandlerCaller{ + virtual ~ScRefHandlerCaller(){} +}; + +class ScRefHandlerHelper +{ +protected: + ScRefHandlerCaller* m_pHandler; +// workaround VS2013 issue with pointers to things that contain virtual base class +#ifdef _WIN32 + #pragma pack(push, 16) +#endif + void (ScRefHandlerCaller::*m_pSetReferenceHdl)( const ScRange& , const ScDocument& ); + void (ScRefHandlerCaller::*m_pSetActiveHdl)(); + void (ScRefHandlerCaller::*m_pRefInputStartPreHdl)( formula::RefEdit* pEdit, const formula::RefButton* pButton ); + void (ScRefHandlerCaller::*m_pRefInputDonePostHdl)(); +#if defined( _WIN32) + #pragma pack(pop) +#endif + +public: + typedef void (ScRefHandlerCaller::*PFUNCSETREFHDLTYPE)( const ScRange& , const ScDocument& ); + typedef void (ScRefHandlerCaller::*PCOMMONHDLTYPE)(); + typedef void (ScRefHandlerCaller::*PINPUTSTARTDLTYPE)( formula::RefEdit* pEdit, const formula::RefButton* pButton ); + + void SetSetRefHdl( PFUNCSETREFHDLTYPE pNewHdl ) + { + m_pSetReferenceHdl = pNewHdl; + } + + void SetSetActHdl( PCOMMONHDLTYPE pNewHdl ) + { + m_pSetActiveHdl = pNewHdl; + } + + void SetHandler( ScRefHandlerCaller *pNewHandler ) + { + m_pHandler = pNewHandler; + } + void SetRefInputStartPreHdl( PINPUTSTARTDLTYPE pNewHdl ){ m_pRefInputStartPreHdl = pNewHdl; } + void SetRefInputDonePostHdl( void (ScRefHandlerCaller::*pNewHdl)() ){ m_pRefInputDonePostHdl = pNewHdl; } + + ScRefHandlerHelper():m_pHandler(nullptr), m_pSetReferenceHdl( nullptr ), m_pSetActiveHdl(nullptr), m_pRefInputStartPreHdl( nullptr ), m_pRefInputDonePostHdl( nullptr ){} +}; + +class ScValidationDlg; + +/** The tab page "Criteria" from the Validation dialog. */ +class ScTPValidationValue : public ScRefHandlerCaller, public SfxTabPage +{ + static const sal_uInt16 pValueRanges[]; +public: + explicit ScTPValidationValue(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rArgSet); + static std::unique_ptr<SfxTabPage> Create( weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rArgSet ); + virtual ~ScTPValidationValue() override; + + static const sal_uInt16* GetRanges() { return pValueRanges; } + + virtual bool FillItemSet( SfxItemSet* rArgSet ) override; + virtual void Reset( const SfxItemSet* rArgSet ) override; + +private: + void Init(); + + OUString GetFirstFormula() const; + OUString GetSecondFormula() const; + + void SetFirstFormula( const OUString& rFmlaStr ); + void SetSecondFormula( const OUString& rFmlaStr ); + + DECL_LINK(SelectHdl, weld::ComboBox&, void); + DECL_LINK(CheckHdl, weld::Button&, void); + + OUString maStrMin; + OUString maStrMax; + OUString maStrValue; + OUString maStrFormula; + OUString maStrRange; + OUString maStrList; + sal_Unicode mcFmlaSep; /// List separator in formulas. + + DECL_LINK( EditSetFocusHdl, formula::RefEdit&, void ); + DECL_LINK( KillEditFocusHdl, formula::RefEdit&, void ); + DECL_LINK( KillButtonFocusHdl, formula::RefButton&, void ); + DECL_LINK( ClickHdl, formula::RefButton&, void ); + + formula::RefEdit* m_pRefEdit; + + std::unique_ptr<weld::ComboBox> m_xLbAllow; + std::unique_ptr<weld::CheckButton> m_xCbAllow; /// Allow blank cells. + std::unique_ptr<weld::CheckButton> m_xCbShow; /// Show selection list in cell. + std::unique_ptr<weld::CheckButton> m_xCbSort; /// Sort selection list in cell. + std::unique_ptr<weld::Label> m_xFtValue; + std::unique_ptr<weld::ComboBox> m_xLbValue; + std::unique_ptr<weld::Label> m_xFtMin; + std::unique_ptr<weld::Widget> m_xMinGrid; + std::unique_ptr<formula::RefEdit> m_xEdMin; + std::unique_ptr<weld::TextView> m_xEdList; /// Entries for explicit list + std::unique_ptr<weld::Label> m_xFtMax; + std::unique_ptr<formula::RefEdit> m_xEdMax; + std::unique_ptr<weld::Label> m_xFtHint; /// Hint text for cell range validity. + std::unique_ptr<formula::RefButton> m_xBtnRef; + std::unique_ptr<weld::Container> m_xRefGrid; + + weld::Container* m_pRefEditParent; + weld::Container* m_pBtnRefParent; + + void SetReferenceHdl( const ScRange& , const ScDocument& ); + void SetActiveHdl(); + void RefInputStartPreHdl(formula::RefEdit* pEdit, const formula::RefButton* pButton); + void RefInputDonePostHdl(); + ScValidationDlg * GetValidationDlg(); +public: + void SetupRefDlg(); + void RemoveRefDlg(bool bRestoreModal); +}; + +/** The "Validity" tab dialog. */ +class ScValidationDlg + : public ScRefHdlrControllerImpl<SfxTabDialogController, false> + , public ScRefHandlerHelper +{ + typedef ScRefHdlrControllerImpl<SfxTabDialogController, false> ScValidationDlgBase; + + ScTabViewShell * m_pTabVwSh; + OString m_sValuePageId; + bool m_bOwnRefHdlr:1; + bool m_bRefInputting:1; + + std::unique_ptr<weld::Container> m_xHBox; + + bool EnterRefStatus(); + bool LeaveRefStatus(); + +public: + explicit ScValidationDlg(weld::Window* pParent, const SfxItemSet* pArgSet, ScTabViewShell* pTabViewSh); + virtual ~ScValidationDlg() override; + static std::shared_ptr<SfxDialogController> Find1AliveObject(const weld::Window *pAncestor) + { + return SC_MOD()->Find1RefWindow(SLOTID, pAncestor); + } + ScTabViewShell *GetTabViewShell() + { + return m_pTabVwSh; + } + + bool SetupRefDlg(); + bool RemoveRefDlg(bool bRestoreModal); + + void SetModal(bool bModal) { m_xDialog->set_modal(bModal); } + + virtual void EndDialog() override; + + virtual void SetReference( const ScRange& rRef, ScDocument& rDoc ) override + { + if ( m_pHandler && m_pSetReferenceHdl ) + (m_pHandler->*m_pSetReferenceHdl)( rRef, rDoc ); + } + + virtual void SetActive() override + { + if ( m_pHandler && m_pSetActiveHdl ) + (m_pHandler->*m_pSetActiveHdl)(); + } + + bool IsRefInputting() const { return m_bRefInputting; } + weld::Container* get_refinput_shrink_parent() { return m_xHBox.get(); } + + virtual void RefInputStart( formula::RefEdit* pEdit, formula::RefButton* pButton = nullptr ) override + { + if( !CanInputStart( pEdit ) ) + return; + + if ( m_pHandler && m_pRefInputStartPreHdl ) + (m_pHandler->*m_pRefInputStartPreHdl)( pEdit, pButton ); + m_bRefInputting = true; + ScValidationDlgBase::RefInputStart( pEdit, pButton ); + } + + virtual void RefInputDone( bool bForced = false ) override + { + if( !CanInputDone( bForced ) ) + return; + + ScValidationDlgBase::RefInputDone( bForced ); + m_bRefInputting = false; + + if ( m_pHandler && m_pRefInputDonePostHdl ) + (m_pHandler->*m_pRefInputDonePostHdl)(); + } + + bool IsChildFocus() const; + + enum { SLOTID = SID_VALIDITY_REFERENCE }; + + virtual void Close() override + { + if (m_bOwnRefHdlr) + { + if (SfxTabPage* pPage = GetTabPage(m_sValuePageId)) + static_cast<ScTPValidationValue*>(pPage)->RemoveRefDlg(false); + } + ScValidationDlgBase::Close(); + } +}; + +class ScTPValidationHelp : public SfxTabPage +{ +private: + std::unique_ptr<weld::CheckButton> m_xTsbHelp; + std::unique_ptr<weld::Entry> m_xEdtTitle; + std::unique_ptr<weld::TextView> m_xEdInputHelp; + +public: + ScTPValidationHelp(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rArgSet); + static std::unique_ptr<SfxTabPage> Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rArgSet); + virtual ~ScTPValidationHelp() override; + + virtual bool FillItemSet ( SfxItemSet* rArgSet ) override; + virtual void Reset ( const SfxItemSet* rArgSet ) override; +}; + +class ScTPValidationError : public SfxTabPage +{ +private: + std::unique_ptr<weld::CheckButton> m_xTsbShow; + std::unique_ptr<weld::ComboBox> m_xLbAction; + std::unique_ptr<weld::Button> m_xBtnSearch; + std::unique_ptr<weld::Entry> m_xEdtTitle; + std::unique_ptr<weld::Label> m_xFtError; + std::unique_ptr<weld::TextView> m_xEdError; + + void Init(); + + // Handler ------------------------ + DECL_LINK(SelectActionHdl, weld::ComboBox&, void); + DECL_LINK(ClickSearchHdl, weld::Button&, void); + +public: + ScTPValidationError(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rArgSet); + static std::unique_ptr<SfxTabPage> Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rArgSet); + virtual ~ScTPValidationError() override; + + virtual bool FillItemSet ( SfxItemSet* rArgSet ) override; + virtual void Reset ( const SfxItemSet* rArgSet ) override; +}; + +#endif // INCLUDED_SC_SOURCE_UI_INC_VALIDATE_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/viewdata.hxx b/sc/source/ui/inc/viewdata.hxx new file mode 100644 index 000000000..345f9d9ae --- /dev/null +++ b/sc/source/ui/inc/viewdata.hxx @@ -0,0 +1,709 @@ +/* -*- 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_SC_SOURCE_UI_INC_VIEWDATA_HXX +#define INCLUDED_SC_SOURCE_UI_INC_VIEWDATA_HXX + +#include <tools/fract.hxx> +#include <sfx2/zoomitem.hxx> +#include <rangelst.hxx> +#include <scdllapi.h> +#include <viewopti.hxx> +#include "docsh.hxx" + +#include <memory> +#include <o3tl/typed_flags_set.hxx> + +#define SC_SIZE_NONE 65535 + +enum class ScFillMode +{ + NONE = 0, + FILL = 1, + EMBED_LT = 2, + EMBED_RB = 3, + MATRIX = 4, +}; + +enum ScSplitMode { SC_SPLIT_NONE = 0, SC_SPLIT_NORMAL, SC_SPLIT_FIX, SC_SPLIT_MODE_MAX_ENUM = SC_SPLIT_FIX }; + +enum ScSplitPos { SC_SPLIT_TOPLEFT, SC_SPLIT_TOPRIGHT, SC_SPLIT_BOTTOMLEFT, SC_SPLIT_BOTTOMRIGHT, SC_SPLIT_POS_MAX_ENUM = SC_SPLIT_BOTTOMRIGHT }; +enum ScHSplitPos { SC_SPLIT_LEFT, SC_SPLIT_RIGHT }; +enum ScVSplitPos { SC_SPLIT_TOP, SC_SPLIT_BOTTOM }; + +inline ScHSplitPos WhichH( ScSplitPos ePos ); +inline ScVSplitPos WhichV( ScSplitPos ePos ); + +/** Screen behavior related to cursor movements */ +enum ScFollowMode { SC_FOLLOW_NONE, SC_FOLLOW_LINE, SC_FOLLOW_FIX, SC_FOLLOW_JUMP }; + +/** Mouse mode to select areas */ +enum ScRefType { SC_REFTYPE_NONE, SC_REFTYPE_REF, SC_REFTYPE_FILL, + SC_REFTYPE_EMBED_LT, SC_REFTYPE_EMBED_RB }; + +/** States GetSimpleArea() returns for the underlying selection marks, so the + caller can react if the result is not of type SC_MARK_SIMPLE. */ +enum ScMarkType +{ + SC_MARK_NONE = 0, // Not returned by GetSimpleArea(), used internally. + // Nothing marked always results in the + // current cursor position being selected and a simple mark. + SC_MARK_SIMPLE = 1, // Simple rectangular area marked, no filtered rows. + SC_MARK_FILTERED = 2, // At least one mark contains filtered rows. + SC_MARK_SIMPLE_FILTERED = // Simple rectangular area marked containing filtered rows. + SC_MARK_SIMPLE | + SC_MARK_FILTERED, // 3 + SC_MARK_MULTI = 4 // Multiple selection marks. + /* TODO: if filtered multi-selection was implemented, this would be the value to use. */ +#if 0 + , + SC_MARK_MULTI_FILTERED = // Multiple selection marks containing filtered rows. + SC_MARK_MULTI | + SC_MARK_FILTERED // 6 +#endif +}; + +enum class ScPasteFlags +{ + NONE = 0, // No flags specified + Mode = 1, // Enable paste-mode + Border = 2, // Show a border around the source cells +}; +namespace o3tl { + template<> struct typed_flags<ScPasteFlags> : is_typed_flags<ScPasteFlags, 0x03> {}; +} + +// for internal Drag&Drop: +enum class ScDragSrc{ + Undefined = 0, + Navigator = 1, + Table = 2 +}; +namespace o3tl { + template<> struct typed_flags<ScDragSrc> : is_typed_flags<ScDragSrc, 0x00000003> {}; +} + +class ScDocFunc; +class ScDocument; +class ScDBFunc; +class ScTabViewShell; +class ScDrawView; +class ScEditEngineDefaulter; +class EditView; +class EditStatus; +class Outliner; +namespace vcl { class Window; } +class SfxObjectShell; +class SfxBindings; +class SfxDispatcher; +class ScPatternAttr; +class ScExtDocOptions; +class ScViewData; +class ScMarkData; +class ScGridWindow; + +class ScPositionHelper +{ +public: + typedef SCCOLROW index_type; + typedef std::pair<index_type, long> value_type; + static_assert(std::numeric_limits<index_type>::is_signed, "ScPositionCache: index type is not signed"); + +private: + static const index_type null = std::numeric_limits<index_type>::min(); + + class Comp + { + public: + bool operator() (const value_type& rValue1, const value_type& rValue2) const; + }; + + index_type MAX_INDEX; + std::set<value_type, Comp> mData; + +public: + ScPositionHelper(ScDocument *pDoc, bool bColumn); + void setDocument(ScDocument *pDoc, bool bColumn); + + void insert(index_type nIndex, long nPos); + void removeByIndex(index_type nIndex); + void invalidateByIndex(index_type nIndex); + void invalidateByPosition(long nPos); + const value_type& getNearestByIndex(index_type nIndex) const; + const value_type& getNearestByPosition(long nPos) const; + long getPosition(index_type nIndex) const; + long computePosition(index_type nIndex, const std::function<long (index_type)>& getSizePx); +}; + +class ScBoundsProvider +{ + typedef ScPositionHelper::value_type value_type; + typedef SCCOLROW index_type; + + ScDocument* pDoc; + const SCTAB nTab; + const bool bColumnHeader; + const index_type MAX_INDEX; + + double mfPPTX; + double mfPPTY; + index_type nFirstIndex; + index_type nSecondIndex; + long nFirstPositionPx; + long nSecondPositionPx; + +public: + ScBoundsProvider(const ScViewData &rView, SCTAB nT, bool bColumnHeader); + + void GetStartIndexAndPosition(SCCOL& nIndex, long& nPosition) const; + void GetEndIndexAndPosition(SCCOL& nIndex, long& nPosition) const; + void GetStartIndexAndPosition(SCROW& nIndex, long& nPosition) const; + void GetEndIndexAndPosition(SCROW& nIndex, long& nPosition) const; + + void Compute(value_type aFirstNearest, value_type aSecondNearest, + long nFirstBound, long nSecondBound); + + void EnlargeStartBy(long nOffset); + + void EnlargeEndBy(long nOffset); + + void EnlargeBy(long nOffset) + { + EnlargeStartBy(nOffset); + EnlargeEndBy(nOffset); + } + +private: + long GetSize(index_type nIndex) const; + + void GetIndexAndPos(index_type nNearestIndex, long nNearestPosition, + long nBound, index_type& nFoundIndex, long& nPosition, + bool bTowards, long nDiff); + + void GeIndexBackwards(index_type nNearestIndex, long nNearestPosition, + long nBound, index_type& nFoundIndex, long& nPosition, + bool bTowards); + + void GetIndexTowards(index_type nNearestIndex, long nNearestPosition, + long nBound, index_type& nFoundIndex, long& nPosition, + bool bTowards); +}; + +class ScViewDataTable // per-sheet data +{ +friend class ScViewData; +private: + SvxZoomType eZoomType; // selected zoom type (normal view) + Fraction aZoomX; // selected zoom X + Fraction aZoomY; // selected zoom Y (displayed) + Fraction aPageZoomX; // zoom in page break preview mode + Fraction aPageZoomY; + + long nTPosX[2]; // MapMode - Offset (Twips) + long nTPosY[2]; + long nMPosX[2]; // MapMode - Offset (1/100 mm) + long nMPosY[2]; + long nPixPosX[2]; // Offset in Pixels + long nPixPosY[2]; + long nHSplitPos; + long nVSplitPos; + + ScSplitMode eHSplitMode; + ScSplitMode eVSplitMode; + ScSplitPos eWhichActive; + + SCCOL nFixPosX; // Cell position of the splitter when freeze pane + SCROW nFixPosY; + + SCCOL nCurX; + SCROW nCurY; + SCCOL nOldCurX; + SCROW nOldCurY; + + ScPositionHelper aWidthHelper; + ScPositionHelper aHeightHelper; + + SCCOL nPosX[2]; ///< X position of the top left cell of the visible area. + SCROW nPosY[2]; ///< Y position of the top left cell of the visible area. + SCCOL nMaxTiledCol; + SCROW nMaxTiledRow; + + bool bShowGrid; // per sheet show grid lines option. + bool mbOldCursorValid; // "virtual" Cursor position when combined + ScViewDataTable(ScDocument *pDoc = nullptr); + + void InitData(ScDocument *pDoc); + void WriteUserDataSequence( + css::uno::Sequence <css::beans::PropertyValue>& rSettings, + const ScViewData& rViewData ) const; + + void ReadUserDataSequence( + const css::uno::Sequence <css::beans::PropertyValue>& rSettings, + ScViewData& rViewData, SCTAB nTab, bool& rHasZoom); + + /** Sanitize the active split range value to not point into a grid window + that would never be initialized due to non-matching split modes. + + This is to be done when reading settings from file formats or + configurations that could have arbitrary values. The caller is + responsible for actually assigning the new value to eWhichActive because + we want this function to be const to be able to call the check from + anywhere. + */ + [[nodiscard]] ScSplitPos SanitizeWhichActive() const; +}; + +class SC_DLLPUBLIC ScViewData +{ +private: + double nPPTX, nPPTY; // Scaling factors + + ::std::vector<std::unique_ptr<ScViewDataTable>> maTabData; + std::unique_ptr<ScMarkData> mpMarkData; + ScViewDataTable* pThisTab; // Data of the displayed sheet + ScDocShell* pDocShell; + ScDocument* pDoc; + ScDBFunc* pView; + ScTabViewShell* pViewShell; + std::unique_ptr<EditView> pEditView[4]; // Belongs to the window + std::unique_ptr<ScViewOptions> pOptions; + EditView* pSpellingView; + + Size aScenButSize; + + Size aScrSize; + MapMode aLogicMode; // skalierter 1/100mm-MapMode + + SvxZoomType eDefZoomType; // default zoom and type for missing TabData + Fraction aDefZoomX; + Fraction aDefZoomY; + Fraction aDefPageZoomX; // zoom in page break preview mode + Fraction aDefPageZoomY; + + ScRefType eRefType; + + SCTAB nTabNo; // displayed sheet + SCTAB nRefTabNo; // sheet which contains RefInput + SCCOL nRefStartX; + SCROW nRefStartY; + SCTAB nRefStartZ; + SCCOL nRefEndX; + SCROW nRefEndY; + SCTAB nRefEndZ; + SCCOL nFillStartX; // Fill Cursor + SCROW nFillStartY; + SCCOL nFillEndX; + SCROW nFillEndY; + SCCOL nEditCol; // Related position + SCROW nEditRow; + SCCOL nEditStartCol; + SCCOL nEditEndCol; // End of Edit View + SCROW nEditEndRow; + SCCOL nTabStartCol; // for Enter after Tab + ScRange aDelRange; // for delete AutoFill + + ScPasteFlags nPasteFlags; + + ScSplitPos eEditActivePart; // the part that was active when edit mode was started + ScFillMode nFillMode; + SvxAdjust eEditAdjust; + bool bEditActive[4]; // Active? + bool bActive:1; // Active Window ? + bool bIsRefMode:1; // Reference input + bool bDelMarkValid:1; // Only valid at SC_REFTYPE_FILL + bool bPagebreak:1; // Page break preview mode + bool bSelCtrlMouseClick:1; // special selection handling for ctrl-mouse-click + bool bMoveArea:1; + + bool bGrowing; + + long m_nLOKPageUpDownOffset; + tools::Rectangle maLOKVisibleArea;///< The visible area in the LibreOfficeKit client. + + DECL_DLLPRIVATE_LINK( EditEngineHdl, EditStatus&, void ); + + + SAL_DLLPRIVATE void CalcPPT(); + SAL_DLLPRIVATE void CreateTabData( SCTAB nNewTab ); + SAL_DLLPRIVATE void CreateTabData( std::vector< SCTAB >& rvTabs ); + SAL_DLLPRIVATE void CreateSelectedTabData(); + SAL_DLLPRIVATE void EnsureTabDataSize(size_t nSize); + SAL_DLLPRIVATE void UpdateCurrentTab(); + +public: + ScViewData( ScDocShell* pDocSh, ScTabViewShell* pViewSh ); + ~ScViewData() COVERITY_NOEXCEPT_FALSE; + + void InitData( ScDocument* pDocument ); + + ScDocShell* GetDocShell() const { return pDocShell; } + ScDocFunc& GetDocFunc() const; + ScDBFunc* GetView() const { return pView; } + ScTabViewShell* GetViewShell() const { return pViewShell; } + SfxObjectShell* GetSfxDocShell() const { return pDocShell; } + SfxBindings& GetBindings(); // from ViewShell's ViewFrame + SfxDispatcher& GetDispatcher(); // from ViewShell's ViewFrame + + ScMarkData& GetMarkData(); + const ScMarkData& GetMarkData() const; + + weld::Window* GetDialogParent(); // forwarded from tabvwsh + ScGridWindow* GetActiveWin(); // from View + const ScGridWindow* GetActiveWin() const; + ScDrawView* GetScDrawView(); // from View + bool IsMinimized() const; // from View + + void UpdateInputHandler( bool bForce = false ); + + void WriteUserData(OUString& rData); + void ReadUserData(const OUString& rData); + void WriteExtOptions( ScExtDocOptions& rOpt ) const; + void ReadExtOptions( const ScExtDocOptions& rOpt ); + void WriteUserDataSequence(css::uno::Sequence <css::beans::PropertyValue>& rSettings) const; + void ReadUserDataSequence(const css::uno::Sequence <css::beans::PropertyValue>& rSettings); + + ScDocument* GetDocument() const; + + bool IsActive() const { return bActive; } + void Activate(bool bActivate) { bActive = bActivate; } + + void InsertTab( SCTAB nTab ); + void InsertTabs( SCTAB nTab, SCTAB nNewSheets ); + void DeleteTab( SCTAB nTab ); + void DeleteTabs( SCTAB nTab, SCTAB nSheets ); + void CopyTab( SCTAB nSrcTab, SCTAB nDestTab ); + void MoveTab( SCTAB nSrcTab, SCTAB nDestTab ); + + SCTAB GetRefTabNo() const { return nRefTabNo; } + void SetRefTabNo( SCTAB nNewTab ) { nRefTabNo = nNewTab; } + + SCTAB GetTabNo() const { return nTabNo; } + SCCOL MaxCol() const { return pDoc->MaxCol(); } + SCROW MaxRow() const { return pDoc->MaxRow(); } + ScSplitPos GetActivePart() const { return pThisTab->eWhichActive; } + SCCOL GetPosX( ScHSplitPos eWhich ) const; + SCROW GetPosY( ScVSplitPos eWhich ) const; + SCCOL GetCurX() const { return pThisTab->nCurX; } + SCROW GetCurY() const { return pThisTab->nCurY; } + SCCOL GetCurXForTab( SCTAB nTabIndex ) const; + SCROW GetCurYForTab( SCTAB nTabIndex ) const; + SCCOL GetOldCurX() const; + SCROW GetOldCurY() const; + long GetLOKDocWidthPixel() const { return pThisTab->aWidthHelper.getPosition(pThisTab->nMaxTiledCol); } + long GetLOKDocHeightPixel() const { return pThisTab->aHeightHelper.getPosition(pThisTab->nMaxTiledRow); } + + ScPositionHelper& GetLOKWidthHelper() { return pThisTab->aWidthHelper; } + ScPositionHelper& GetLOKHeightHelper() { return pThisTab->aHeightHelper; } + + ScPositionHelper* GetLOKWidthHelper(SCTAB nTabIndex); + ScPositionHelper* GetLOKHeightHelper(SCTAB nTabIndex); + + ScSplitMode GetHSplitMode() const { return pThisTab->eHSplitMode; } + ScSplitMode GetVSplitMode() const { return pThisTab->eVSplitMode; } + long GetHSplitPos() const { return pThisTab->nHSplitPos; } + long GetVSplitPos() const { return pThisTab->nVSplitPos; } + SCCOL GetFixPosX() const { return pThisTab->nFixPosX; } + SCROW GetFixPosY() const { return pThisTab->nFixPosY; } + SCCOL GetMaxTiledCol() const { return pThisTab->nMaxTiledCol; } + SCROW GetMaxTiledRow() const { return pThisTab->nMaxTiledRow; } + + bool IsPagebreakMode() const { return bPagebreak; } + bool IsPasteMode() const { return bool(nPasteFlags & ScPasteFlags::Mode); } + bool ShowPasteSource() const { return bool(nPasteFlags & ScPasteFlags::Border); } + + void SetPosX( ScHSplitPos eWhich, SCCOL nNewPosX ); + void SetPosY( ScVSplitPos eWhich, SCROW nNewPosY ); + void SetCurX( SCCOL nNewCurX ) { pThisTab->nCurX = nNewCurX; } + void SetCurY( SCROW nNewCurY ) { pThisTab->nCurY = nNewCurY; } + void SetCurXForTab( SCCOL nNewCurX, SCTAB nTabIndex ); + void SetCurYForTab( SCCOL nNewCurY, SCTAB nTabIndex ); + void SetOldCursor( SCCOL nNewX, SCROW nNewY ); + void ResetOldCursor(); + + void SetHSplitMode( ScSplitMode eMode ) { pThisTab->eHSplitMode = eMode; } + void SetVSplitMode( ScSplitMode eMode ) { pThisTab->eVSplitMode = eMode; } + void SetHSplitPos( long nPos ) { pThisTab->nHSplitPos = nPos; } + void SetVSplitPos( long nPos ) { pThisTab->nVSplitPos = nPos; } + void SetFixPosX( SCCOL nPos ) { pThisTab->nFixPosX = nPos; } + void SetFixPosY( SCROW nPos ) { pThisTab->nFixPosY = nPos; } + void SetMaxTiledCol( SCCOL nCol ); + void SetMaxTiledRow( SCROW nRow ); + + void SetPagebreakMode( bool bSet ); + void SetPasteMode ( ScPasteFlags nFlags ) { nPasteFlags = nFlags; } + + void SetZoomType( SvxZoomType eNew, bool bAll ); + void SetZoomType( SvxZoomType eNew, std::vector< SCTAB >& tabs ); + void SetZoom( const Fraction& rNewX, const Fraction& rNewY, std::vector< SCTAB >& tabs ); + void SetZoom( const Fraction& rNewX, const Fraction& rNewY, bool bAll ); + void RefreshZoom(); + + void SetSelCtrlMouseClick( bool bTmp ) { bSelCtrlMouseClick = bTmp; } + + SvxZoomType GetZoomType() const { return pThisTab->eZoomType; } + const Fraction& GetZoomX() const { return bPagebreak ? pThisTab->aPageZoomX : pThisTab->aZoomX; } + const Fraction& GetZoomY() const { return bPagebreak ? pThisTab->aPageZoomY : pThisTab->aZoomY; } + + void SetShowGrid( bool bShow ); + bool GetShowGrid() const { return pThisTab->bShowGrid; } + + const MapMode& GetLogicMode( ScSplitPos eWhich ); + const MapMode& GetLogicMode(); // Offset 0 + + double GetPPTX() const { return nPPTX; } + double GetPPTY() const { return nPPTY; } + + ScMarkType GetSimpleArea( SCCOL& rStartCol, SCROW& rStartRow, SCTAB& rStartTab, + SCCOL& rEndCol, SCROW& rEndRow, SCTAB& rEndTab ) const; + ScMarkType GetSimpleArea( ScRange& rRange ) const; + /// May modify rNewMark using MarkToSimple(). + ScMarkType GetSimpleArea( ScRange & rRange, ScMarkData & rNewMark ) const; + void GetMultiArea( ScRangeListRef& rRange ) const; + + bool SimpleColMarked(); + bool SimpleRowMarked(); + + bool IsMultiMarked() const; + + /** Disallow cell fill (Paste,Fill,...) on Ctrl+A all + selected or another high amount of selected cells. + We'd go DOOM. + */ + bool SelectionForbidsCellFill(); + /// Determine DOOM condition, i.e. from selected range. + static bool SelectionFillDOOM( const ScRange& rRange ); + + void SetFillMode( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow ); + void SetDragMode( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, + ScFillMode nMode ); + void GetFillData( SCCOL& rStartCol, SCROW& rStartRow, + SCCOL& rEndCol, SCROW& rEndRow ); + void ResetFillMode(); + bool IsAnyFillMode() const { return nFillMode != ScFillMode::NONE; } + bool IsFillMode() const { return nFillMode == ScFillMode::FILL; } + ScFillMode GetFillMode() const { return nFillMode; } + + SvxAdjust GetEditAdjust() const {return eEditAdjust; } + void SetEditAdjust( SvxAdjust eNewEditAdjust ) { eEditAdjust = eNewEditAdjust; } + + // TRUE: Cell is merged + bool GetMergeSizePixel( SCCOL nX, SCROW nY, long& rSizeXPix, long& rSizeYPix ) const; + void GetPosFromPixel( long nClickX, long nClickY, ScSplitPos eWhich, + SCCOL& rPosX, SCROW& rPosY, + bool bTestMerge = true, bool bRepair = false ); + void GetMouseQuadrant( const Point& rClickPos, ScSplitPos eWhich, + SCCOL nPosX, SCROW nPosY, bool& rLeft, bool& rTop ); + + bool IsRefMode() const { return bIsRefMode; } + ScRefType GetRefType() const { return eRefType; } + SCCOL GetRefStartX() const { return nRefStartX; } + SCROW GetRefStartY() const { return nRefStartY; } + SCTAB GetRefStartZ() const { return nRefStartZ; } + SCCOL GetRefEndX() const { return nRefEndX; } + SCROW GetRefEndY() const { return nRefEndY; } + SCTAB GetRefEndZ() const { return nRefEndZ; } + + void SetRefMode( bool bNewMode, ScRefType eNewType ) + { bIsRefMode = bNewMode; eRefType = eNewType; } + + void SetRefStart( SCCOL nNewX, SCROW nNewY, SCTAB nNewZ ); + void SetRefEnd( SCCOL nNewX, SCROW nNewY, SCTAB nNewZ ); + + void ResetDelMark() { bDelMarkValid = false; } + void SetDelMark( const ScRange& rRange ) + { aDelRange = rRange; bDelMarkValid = true; } + + bool GetDelMark( ScRange& rRange ) const + { rRange = aDelRange; return bDelMarkValid; } + + inline void GetMoveCursor( SCCOL& rCurX, SCROW& rCurY ); + + const ScViewOptions& GetOptions() const { return *pOptions; } + void SetOptions( const ScViewOptions& rOpt ); + + bool IsGridMode () const { return pOptions->GetOption( VOPT_GRID ); } + void SetGridMode ( bool bNewMode ) { pOptions->SetOption( VOPT_GRID, bNewMode ); } + bool IsSyntaxMode () const { return pOptions->GetOption( VOPT_SYNTAX ); } + void SetSyntaxMode ( bool bNewMode ) { pOptions->SetOption( VOPT_SYNTAX, bNewMode ); } + bool IsHeaderMode () const { return pOptions->GetOption( VOPT_HEADER ); } + void SetHeaderMode ( bool bNewMode ) { pOptions->SetOption( VOPT_HEADER, bNewMode ); } + bool IsTabMode () const { return pOptions->GetOption( VOPT_TABCONTROLS ); } + void SetTabMode ( bool bNewMode ) { pOptions->SetOption( VOPT_TABCONTROLS, bNewMode ); } + bool IsVScrollMode () const { return pOptions->GetOption( VOPT_VSCROLL ); } + void SetVScrollMode ( bool bNewMode ) { pOptions->SetOption( VOPT_VSCROLL, bNewMode ); } + bool IsHScrollMode () const { return pOptions->GetOption( VOPT_HSCROLL ); } + void SetHScrollMode ( bool bNewMode ) { pOptions->SetOption( VOPT_HSCROLL, bNewMode ); } + bool IsOutlineMode () const { return pOptions->GetOption( VOPT_OUTLINER ); } + void SetOutlineMode ( bool bNewMode ) { pOptions->SetOption( VOPT_OUTLINER, bNewMode ); } + + /// Force page size for PgUp/PgDown to overwrite the computation based on m_aVisArea. + void ForcePageUpDownOffset(long nTwips) { m_nLOKPageUpDownOffset = nTwips; } + long GetPageUpDownOffset() const { return m_nLOKPageUpDownOffset; } + + /// The visible area in the client (set by setClientVisibleArea). + const tools::Rectangle& getLOKVisibleArea() const { return maLOKVisibleArea; } + void setLOKVisibleArea(const tools::Rectangle& rArea) { maLOKVisibleArea = rArea; } + + void KillEditView(); + void ResetEditView(); + void SetEditEngine( ScSplitPos eWhich, + ScEditEngineDefaulter* pNewEngine, + vcl::Window* pWin, SCCOL nNewX, SCROW nNewY ); + void GetEditView( ScSplitPos eWhich, EditView*& rViewPtr, SCCOL& rCol, SCROW& rRow ); + bool HasEditView( ScSplitPos eWhich ) const + { return pEditView[eWhich] && bEditActive[eWhich]; } + EditView* GetEditView( ScSplitPos eWhich ) const + { return pEditView[eWhich].get(); } + + /** + * Extend the output area for the edit engine view in a horizontal + * direction as needed. + */ + void EditGrowX(); + + /** + * Extend the output area for the edit engine view in a vertical direction + * as needed. + * + * @param bInitial when true, then the call originates from a brand-new + * edit engine instance. + */ + void EditGrowY( bool bInitial = false ); + + ScSplitPos GetEditActivePart() const { return eEditActivePart; } + SCCOL GetEditViewCol() const { return nEditCol; } + SCROW GetEditViewRow() const { return nEditRow; } + SCCOL GetEditStartCol() const { return nEditStartCol; } + SCROW GetEditStartRow() const { return nEditRow; } // never editing above the cell + SCCOL GetEditEndCol() const { return nEditEndCol; } + SCROW GetEditEndRow() const { return nEditEndRow; } + + tools::Rectangle GetEditArea( ScSplitPos eWhich, SCCOL nPosX, SCROW nPosY, vcl::Window* pWin, + const ScPatternAttr* pPattern, bool bForceToTop ); + + void SetTabNo( SCTAB nNewTab ); + void SetActivePart( ScSplitPos eNewActive ); + + Point GetScrPos( SCCOL nWhereX, SCROW nWhereY, ScSplitPos eWhich, + bool bAllowNeg = false ) const; + Point GetScrPos( SCCOL nWhereX, SCROW nWhereY, ScHSplitPos eWhich ) const; + Point GetScrPos( SCCOL nWhereX, SCROW nWhereY, ScVSplitPos eWhich ) const; + + /// return json for our cursor position. + OString describeCellCursor() const { return describeCellCursorAt(GetCurX(), GetCurY()); } + OString describeCellCursorAt( SCCOL nCol, SCROW nRow ) const; + + SCCOL CellsAtX( SCCOL nPosX, SCCOL nDir, ScHSplitPos eWhichX, sal_uInt16 nScrSizeY = SC_SIZE_NONE ) const; + SCROW CellsAtY( SCROW nPosY, SCROW nDir, ScVSplitPos eWhichY, sal_uInt16 nScrSizeX = SC_SIZE_NONE ) const; + + SCCOL VisibleCellsX( ScHSplitPos eWhichX ) const; // Completely visible cell + SCROW VisibleCellsY( ScVSplitPos eWhichY ) const; + SCCOL PrevCellsX( ScHSplitPos eWhichX ) const; // Cells on the preceding page + SCROW PrevCellsY( ScVSplitPos eWhichY ) const; + + bool IsOle() const; + void SetScreen( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 ); + void SetScreen( const tools::Rectangle& rVisArea ); + void SetScreenPos( const Point& rVisAreaStart ); + + void UpdateScreenZoom( const Fraction& rNewX, const Fraction& rNewY ); + + const Size& GetScrSize() const { return aScrSize; } + + void RecalcPixPos(); + Point GetPixPos( ScSplitPos eWhich ) const + { return Point( pThisTab->nPixPosX[WhichH(eWhich)], + pThisTab->nPixPosY[WhichV(eWhich)] ); } + void SetSpellingView( EditView* pSpView) { pSpellingView = pSpView; } + EditView* GetSpellingView() const { return pSpellingView; } + + void UpdateOutlinerFlags( Outliner& rOutl ) const; + + Point GetMousePosPixel(); + + bool UpdateFixX(SCTAB nTab = MAXTAB+1); + bool UpdateFixY(SCTAB nTab = MAXTAB+1); + + SCCOL GetTabStartCol() const { return nTabStartCol; } + void SetTabStartCol(SCCOL nNew) { nTabStartCol = nNew; } + + ScAddress GetCurPos() const; + + const Size& GetScenButSize() const { return aScenButSize; } + void SetScenButSize(const Size& rNew) { aScenButSize = rNew; } + + bool IsSelCtrlMouseClick() const { return bSelCtrlMouseClick; } + + static inline long ToPixel( sal_uInt16 nTwips, double nFactor ); + + /** while (rScrY <= nEndPixels && rPosY <= nEndRow) add pixels of row + heights converted with nPPTY to rScrY, optimized for row height + segments. Upon return rPosY is the last row evaluated <= nEndRow, rScrY + may be > nEndPixels! + */ + static void AddPixelsWhile( long & rScrY, long nEndPixels, + SCROW & rPosY, SCROW nEndRow, double nPPTY, + const ScDocument * pDoc, SCTAB nTabNo ); + + /** while (rScrY <= nEndPixels && rPosY >= nStartRow) add pixels of row + heights converted with nPPTY to rScrY, optimized for row height + segments. Upon return rPosY is the last row evaluated >= nStartRow, + rScrY may be > nEndPixels! + */ + static void AddPixelsWhileBackward( long & rScrY, long nEndPixels, + SCROW & rPosY, SCROW nStartRow, double nPPTY, + const ScDocument * pDoc, SCTAB nTabNo ); +}; + +inline long ScViewData::ToPixel( sal_uInt16 nTwips, double nFactor ) +{ + long nRet = static_cast<long>( nTwips * nFactor ); + if ( !nRet && nTwips ) + nRet = 1; + return nRet; +} + +inline void ScViewData::GetMoveCursor( SCCOL& rCurX, SCROW& rCurY ) +{ + if ( bIsRefMode ) + { + rCurX = nRefEndX; + rCurY = nRefEndY; + } + else + { + rCurX = GetCurX(); + rCurY = GetCurY(); + } +} + +inline ScHSplitPos WhichH( ScSplitPos ePos ) +{ + return (ePos==SC_SPLIT_TOPLEFT || ePos==SC_SPLIT_BOTTOMLEFT) ? + SC_SPLIT_LEFT : SC_SPLIT_RIGHT; +} + +inline ScVSplitPos WhichV( ScSplitPos ePos ) +{ + return (ePos==SC_SPLIT_TOPLEFT || ePos==SC_SPLIT_TOPRIGHT) ? + SC_SPLIT_TOP : SC_SPLIT_BOTTOM; +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/viewfunc.hxx b/sc/source/ui/inc/viewfunc.hxx new file mode 100644 index 000000000..a8d4a2598 --- /dev/null +++ b/sc/source/ui/inc/viewfunc.hxx @@ -0,0 +1,381 @@ +/* -*- 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_SC_SOURCE_UI_INC_VIEWFUNC_HXX +#define INCLUDED_SC_SOURCE_UI_INC_VIEWFUNC_HXX + +#include "tabview.hxx" + +#include <tabbgcolor.hxx> + +#include <com/sun/star/embed/Aspects.hpp> +#include <vector> + +class ScPatternAttr; +class ScAutoFormatData; +class SvxSearchItem; +class SfxItemSet; +class SvxBoxItem; +class SvxBoxInfoItem; +class SfxStyleSheetBase; +class SfxStyleSheet; +class SfxPoolItem; +class EditTextObject; +struct ScSolveParam; +struct ScTabOpParam; +class ScValidationData; +class ScConversionParam; +class SdrModel; +class Graphic; +class ScRangeList; +class SvxHyperlinkItem; +class ScTransferObj; +class ScTableProtection; +enum class CreateNameFlags; + +namespace editeng { class SvxBorderLine; } +namespace com::sun::star::embed { class XEmbeddedObject; } + +namespace sc { + +struct ColRowSpan; + +} + +namespace com::sun::star::datatransfer { class XTransferable; } + +struct ScDataFormFragment +{ + std::unique_ptr<weld::Builder> m_xBuilder; + std::unique_ptr<weld::Label> m_xLabel; + std::unique_ptr<weld::Entry> m_xEdit; + + ScDataFormFragment(weld::Container* pGrid, int nLine); +}; + +class ScViewFunc : public ScTabView +{ +private: + ScAddress aFormatSource; // for automatic extension of formatting + ScRange aFormatArea; + bool bFormatValid; + +public: + ScViewFunc( vcl::Window* pParent, ScDocShell& rDocSh, ScTabViewShell* pViewShell ); + ~ScViewFunc(); + + SC_DLLPUBLIC const ScPatternAttr* GetSelectionPattern (); + void GetSelectionFrame( + std::shared_ptr<SvxBoxItem>& rLineOuter, + std::shared_ptr<SvxBoxInfoItem>& rLineInner ); + + SvtScriptType GetSelectionScriptType(); + + bool GetAutoSumArea( ScRangeList& rRangeList ); + void EnterAutoSum( const ScRangeList& rRangeList, bool bSubTotal, const ScAddress& rAddr, const OpCode eCode ); + bool AutoSum( const ScRange& rRange, bool bSubTotal, bool bSetCursor, bool bContinue, const OpCode eCode ); + OUString GetAutoSumFormula( const ScRangeList& rRangeList, bool bSubTotal, const ScAddress& rAddr, const OpCode eCode ); + + void EnterData( SCCOL nCol, SCROW nRow, SCTAB nTab, const OUString& rString, + const EditTextObject* pData = nullptr ); + void EnterData( SCCOL nCol, SCROW nRow, SCTAB nTab, + const EditTextObject& rData, bool bTestSimple = false ); + void EnterValue( SCCOL nCol, SCROW nRow, SCTAB nTab, const double& rValue ); + + void EnterMatrix( const OUString& rString, ::formula::FormulaGrammar::Grammar eGram ); + + /** + * @param pData The caller must manage the life cycle of the object this + * pointer points to. NULL is allowed. + */ + void EnterBlock( const OUString& rString, const EditTextObject* pData ); + + void EnterDataAtCursor( const OUString& rString ); //! Not used? + + SC_DLLPUBLIC void CutToClip(); + SC_DLLPUBLIC bool CopyToClip( ScDocument* pClipDoc, bool bCut, bool bApi = false, + bool bIncludeObjects = false, bool bStopEdit = true ); + SC_DLLPUBLIC bool CopyToClip( ScDocument* pClipDoc, const ScRangeList& rRange, bool bCut, + bool bApi = false, bool bIncludeObjects = false, bool bStopEdit = true ); + bool CopyToClipSingleRange( ScDocument* pClipDoc, const ScRangeList& rRanges, bool bCut, + bool bIncludeObjects ); + bool CopyToClipMultiRange( const ScDocument* pClipDoc, const ScRangeList& rRanges, bool bCut, + bool bApi, bool bIncludeObjects ); + ScTransferObj* CopyToTransferable(); + SC_DLLPUBLIC bool PasteFromClip( InsertDeleteFlags nFlags, ScDocument* pClipDoc, + ScPasteFunc nFunction = ScPasteFunc::NONE, bool bSkipEmpty = false, + bool bTranspose = false, bool bAsLink = false, + InsCellCmd eMoveMode = INS_NONE, + InsertDeleteFlags nUndoExtraFlags = InsertDeleteFlags::NONE, + bool bAllowDialogs = false ); + + void FillTab( InsertDeleteFlags nFlags, ScPasteFunc nFunction, bool bSkipEmpty, bool bAsLink ); + + SC_DLLPUBLIC void PasteFromSystem(); + SC_DLLPUBLIC bool PasteFromSystem( SotClipboardFormatId nFormatId, bool bApi = false ); + void PasteFromTransferable( const css::uno::Reference< + css::datatransfer::XTransferable >& rxTransferable ); + + void PasteDraw(); + void PasteDraw( const Point& rLogicPos, SdrModel* pModel, bool bGroup, + const OUString& rSrcShellID, const OUString& rDestShellID ); + + bool PasteOnDrawObjectLinked( + const css::uno::Reference< css::datatransfer::XTransferable >& rxTransferable, + SdrObject& rHitObj); + + bool PasteDataFormat( SotClipboardFormatId nFormatId, + const css::uno::Reference< css::datatransfer::XTransferable >& rxTransferable, + SCCOL nPosX, SCROW nPosY, const Point* pLogicPos, + bool bLink = false, bool bAllowDialogs = false ); + + bool PasteFile( const Point&, const OUString&, bool bLink ); + bool PasteObject( const Point&, const css::uno::Reference < css::embed::XEmbeddedObject >&, const Size*, const Graphic* = nullptr, const OUString& = OUString(), sal_Int64 nAspect = css::embed::Aspects::MSOLE_CONTENT ); + bool PasteBitmapEx( const Point&, const BitmapEx& ); + bool PasteMetaFile( const Point&, const GDIMetaFile& ); + bool PasteGraphic( const Point& rPos, const Graphic& rGraphic, + const OUString& rFile, const OUString& rFilter ); + bool PasteBookmark( SotClipboardFormatId nFormatId, + const css::uno::Reference< css::datatransfer::XTransferable >& rxTransferable, + SCCOL nPosX, SCROW nPosY ); + bool PasteLink( const css::uno::Reference< css::datatransfer::XTransferable >& rxTransferable ); + + void InsertBookmark( const OUString& rDescription, const OUString& rURL, + SCCOL nPosX, SCROW nPosY, const OUString* pTarget = nullptr, + bool bTryReplace = false ); + bool HasBookmarkAtCursor( SvxHyperlinkItem* pContent ); + + bool MoveBlockTo( const ScRange& rSource, const ScAddress& rDestPos, + bool bCut ); + + bool LinkBlock( const ScRange& rSource, const ScAddress& rDestPos ); + + void CreateNames( CreateNameFlags nFlags ); + CreateNameFlags GetCreateNameFlags(); + void InsertNameList(); + bool InsertName( const OUString& rName, const OUString& rSymbol, + const OUString& rType ); + + void ApplyAttributes( const SfxItemSet* pDialogSet, const SfxItemSet* pOldSet, bool bAdjustBlockHeight = true ); + void ApplyAttr( const SfxPoolItem& rAttrItem, bool bAdjustBlockHeight = true ); + + void ApplySelectionPattern( const ScPatternAttr& rAttr, + bool bCursorOnly = false); + void ApplyPatternLines(const ScPatternAttr& rAttr, + const SvxBoxItem& rNewOuter, + const SvxBoxInfoItem* pNewInner); + + void ApplyUserItemSet( const SfxItemSet& rItemSet ); + + const SfxStyleSheet* + GetStyleSheetFromMarked(); + void SetStyleSheetToMarked( const SfxStyleSheet* pStyleSheet ); + void RemoveStyleSheetInUse( const SfxStyleSheetBase* pStyleSheet ); + void UpdateStyleSheetInUse( const SfxStyleSheetBase* pStyleSheet ); + + void SetNumberFormat( SvNumFormatType nFormatType, sal_uLong nAdd = 0 ); + void SetNumFmtByStr( const OUString& rCode ); + void ChangeNumFmtDecimals( bool bIncrement ); + + void SetValidation( const ScValidationData& rNew ); + + void ChangeIndent( bool bIncrement ); + + void ProtectSheet( SCTAB nTab, const ScTableProtection& rProtect ); + + void Protect( SCTAB nTab, const OUString& rPassword ); + bool Unprotect( SCTAB nTab, const OUString& rPassword ); + + void DeleteCells( DelCellCmd eCmd ); + bool InsertCells( InsCellCmd eCmd, bool bRecord = true, bool bPartOfPaste = false ); + void DeleteMulti( bool bRows ); + + void DeleteContents( InsertDeleteFlags nFlags ); + + void SetWidthOrHeight( + bool bWidth, const std::vector<sc::ColRowSpan>& rRanges, ScSizeMode eMode, + sal_uInt16 nSizeTwips, bool bRecord = true, const ScMarkData* pMarkData = nullptr ); + + void SetMarkedWidthOrHeight( bool bWidth, ScSizeMode eMode, sal_uInt16 nSizeTwips ); + + bool AdjustBlockHeight( bool bPaint = true, ScMarkData* pMarkData = nullptr ); + bool AdjustRowHeight( SCROW nStartRow, SCROW nEndRow ); + + void ModifyCellSize( ScDirection eDir, bool bOptimal ); + + SC_DLLPUBLIC void + InsertPageBreak( bool bColumn, bool bRecord = true, + const ScAddress* pPos = nullptr, + bool bSetModified = true ); + SC_DLLPUBLIC void + DeletePageBreak( bool bColumn, bool bRecord = true, + const ScAddress* pPos = nullptr, + bool bSetModified = true ); + + void RemoveManualBreaks(); + + void SetPrintZoom(sal_uInt16 nScale); + void AdjustPrintZoom(); + + bool TestMergeCells(); + bool TestRemoveMerge(); + + bool MergeCells( bool bApi, bool& rDoContents, bool bCenter ); + bool RemoveMerge(); + + void FillSimple( FillDir eDir ); + void FillSeries( FillDir eDir, FillCmd eCmd, FillDateCmd eDateCmd, + double fStart, double fStep, double fMax ); + void FillAuto( FillDir eDir, SCCOL nStartCol, SCROW nStartRow, + SCCOL nEndCol, SCROW nEndRow, sal_uLong nCount ); + void FillCrossDblClick(); + void ConvertFormulaToValue(); + + void TransliterateText( TransliterationFlags nType ); + + ScAutoFormatData* CreateAutoFormatData(); + void AutoFormat( sal_uInt16 nFormatNo ); + + bool SearchAndReplace( const SvxSearchItem* pSearchItem, + bool bAddUndo, bool bIsApi ); + + void Solve( const ScSolveParam& rParam ); + void TabOp( const ScTabOpParam& rParam, bool bRecord = true ); + + bool InsertTable( const OUString& rName, SCTAB nTabNr, bool bRecord = true ); + void InsertTables(std::vector<OUString>& aNames, SCTAB nTab, SCTAB nCount, bool bRecord = true); + + bool AppendTable( const OUString& rName, bool bRecord = true ); + + void DeleteTable( SCTAB nTabNr, bool bRecord = true ); + bool DeleteTables(const std::vector<SCTAB>& TheTabs, bool bRecord = true ); + void DeleteTables(SCTAB nTab, SCTAB nSheets); + + bool RenameTable( const OUString& rName, SCTAB nTabNr ); + void MoveTable( sal_uInt16 nDestDocNo, SCTAB nDestTab, bool bCopy, const OUString* pNewTabName = nullptr ); + void ImportTables( ScDocShell* pSrcShell, + SCTAB nCount, const SCTAB* pSrcTabs, + bool bLink,SCTAB nTab); + + bool SetTabBgColor( const Color& rColor, SCTAB nTabNr ); + bool SetTabBgColor( ScUndoTabColorInfo::List& rUndoSetTabBgColorInfoList ); + + void InsertTableLink( const OUString& rFile, + const OUString& rFilter, const OUString& rOptions, + const OUString& rTabName ); + void InsertAreaLink( const OUString& rFile, + const OUString& rFilter, const OUString& rOptions, + const OUString& rSource ); + + void ShowTable( const std::vector<OUString>& rNames ); + void HideTable( const ScMarkData& rMark ); + + void MakeScenario(const OUString& rName, const OUString& rComment, + const Color& rColor, ScScenarioFlags nFlags); + void ExtendScenario(); + void UseScenario( const OUString& rName ); + + void InsertSpecialChar( const OUString& rStr, const vcl::Font& rFont ); + + void SetSelectionFrameLines( const ::editeng::SvxBorderLine* pLine, + bool bColorOnly ); + + void SetNoteText( const ScAddress& rPos, const OUString& rNoteText ); + void ReplaceNote( const ScAddress& rPos, const OUString& rNoteText, const OUString* pAuthor, const OUString* pDate ); + void DoRefConversion(); + + void DoHangulHanjaConversion(); + void DoThesaurus(); + + /** Generic implementation of sheet conversion functions. */ + void DoSheetConversion( const ScConversionParam& rParam ); + + void SetPrintRanges( bool bEntireSheet, + const OUString* pPrint, + const OUString* pRepCol, const OUString* pRepRow, + bool bAddPrint ); + + void DetectiveAddPred(); + void DetectiveDelPred(); + void DetectiveAddSucc(); + void DetectiveDelSucc(); + void DetectiveAddError(); + void DetectiveMarkInvalid(); + void DetectiveDelAll(); + void DetectiveRefresh(); + void DetectiveMarkPred(); + void DetectiveMarkSucc(); + + void InsertCurrentTime(SvNumFormatType nCellFmt, const OUString& rUndoStr); + + void ShowNote( bool bShow ); + void EditNote(); + + bool SelectionEditable( bool* pOnlyNotBecauseOfMatrix = nullptr ); + + SC_DLLPUBLIC void + DataFormPutData(SCROW nCurrentRow , + SCROW nStartRow , SCCOL nStartCol , + SCROW nEndRow , SCCOL nEndCol , + std::vector<std::unique_ptr<ScDataFormFragment>>& rEdits, + sal_uInt16 aColLength); + void UpdateSelectionArea( const ScMarkData& rSel, ScPatternAttr* pAttr = nullptr ); + + void OnLOKInsertDeleteColumn(SCCOL nStartCol, long nOffset); + void OnLOKInsertDeleteRow(SCROW nStartRow, long nOffset); + void OnLOKSetWidthOrHeight(SCCOLROW nStart, bool bWidth); + + // Internal helper functions +protected: + static void UpdateLineAttrs( ::editeng::SvxBorderLine& rLine, + const ::editeng::SvxBorderLine* pDestLine, + const ::editeng::SvxBorderLine* pSrcLine, + bool bColor ); + +private: + void PasteRTF( SCCOL nCol, SCROW nStartRow, + const css::uno::Reference< css::datatransfer::XTransferable >& rxTransferable ); + + bool PasteMultiRangesFromClip( InsertDeleteFlags nFlags, ScDocument* pClipDoc, ScPasteFunc nFunction, + bool bSkipEmpty, bool bTranspose, bool bAsLink, bool bAllowDialogs, + InsCellCmd eMoveMode, InsertDeleteFlags nUndoFlags ); + + bool PasteFromClipToMultiRanges( InsertDeleteFlags nFlags, ScDocument* pClipDoc, ScPasteFunc nFunction, + bool bSkipEmpty, bool bTranspose, bool bAsLink, bool bAllowDialogs, + InsCellCmd eMoveMode, InsertDeleteFlags nUndoFlags ); + + void PostPasteFromClip(const ScRangeList& rPasteRanges, const ScMarkData& rMark); + + sal_uInt16 GetOptimalColWidth( SCCOL nCol, SCTAB nTab, bool bFormula ); + + void StartFormatArea(); + bool TestFormatArea( SCCOL nCol, SCROW nRow, SCTAB nTab, bool bAttrChanged ); + void DoAutoAttributes( SCCOL nCol, SCROW nRow, SCTAB nTab, + bool bAttrChanged ); + + void MarkAndJumpToRanges(const ScRangeList& rRanges); + void CopyAutoSpellData( FillDir eDir, SCCOL nStartCol, SCROW nStartRow, + SCCOL nEndCol, SCROW nEndRow, sal_uLong nCount ); +}; + +extern bool bPasteIsDrop; +extern bool bPasteIsMove; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/viewutil.hxx b/sc/source/ui/inc/viewutil.hxx new file mode 100644 index 000000000..f8dddbfbc --- /dev/null +++ b/sc/source/ui/inc/viewutil.hxx @@ -0,0 +1,91 @@ +/* -*- 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_SC_SOURCE_UI_INC_VIEWUTIL_HXX +#define INCLUDED_SC_SOURCE_UI_INC_VIEWUTIL_HXX + +#include <address.hxx> +#include <sal/types.h> +#include <i18nlangtag/lang.h> + +class SfxItemSet; +class SfxBindings; +class SvxFontItem; +class SfxViewShell; +class SfxViewFrame; +class ScChangeAction; +class ScChangeViewSettings; +class ScDocument; +class ScMarkData; +enum class SvtScriptType; +enum class TransliterationFlags; + + +enum class ScUpdateMode { All, Marks }; + +class SC_DLLPUBLIC ScViewUtil +{ +public: + static void ExecuteCharMap( const SvxFontItem& rOldFont, + SfxViewFrame& rFrame ); + + static bool IsActionShown( const ScChangeAction& rAction, + const ScChangeViewSettings& rSettings, + ScDocument& rDocument ); + + static void PutItemScript( SfxItemSet& rShellSet, const SfxItemSet& rCoreSet, + sal_uInt16 nWhichId, SvtScriptType nScript ); + + static LanguageType GetEffLanguage( ScDocument* pDoc, const ScAddress& rPos ); + + static TransliterationFlags GetTransliterationType( sal_uInt16 nSlotID ); + + static bool HasFiltered( const ScRange& rRange, const ScDocument* pDoc ); + /** Fit a range to cover nRows number of unfiltered rows. + @return <TRUE/> if the resulting range covers nRows unfiltered rows. */ + static bool FitToUnfilteredRows( ScRange & rRange, const ScDocument * pDoc, size_t nRows ); + static void UnmarkFiltered( ScMarkData& rMark, const ScDocument* pDoc ); + + static void HideDisabledSlot( SfxItemSet& rSet, SfxBindings& rBindings, sal_uInt16 nSlotId ); + + /** Returns true, if the passed view shell is in full screen mode. */ + static bool IsFullScreen( const SfxViewShell& rViewShell ); + /** Enters or leaves full screen mode at the passed view shell. */ + static void SetFullScreen( const SfxViewShell& rViewShell, bool bSet ); +}; + +class ScUpdateRect +{ +private: + SCCOL nOldStartX; + SCROW nOldStartY; + SCCOL nOldEndX; + SCROW nOldEndY; + SCCOL nNewStartX; + SCROW nNewStartY; + SCCOL nNewEndX; + SCROW nNewEndY; +public: + ScUpdateRect( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2 ); + void SetNew( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2 ); + bool GetDiff( SCCOL& rX1, SCROW& rY1, SCCOL& rX2, SCROW& rY2 ); +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/warnbox.hxx b/sc/source/ui/inc/warnbox.hxx new file mode 100644 index 000000000..ec839abbf --- /dev/null +++ b/sc/source/ui/inc/warnbox.hxx @@ -0,0 +1,42 @@ +/* -*- 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_SC_SOURCE_UI_INC_WARNBOX_HXX +#define INCLUDED_SC_SOURCE_UI_INC_WARNBOX_HXX + +#include <vcl/weld.hxx> + +/** Warning box for "Replace cell contents?". + With warning image and "Do not show again" checkbox. */ +class ScReplaceWarnBox : public weld::MessageDialogController +{ + std::unique_ptr<weld::CheckButton> m_xWarningOnBox; + +public: + ScReplaceWarnBox(weld::Window* pParent); + + /** Opens dialog if IsDialogEnabled() returns true. + @descr If after executing the dialog the checkbox "Do not show again" is set, + the method DisableDialog() will be called. */ + virtual short run() override; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/xmlsourcedlg.hxx b/sc/source/ui/inc/xmlsourcedlg.hxx new file mode 100644 index 000000000..452bac0f8 --- /dev/null +++ b/sc/source/ui/inc/xmlsourcedlg.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/. + */ + +#ifndef INCLUDED_SC_SOURCE_UI_INC_XMLSOURCEDLG_HXX +#define INCLUDED_SC_SOURCE_UI_INC_XMLSOURCEDLG_HXX + +#include "anyrefdg.hxx" +#include <orcusxml.hxx> + +#include <set> +#include <memory> +#include <vector> + +class ScDocument; +class ScRange; +class ScOrcusXMLContext; + +struct CustomCompare +{ + weld::TreeView& mrLbTree; + CustomCompare(weld::TreeView& rLbTree) + : mrLbTree(rLbTree) + { + } + bool operator()(const std::unique_ptr<weld::TreeIter>& lhs, + const std::unique_ptr<weld::TreeIter>& rhs) const + { + return mrLbTree.iter_compare(*lhs, *rhs) == -1; + } +}; + +class ScXMLSourceDlg : public ScAnyRefDlgController +{ + OUString maSrcPath; + + ScOrcusXMLTreeParam maXMLParam; + std::unique_ptr<weld::TreeIter> mxCurRefEntry; + std::unique_ptr<ScOrcusXMLContext> mpXMLContext; + + ScDocument* mpDoc; + bool mbDlgLostFocus; + + formula::RefEdit* mpActiveEdit; + std::unique_ptr<weld::Button> mxBtnSelectSource; + std::unique_ptr<weld::Label> mxFtSourceFile; + + std::unique_ptr<weld::Container> mxMapGrid; + + std::unique_ptr<weld::TreeView> mxLbTree; + std::unique_ptr<formula::RefEdit> mxRefEdit; + std::unique_ptr<formula::RefButton> mxRefBtn; + + std::unique_ptr<weld::Button> mxBtnOk; + std::unique_ptr<weld::Button> mxBtnCancel; + + CustomCompare maCustomCompare; + + std::set<std::unique_ptr<weld::TreeIter>, CustomCompare> maCellLinks; + std::set<std::unique_ptr<weld::TreeIter>, CustomCompare> maRangeLinks; + +public: + ScXMLSourceDlg(SfxBindings* pB, SfxChildWindow* pCW, weld::Window* pParent, ScDocument* pDoc); + virtual ~ScXMLSourceDlg() override; + + virtual bool IsRefInputMode() const override; + virtual void SetReference(const ScRange& rRange, ScDocument& rDoc) override; + virtual void Deactivate() override; + virtual void SetActive() override; + virtual void Close() override; + +private: + void SelectSourceFile(); + void LoadSourceFileStructure(const OUString& rPath); + void TreeItemSelected(); + void DefaultElementSelected(weld::TreeIter& rEntry); + void RepeatElementSelected(weld::TreeIter& rEntry); + void AttributeSelected(weld::TreeIter& rEntry); + + void SetNonLinkable(); + void SetSingleLinkable(); + void SetRangeLinkable(); + void SelectAllChildEntries(weld::TreeIter& rEntry); + + /** + * Check if any of its parents is linked or repeated. The passed entry is + * not checked; its parent is the first one to be checked, then all its + * parents get checked all the way to the root. + */ + bool IsParentDirty(const weld::TreeIter* pEntry) const; + + bool IsChildrenDirty(const weld::TreeIter* pEntry) const; + + void OkPressed(); + void CancelPressed(); + void RefEditModified(); + + DECL_LINK(BtnPressedHdl, weld::Button&, void); + DECL_LINK(TreeItemSelectHdl, weld::TreeView&, void); + DECL_LINK(RefModifiedHdl, formula::RefEdit&, void); +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |