LCOV - code coverage report
Current view: top level - include/svx - svdedxv.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 8 10 80.0 %
Date: 2015-06-13 12:38:46 Functions: 8 10 80.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #ifndef INCLUDED_SVX_SVDEDXV_HXX
      21             : #define INCLUDED_SVX_SVDEDXV_HXX
      22             : 
      23             : #include <rtl/ref.hxx>
      24             : #include <svl/languageoptions.hxx>
      25             : #include <svx/svxdllapi.h>
      26             : #include <svx/svdglev.hxx>
      27             : #include <svx/selectioncontroller.hxx>
      28             : #include <memory>
      29             : 
      30             : class SdrOutliner;
      31             : class OutlinerView;
      32             : class EditStatus;
      33             : class EditFieldInfo;
      34             : class ImpSdrEditPara;
      35             : struct PasteOrDropInfos;
      36             : class SdrUndoManager;
      37             : 
      38             : namespace com { namespace sun { namespace star { namespace uno {
      39             :     class Any;
      40             : } } } }
      41             : 
      42             : namespace sdr {
      43             :     class SelectionController;
      44             : }
      45             : 
      46             : enum SdrEndTextEditKind {SDRENDTEXTEDIT_UNCHANGED, // textobject unchanged
      47             :                          SDRENDTEXTEDIT_CHANGED,   // textobject changed
      48             :                          SDRENDTEXTEDIT_DELETED,   // textobject implicitly deleted
      49             :                          SDRENDTEXTEDIT_SHOULDBEDELETED}; // for writer: textobject should be deleted
      50             : 
      51             : 
      52             : // - general edit for objectspecific properties
      53             : // - textedit for all drawobjects, inherited from SdrTextObj
      54             : // - macromod
      55             : 
      56             : 
      57             : class SVX_DLLPUBLIC SdrObjEditView: public SdrGlueEditView
      58             : {
      59             :     friend class                SdrPageView;
      60             :     friend class                ImpSdrEditPara;
      61             : 
      62             : protected:
      63             :     // TextEdit
      64             :     SdrObjectWeakRef            mxTextEditObj;          // current object in TextEdit
      65             :     SdrPageView*                pTextEditPV;
      66             :     SdrOutliner*                pTextEditOutliner;     // outliner for the TextEdit
      67             :     OutlinerView*               pTextEditOutlinerView; // current view of the outliners
      68             :     VclPtr<vcl::Window>         pTextEditWin;          // matching window to pTextEditOutlinerView
      69             :     vcl::Cursor*                pTextEditCursorMerker; // to restore the cursor in each window
      70             :     ImpSdrEditPara*             pEditPara; // trashbin for everything else to stay compatible
      71             :     SdrObject*                  pMacroObj;
      72             :     SdrPageView*                pMacroPV;
      73             :     VclPtr<vcl::Window>         pMacroWin;
      74             : 
      75             :     Rectangle                   aTextEditArea;
      76             :     Rectangle                   aMinTextEditArea;
      77             :     Link<>                      aOldCalcFieldValueLink; // for call the old handler
      78             :     Point                       aMacroDownPos;
      79             : 
      80             :     sal_uInt16                  nMacroTol;
      81             : 
      82             :     bool                        bTextEditDontDelete : 1;   // do not delete outliner and view of SdrEndTextEdit (f. spellchecking)
      83             :     bool                        bTextEditOnlyOneView : 1;  // a single OutlinerView (f. spellchecking)
      84             :     bool                        bTextEditNewObj : 1;       // current edited object was just recreated
      85             :     bool                        bQuickTextEditMode : 1;    // persistent(->CrtV). Default=TRUE
      86             :     bool                        bMacroMode : 1;            // persistent(->CrtV). Default=TRUE
      87             :     bool                        bMacroDown : 1;
      88             : 
      89             :     rtl::Reference< sdr::SelectionController > mxSelectionController;
      90             :     rtl::Reference< sdr::SelectionController > mxLastSelectionController;
      91             : 
      92             : private:
      93             :     ::svl::IUndoManager* mpOldTextEditUndoManager;
      94             : 
      95             :     SVX_DLLPRIVATE void ImpClearVars();
      96             : 
      97             : protected:
      98             :     // central method to get an SdrUndoManager for enhanced TextEdit. Default will
      99             :     // try to return a dynamic_casted GetModel()->GetSdrUndoManager(). Applications
     100             :     // which want to use this feature will need to override this virtual method,
     101             :     // provide their document UndoManager and derive it from SdrUndoManager.
     102             :     virtual SdrUndoManager* getSdrUndoManagerForEnhancedTextEdit() const;
     103             : 
     104             :     OutlinerView* ImpFindOutlinerView(vcl::Window* pWin) const;
     105             : 
     106             :     // Create a new OutlinerView at the heap and initialize all required parameters.
     107             :     // pTextEditObj, pTextEditPV and pTextEditOutliner have to be initialized
     108             :     OutlinerView* ImpMakeOutlinerView(vcl::Window* pWin, bool bNoPaint, OutlinerView* pGivenView) const;
     109             :     void ImpPaintOutlinerView(OutlinerView& rOutlView, const Rectangle& rRect, OutputDevice& rTargetDevice) const;
     110             :     void ImpInvalidateOutlinerView(OutlinerView& rOutlView) const;
     111             : 
     112             :     // Check if the whole text is selected.
     113             :     // Still returns sal_True if there is no text present.
     114             :     bool ImpIsTextEditAllSelected() const;
     115             :     void ImpMakeTextCursorAreaVisible();
     116             : 
     117             :     // handler for AutoGrowing text with active Outliner
     118             :     DECL_LINK(ImpOutlinerStatusEventHdl,EditStatus*);
     119             :     DECL_LINK(ImpOutlinerCalcFieldValueHdl,EditFieldInfo*);
     120             : 
     121             :     // link for EndTextEditHdl
     122             :     DECL_LINK(EndTextEditHdl, SdrUndoManager*);
     123             : 
     124             :     void ImpMacroUp(const Point& rUpPos);
     125             :     void ImpMacroDown(const Point& rDownPos);
     126             : 
     127             :        DECL_LINK( BeginPasteOrDropHdl, PasteOrDropInfos* );
     128             :     DECL_LINK( EndPasteOrDropHdl, PasteOrDropInfos* );
     129             : 
     130             : protected:
     131             :     // #i71538# make constructors of SdrView sub-components protected to avoid incomplete incarnations which may get casted to SdrView
     132             :     SdrObjEditView(SdrModel* pModel1, OutputDevice* pOut = 0L);
     133             :     virtual ~SdrObjEditView();
     134             : 
     135             : public:
     136             : 
     137             :     // used to call the old ImpPaintOutlinerView. Will be replaced when the
     138             :     // outliner will be displayed on the overlay in edit mode.
     139             :     void TextEditDrawing(SdrPaintWindow& rPaintWindow) const;
     140             : 
     141             :     // Actionhandling for macromod
     142             :     virtual bool IsAction() const SAL_OVERRIDE;
     143             :     virtual void MovAction(const Point& rPnt) SAL_OVERRIDE;
     144             :     virtual void EndAction() SAL_OVERRIDE;
     145             :     virtual void BrkAction() SAL_OVERRIDE;
     146             :     virtual void BckAction() SAL_OVERRIDE;
     147             :     virtual void TakeActionRect(Rectangle& rRect) const SAL_OVERRIDE;
     148             : 
     149             :     virtual void Notify(SfxBroadcaster& rBC, const SfxHint& rHint) SAL_OVERRIDE;
     150             :     virtual void ModelHasChanged() SAL_OVERRIDE;
     151             : 
     152             : 
     153             :     // TextEdit over an outliner
     154             : 
     155             :     // QuickTextEditMode = edit the text straight after selection. Default=TRUE. Persistent.
     156           3 :     void SetQuickTextEditMode(bool bOn) { bQuickTextEditMode=bOn; }
     157        1405 :     bool IsQuickTextEditMode() const { return bQuickTextEditMode; }
     158             : 
     159             :     // Start the TextEditMode. If pWin==NULL, use the first window, which is logged at the View.
     160             :     // The cursor of the currently edited window is stored with SdrBeginTextEdit()
     161             :     // and restored with SdrEndTextEdit().
     162             :     // The app has to ensure, that the BegEdit of the window logged cursor is still valid,
     163             :     // when SdrEndTextEdit is called.
     164             :     // With the parameter pEditOutliner, the app has the possibility to specify his own outliner,
     165             :     // which is used for editing. After the SdrBeginTextEdit call, the outliner belongs to
     166             :     // SdrObjEditView, and is also later destroyed by this via delete (if bDontDeleteOutliner=sal_False).
     167             :     // Afterwards the SdrObjEditView sets the modflag (EditEngine/Outliner) at this instance and also the
     168             :     // StatusEventHdl.
     169             :     // Similarly a specific OutlinerView can be specified.
     170             : 
     171             :     virtual bool SdrBeginTextEdit(SdrObject* pObj, SdrPageView* pPV = 0L, vcl::Window* pWin = 0L, bool bIsNewObj = false,
     172             :         SdrOutliner* pGivenOutliner = 0L, OutlinerView* pGivenOutlinerView = 0L,
     173             :         bool bDontDeleteOutliner = false, bool bOnlyOneView = false, bool bGrabFocus = true);
     174             :     // bDontDeleteReally is a special parameter for writer
     175             :     // If this flag is set, then a maybe empty textobject is not deleted.
     176             :     // Instead you get a return code SDRENDTEXTEDIT_SHOULDBEDELETED
     177             :     // (in place of SDRENDTEXTEDIT_BEDELETED), which says, the obj should be
     178             :     // deleted.
     179             :     virtual SdrEndTextEditKind SdrEndTextEdit(bool bDontDeleteReally = false);
     180             :     virtual bool IsTextEdit() const SAL_OVERRIDE;
     181             : 
     182             :     // This method returns sal_True, if the point rHit is inside the
     183             :     // objectspace or the OutlinerView.
     184             :     bool IsTextEditHit(const Point& rHit, short nTol) const;
     185             : 
     186             :     // This method returns sal_True, if the point rHit is inside the
     187             :     // handle-thick frame, which surrounds the OutlinerView at TextFrames.
     188             :     bool IsTextEditFrameHit(const Point& rHit) const;
     189             : 
     190             :     // At active selection, between MouseButtonDown and
     191             :     // MouseButtonUp, this method always returns TRUE.
     192             :     bool IsTextEditInSelectionMode() const;
     193             : 
     194             :     // If sb needs the object out of the TextEdit:
     195        3793 :     SdrObject* GetTextEditObject() const { return mxTextEditObj.get(); }
     196             : 
     197             :     // info about TextEditPageView. Default is 0L.
     198             :     virtual SdrPageView* GetTextEditPageView() const SAL_OVERRIDE;
     199             : 
     200             :     // Current window of the outliners.
     201             :     vcl::Window* GetTextEditWin() const { return pTextEditWin; }
     202             :     void SetTextEditWin(vcl::Window* pWin);
     203             : 
     204             :     // Now at this outliner, events can be send, attributes can be set,
     205             :     // call Cut/Copy/Paste, call Undo/Redo, and so on...
     206           0 :     const SdrOutliner* GetTextEditOutliner() const { return pTextEditOutliner; }
     207         646 :     SdrOutliner* GetTextEditOutliner() { return pTextEditOutliner; }
     208             :     const OutlinerView* GetTextEditOutlinerView() const { return pTextEditOutlinerView; }
     209        4341 :     OutlinerView* GetTextEditOutlinerView() { return pTextEditOutlinerView; }
     210             : 
     211             :     virtual bool KeyInput(const KeyEvent& rKEvt, vcl::Window* pWin) SAL_OVERRIDE;
     212             :     virtual bool MouseButtonDown(const MouseEvent& rMEvt, vcl::Window* pWin) SAL_OVERRIDE;
     213             :     virtual bool MouseButtonUp(const MouseEvent& rMEvt, vcl::Window* pWin) SAL_OVERRIDE;
     214             :     virtual bool MouseMove(const MouseEvent& rMEvt, vcl::Window* pWin) SAL_OVERRIDE;
     215             :     virtual bool Command(const CommandEvent& rCEvt, vcl::Window* pWin) SAL_OVERRIDE;
     216             : 
     217             :     // #97766# make virtual to change implementation e.g. for SdOutlineView
     218             :     virtual SvtScriptType GetScriptType() const;
     219             : 
     220             :     /* new interface src537 */
     221             :     bool GetAttributes(SfxItemSet& rTargetSet, bool bOnlyHardAttr=false) const;
     222             : 
     223             :     bool SetAttributes(const SfxItemSet& rSet, bool bReplaceAll);
     224             :     SfxStyleSheet* GetStyleSheet() const; // SfxStyleSheet* GetStyleSheet(bool& rOk) const;
     225             :     bool SetStyleSheet(SfxStyleSheet* pStyleSheet, bool bDontRemoveHardAttr);
     226             : 
     227             :     // Intern: at mounting new OutlinerView...
     228             :     virtual void AddWindowToPaintView(OutputDevice* pNewWin) SAL_OVERRIDE;
     229             :     virtual void DeleteWindowFromPaintView(OutputDevice* pOldWin) SAL_OVERRIDE;
     230             : 
     231             :     sal_uInt16 GetSelectionLevel() const;
     232             : 
     233             : 
     234             : 
     235             :     // Object-MacroModus (e.g. rect as button or sth. like that):
     236             : 
     237             :     // Persistent. Default TRUE. SvDraw evaluates the flag e.g. at SdrView::GetPreferredPointer().
     238             :     // Has only effect, if the document has draw-objects with macrofunctionality (SdrObject::HasMacro()==sal_True).
     239             :     void SetMacroMode(bool bOn) { bMacroMode=bOn; }
     240         720 :     bool IsMacroMode() const { return bMacroMode; }
     241             :     bool BegMacroObj(const Point& rPnt, short nTol, SdrObject* pObj, SdrPageView* pPV, vcl::Window* pWin);
     242           0 :     bool BegMacroObj(const Point& rPnt, SdrObject* pObj, SdrPageView* pPV, vcl::Window* pWin) { return BegMacroObj(rPnt,-2,pObj,pPV,pWin); }
     243             :     void MovMacroObj(const Point& rPnt);
     244             :     void BrkMacroObj();
     245             :     bool EndMacroObj();
     246        2224 :     bool IsMacroObj() const { return pMacroObj!=NULL; }
     247             :     bool IsMacroObjDown() const { return bMacroDown; }
     248             : 
     249             :     /** fills the given any with a XTextCursor for the current text selection.
     250             :         Leaves the any untouched if there currently is no text selected */
     251             :     void getTextSelection( ::com::sun::star::uno::Any& rSelection );
     252             : 
     253             :     virtual void MarkListHasChanged() SAL_OVERRIDE;
     254             : 
     255           8 :     rtl::Reference< sdr::SelectionController > getSelectionController() const { return mxSelectionController; }
     256             : 
     257             :     /** returns true if the shape identified by its inventor and identifier supports format paint brush operation */
     258             :     static bool SupportsFormatPaintbrush( sal_uInt32 nObjectInventor, sal_uInt16 nObjectIdentifier );
     259             : 
     260             :     /** returns a format paint brush set from the current selection */
     261             :     bool TakeFormatPaintBrush( std::shared_ptr< SfxItemSet >& rFormatSet  );
     262             : 
     263             :     /** applies a format paint brush set from the current selection.
     264             :         if bNoCharacterFormats is true, no character attributes are changed.
     265             :         if bNoParagraphFormats is true, no paragraph attributes are changed.
     266             :     */
     267             :     void ApplyFormatPaintBrush( SfxItemSet& rFormatSet, bool bNoCharacterFormats, bool bNoParagraphFormats );
     268             : 
     269             :     /** helper function for selections with multiple SdrText for one SdrTextObj (f.e. tables ) */
     270             :     static void ApplyFormatPaintBrushToText( SfxItemSet& rFormatSet, SdrTextObj& rTextObj, SdrText* pText, bool bNoCharacterFormats, bool bNoParagraphFormats );
     271             : 
     272             : protected:
     273             :     virtual void OnBeginPasteOrDrop( PasteOrDropInfos* pInfos );
     274             :     virtual void OnEndPasteOrDrop( PasteOrDropInfos* pInfos );
     275             : 
     276             : };
     277             : 
     278             : #endif // INCLUDED_SVX_SVDEDXV_HXX
     279             : 
     280             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11