LCOV - code coverage report
Current view: top level - libreoffice/sd/source/ui/inc - smarttag.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 4 0.0 %
Date: 2012-12-27 Functions: 0 5 0.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 _SD_SMARTTAG_HXX_
      21             : #define _SD_SMARTTAG_HXX_
      22             : 
      23             : #include "helper/simplereferencecomponent.hxx"
      24             : #include <rtl/ref.hxx>
      25             : #include <set>
      26             : #include <svx/svdhdl.hxx>
      27             : #include <svx/svdview.hxx>
      28             : 
      29             : class KeyEvent;
      30             : class MouseEvent;
      31             : class SdrHdlList;
      32             : 
      33             : namespace sd {
      34             : 
      35             : class View;
      36             : class SmartHdl;
      37             : 
      38             : /** a smart tag represents a visual user interface element on the documents edit view
      39             :     that is not part of the document. It uses derivations from SmartHdl for its visuals.
      40             :     A SmartTag adds himself to the given view if created. It removes himself if it
      41             :     is disposed before the view is disposed.
      42             : 
      43             :     Derive from this class to implement your own smart tag.
      44             : */
      45             : class SmartTag : public SimpleReferenceComponent
      46             : {
      47             :     friend class SmartTagSet;
      48             : 
      49             : public:
      50             :     explicit SmartTag( ::sd::View& rView );
      51             :     virtual ~SmartTag();
      52             : 
      53             :     /** returns true if the SmartTag consumes this event. */
      54             :     virtual bool MouseButtonDown( const MouseEvent&, SmartHdl& );
      55             : 
      56             :     /** returns true if the SmartTag consumes this event. */
      57             :     virtual bool KeyInput( const KeyEvent& rKEvt );
      58             : 
      59             :     /** returns true if the SmartTag consumes this event. */
      60             :     virtual bool RequestHelp( const HelpEvent& rHEvt );
      61             : 
      62             :     /** returns true if the SmartTag consumes this event. */
      63             :     virtual bool Command( const CommandEvent& rCEvt );
      64             : 
      65             :     /** returns true if this smart tag is currently selected */
      66             :     bool isSelected() const;
      67             : 
      68           0 :     ::sd::View& getView() const { return mrView; }
      69             : 
      70             : protected:
      71             :     virtual sal_uLong GetMarkablePointCount() const;
      72             :     virtual sal_uLong GetMarkedPointCount() const;
      73             :     virtual sal_Bool MarkPoint(SdrHdl& rHdl, sal_Bool bUnmark=sal_False);
      74             :     virtual void CheckPossibilities();
      75             :     virtual sal_Bool MarkPoints(const Rectangle* pRect, sal_Bool bUnmark);
      76             : 
      77             :     virtual void addCustomHandles( SdrHdlList& rHandlerList );
      78             :     virtual void select();
      79             :     virtual void deselect();
      80             :     virtual bool getContext( SdrViewContext& rContext );
      81             : 
      82             :     virtual void disposing();
      83             : 
      84             :     ::sd::View& mrView;
      85             :     bool mbSelected;
      86             : 
      87             : private:
      88             :     SmartTag( const SmartTag& );                // not implemented
      89             :     SmartTag& operator=( const SmartTag& ); // not implemented
      90             : };
      91             : 
      92             : typedef rtl::Reference< SmartTag > SmartTagReference;
      93             : 
      94             : /** class to administrate the available smart tags for a single view. */
      95             : class SmartTagSet
      96             : {
      97             :     friend class SmartTag;
      98             : public:
      99             :     explicit SmartTagSet( ::sd::View& rView );
     100             :     ~SmartTagSet();
     101             : 
     102             :     /** selects the given smart tag and updates all handles */
     103             :     void select( const SmartTagReference& xTag );
     104             : 
     105             :     /** deselects the current selected smart tag and updates all handles */
     106             :     void deselect();
     107             : 
     108             :     /** returns the currently selected tag or an empty reference. */
     109           0 :     const SmartTagReference& getSelected() const { return mxSelectedTag; }
     110             : 
     111             :     /** returns true if a SmartTag consumes this event. */
     112             :     bool MouseButtonDown( const MouseEvent& );
     113             : 
     114             :     /** returns true if a SmartTag consumes this event. */
     115             :     bool KeyInput( const KeyEvent& rKEvt );
     116             : 
     117             :     /** returns true if a SmartTag consumes this event. */
     118             :     bool RequestHelp( const HelpEvent& rHEvt );
     119             : 
     120             :     /** returns true if a SmartTag consumes this event. */
     121             :     bool Command( const CommandEvent& rCEvt );
     122             : 
     123             :     /** disposes all smart tags and clears the set */
     124             :     void Dispose();
     125             : 
     126             :     /** addes the handles from all smart tags to the given list */
     127             :     void addCustomHandles( SdrHdlList& rHandlerList );
     128             : 
     129             :     /** returns true if the currently selected smart tag has
     130             :         a special context, returned in rContext. */
     131             :     bool getContext( SdrViewContext& rContext ) const;
     132             : 
     133             :     // support point editing
     134             :     sal_Bool HasMarkablePoints() const;
     135             :     sal_uLong GetMarkablePointCount() const;
     136             :     sal_Bool HasMarkedPoints() const;
     137             :     sal_uLong GetMarkedPointCount() const;
     138             :     sal_Bool IsPointMarkable(const SdrHdl& rHdl) const;
     139             :     sal_Bool MarkPoint(SdrHdl& rHdl, sal_Bool bUnmark=sal_False);
     140             :     sal_Bool MarkPoints(const Rectangle* pRect, sal_Bool bUnmark);
     141             : 
     142             :     void CheckPossibilities();
     143             : 
     144             : private:
     145             :     SmartTagSet( const SmartTagSet& );              // not implemented
     146             :     SmartTagSet& operator=( const SmartTagSet& );   // not implemented
     147             : 
     148             :     /** adds a new smart tag to this set */
     149             :     void add( const SmartTagReference& xTag );
     150             : 
     151             :     /** removes the given smart tag from this set */
     152             :     void remove( const SmartTagReference& xTag );
     153             : 
     154             :      std::set< SmartTagReference > maSet;
     155             : 
     156             :     ::sd::View& mrView;
     157             :     SmartTagReference mxSelectedTag;
     158             :     SmartTagReference mxMouseOverTag;
     159             : };
     160             : 
     161             : /** a derivation from this handle is the visual representation for a smart tag.
     162             :     One smart tag can have more than one handle.
     163             : */
     164           0 : class SmartHdl : public SdrHdl
     165             : {
     166             : public:
     167             :     SmartHdl( const SmartTagReference& xTag, SdrObject* pObject, const Point& rPnt, SdrHdlKind eNewKind=HDL_SMARTTAG );
     168             :     SmartHdl( const SmartTagReference& xTag, const Point& rPnt, SdrHdlKind eNewKind=HDL_SMARTTAG );
     169             : 
     170           0 :     const SmartTagReference& getTag() const { return mxTag; }
     171             : 
     172             :     virtual bool isMarkable() const;
     173             : protected:
     174             :     SmartTagReference mxTag;
     175             : };
     176             : 
     177             : } // end of namespace sd
     178             : 
     179             : #endif      // _SD_SMARTTAG_HXX_
     180             : 
     181             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10