LCOV - code coverage report
Current view: top level - sw/inc - PostItMgr.hxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 28 34 82.4 %
Date: 2014-04-11 Functions: 8 15 53.3 %
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_SW_INC_POSTITMGR_HXX
      21             : #define INCLUDED_SW_INC_POSTITMGR_HXX
      22             : 
      23             : #include <list>
      24             : #include <vector>
      25             : #include <editeng/outlobj.hxx>
      26             : #include <rtl/ustring.hxx>
      27             : #include <tools/link.hxx>
      28             : #include <swrect.hxx>
      29             : #include <unotools/configitem.hxx>
      30             : #include <unotools/options.hxx>
      31             : #include <com/sun/star/util/SearchOptions.hpp>
      32             : #include <com/sun/star/uno/Any.hxx>
      33             : #include <SidebarWindowsTypes.hxx>
      34             : #include <svl/lstner.hxx>
      35             : 
      36             : class SwWrtShell;
      37             : class SwDoc;
      38             : class SwView;
      39             : class SwPostItField;
      40             : class SwFmtFld;
      41             : class SwField;
      42             : class SfxBroadcaster;
      43             : class SfxHint;
      44             : class SwEditWin;
      45             : class Color;
      46             : class SvxSearchItem;
      47             : class SvxLanguageItem;
      48             : namespace sw { namespace annotation {
      49             :     class SwAnnotationWin;
      50             : }}
      51             : namespace sw { namespace sidebarwindows {
      52             :     class SwSidebarWin;
      53             :     class SwFrmSidebarWinContainer;
      54             : }}
      55             : class SwSidebarItem;
      56             : class SwFrm;
      57             : class Window;
      58             : 
      59             : #define SORT_POS    1
      60             : #define SORT_AUTHOR 2
      61             : #define SORT_DATE   3
      62             : 
      63             : #define COL_NOTES_SIDEPANE_ARROW_ENABLED    RGB_COLORDATA(0,0,0)
      64             : #define COL_NOTES_SIDEPANE_ARROW_DISABLED   RGB_COLORDATA(172,168,153)
      65             : 
      66             : typedef std::list<SwSidebarItem*> SwSidebarItem_list;
      67             : typedef std::list<SwSidebarItem*>::iterator SwSidebarItem_iterator;
      68             : 
      69             : struct SwPostItPageItem
      70             : {
      71             :     bool bScrollbar;
      72             :     sw::sidebarwindows::SidebarPosition eSidebarPosition;
      73             :     long lOffset;
      74             :     SwRect mPageRect;
      75             :     SwSidebarItem_list* mList;
      76        2539 :     SwPostItPageItem(): bScrollbar(false), eSidebarPosition( sw::sidebarwindows::SIDEBAR_LEFT ), lOffset(0)
      77             :     {
      78        2539 :         mList = new SwSidebarItem_list;
      79        2539 :     }
      80        2539 :     ~SwPostItPageItem()
      81             :     {
      82        2539 :         mList->clear();
      83        2539 :         delete mList;
      84        2539 :     }
      85             : 
      86             : };
      87             : 
      88             : struct FieldShadowState
      89             : {
      90             :     const SwPostItField* mpShadowFld;
      91             :     bool bCursor;
      92             :     bool bMouse;
      93        1732 :     FieldShadowState(): mpShadowFld(0),bCursor(false),bMouse(false)
      94             :     {
      95        1732 :     }
      96             : };
      97             : 
      98        1732 : class SwNoteProps: public utl::ConfigItem
      99             : {
     100             :     private:
     101             :         bool bIsShowAnchor;
     102             :     public:
     103        1732 :         SwNoteProps()
     104             :             : ConfigItem(OUString("Office.Writer/Notes"))
     105        1732 :             , bIsShowAnchor(false)
     106             :         {
     107        1732 :             const ::com::sun::star::uno::Sequence< OUString >& rNames = GetPropertyNames();
     108        1732 :                 ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > aValues = GetProperties(rNames);
     109        1732 :                 const ::com::sun::star::uno::Any* pValues = aValues.getConstArray();
     110             :                 SAL_WARN_IF(aValues.getLength() != rNames.getLength(), "sw", "GetProperties failed");
     111        1732 :                 if (aValues.getLength())
     112        1732 :                     pValues[0]>>=bIsShowAnchor;
     113        1732 :         }
     114             : 
     115        1732 :         bool IsShowAnchor()
     116             :         {
     117        1732 :             return bIsShowAnchor;
     118             :         }
     119        1732 :         ::com::sun::star::uno::Sequence< OUString >& GetPropertyNames()
     120             :         {
     121        1732 :             static ::com::sun::star::uno::Sequence< OUString > aNames;
     122        1732 :             if(!aNames.getLength())
     123             :             {
     124          35 :                 aNames.realloc(1);
     125          35 :                 OUString* pNames = aNames.getArray();
     126          35 :                 pNames[0] = OUString("ShowAnkor");
     127             :             }
     128        1732 :             return aNames;
     129             :         }
     130             : 
     131             :     virtual void Commit() SAL_OVERRIDE;
     132             :     virtual void Notify( const ::com::sun::star::uno::Sequence< OUString >& aPropertyNames ) SAL_OVERRIDE;
     133             : };
     134             : 
     135             : class SwPostItMgr: public SfxListener
     136             : {
     137             :     private:
     138             :         SwView*                         mpView;
     139             :         SwWrtShell*                     mpWrtShell;
     140             :         SwEditWin*                      mpEditWin;
     141             :         std::list< SwSidebarItem*>      mvPostItFlds;
     142             :         std::vector<SwPostItPageItem*>  mPages;
     143             :         sal_uLong                           mnEventId;
     144             :         bool                            mbWaitingForCalcRects;
     145             :         sw::sidebarwindows::SwSidebarWin* mpActivePostIt;
     146             :         bool                            mbLayout;
     147             :         long                            mbLayoutHeight;
     148             :         bool                            mbLayouting;
     149             :         bool                            mbReadOnly;
     150             :         bool                            mbDeleteNote;
     151             :         FieldShadowState                mShadowState;
     152             :         OutlinerParaObject*             mpAnswer;
     153             :         bool                            mbIsShowAnchor;
     154             : 
     155             :         // data structure to collect the <SwSidebarWin> instances for certain <SwFrm> instances.
     156             :         sw::sidebarwindows::SwFrmSidebarWinContainer* mpFrmSidebarWinContainer;
     157             : 
     158             :         typedef std::list<sw::sidebarwindows::SwSidebarWin*>::iterator  SwSidebarWin_iterator;
     159             : 
     160             :         void            AddPostIts(bool bCheckExistance = true,bool bFocus = true);
     161             :         void            RemoveSidebarWin();
     162             :         void            PreparePageContainer();
     163             :         void            Scroll(const long lScroll,const unsigned long aPage );
     164             :         void            AutoScroll(const sw::sidebarwindows::SwSidebarWin* pPostIt,const unsigned long aPage );
     165             :         bool            ScrollbarHit(const unsigned long aPage,const Point &aPoint);
     166             :         bool            LayoutByPage( std::list<sw::sidebarwindows::SwSidebarWin*> &aVisiblePostItList,
     167             :                                       const Rectangle aBorder,
     168             :                                       long lNeededHeight);
     169             :         void            CheckForRemovedPostIts();
     170             :             bool                ArrowEnabled(sal_uInt16 aDirection,unsigned long aPage) const;
     171             :             bool                BorderOverPageBorder(unsigned long aPage) const;
     172             :             bool                HasScrollbars() const;
     173             :         void            Focus(SfxBroadcaster& rBC);
     174             : 
     175             :             sal_Int32           GetInitialAnchorDistance() const;
     176             :             sal_Int32           GetScrollSize() const;
     177             :             sal_Int32           GetSpaceBetween() const;
     178             :         void            SetReadOnlyState();
     179             :                     DECL_LINK( CalcHdl, void*);
     180             : 
     181             :         sw::sidebarwindows::SwSidebarWin* GetSidebarWin(const SfxBroadcaster* pBroadcaster) const;
     182             : 
     183             :         void InsertItem( SfxBroadcaster* pItem, bool bCheckExistance, bool bFocus);
     184             :         void RemoveItem( SfxBroadcaster* pBroadcast );
     185             : 
     186             :         void Sort(const short aType);
     187             : 
     188             :     public:
     189             :             SwPostItMgr(SwView* aDoc);
     190             :             virtual ~SwPostItMgr();
     191             : 
     192             :             typedef std::list< SwSidebarItem* >::const_iterator const_iterator;
     193           0 :             const_iterator begin()  const { return mvPostItFlds.begin(); }
     194           0 :             const_iterator end()    const { return mvPostItFlds.end();  }
     195             : 
     196             :             void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) SAL_OVERRIDE;
     197             : 
     198             :             void LayoutPostIts();
     199             :             bool CalcRects();
     200             : 
     201             :             void MakeVisible( const sw::sidebarwindows::SwSidebarWin* pPostIt,
     202             :                               long aPage = -1);
     203             : 
     204             :             bool ShowScrollbar(const unsigned long aPage) const;
     205             :             bool HasNotes() const ;
     206             :             bool ShowNotes() const;
     207           0 :             bool IsShowAnchor() { return mbIsShowAnchor;}
     208             :             unsigned long GetSidebarWidth(bool bPx = false) const;
     209             :             unsigned long GetSidebarBorderWidth(bool bPx = false) const;
     210             :             unsigned long GetNoteWidth();
     211             : 
     212             :             void PrepareView(bool bIgnoreCount = false);
     213             : 
     214             :             void CorrectPositions();
     215             : 
     216           0 :             void SetLayout() { mbLayout = true; };
     217             :             void Delete(const OUString& aAuthor);
     218             :             void Delete();
     219             : 
     220             :             void Hide( const OUString& rAuthor );
     221             :             void Hide();
     222             :             void Show();
     223             : 
     224             :             void Rescale();
     225             : 
     226             :             Rectangle GetBottomScrollRect(const unsigned long aPage) const;
     227             :             Rectangle GetTopScrollRect(const unsigned long aPage) const;
     228             : 
     229             :             bool IsHit(const Point &aPointPixel);
     230             :             Color GetArrowColor(sal_uInt16 aDirection,unsigned long aPage) const;
     231             : 
     232             :             sw::annotation::SwAnnotationWin* GetAnnotationWin(const SwPostItField* pFld) const;
     233             : 
     234             :             sw::sidebarwindows::SwSidebarWin* GetNextPostIt( sal_uInt16 aDirection,
     235             :                                                              sw::sidebarwindows::SwSidebarWin* aPostIt);
     236             :             long GetNextBorder();
     237             : 
     238           9 :             sw::sidebarwindows::SwSidebarWin* GetActiveSidebarWin() { return mpActivePostIt; }
     239             :             void SetActiveSidebarWin( sw::sidebarwindows::SwSidebarWin* p);
     240             :             bool HasActiveSidebarWin() const;
     241             :             bool HasActiveAnnotationWin() const;
     242             :             void GrabFocusOnActiveSidebarWin();
     243             :             void UpdateDataOnActiveSidebarWin();
     244             :             void DeleteActiveSidebarWin();
     245             :             void HideActiveSidebarWin();
     246             :             void ToggleInsModeOnActiveSidebarWin();
     247             : 
     248             :             sal_Int32 GetMinimumSizeWithMeta() const;
     249             :             sal_Int32 GetSidebarScrollerHeight() const;
     250             : 
     251             :             void SetShadowState(const SwPostItField* pFld,bool bCursor = true);
     252             : 
     253             :             void SetSpellChecking();
     254             : 
     255             :             static Color           GetColorDark(sal_uInt16 aAuthorIndex);
     256             :             static Color           GetColorLight(sal_uInt16 aAuthorIndex);
     257             :             static Color           GetColorAnchor(sal_uInt16 aAuthorIndex);
     258             : 
     259           0 :             void                RegisterAnswer(OutlinerParaObject* pAnswer) { mpAnswer = pAnswer;}
     260           0 :             OutlinerParaObject* IsAnswer() {return mpAnswer;}
     261             :             void CheckMetaText();
     262             :             void StartSpelling();
     263             : 
     264             :             sal_uInt16 Replace(SvxSearchItem* pItem);
     265             :             sal_uInt16 SearchReplace(const SwFmtFld &pFld, const ::com::sun::star::util::SearchOptions& rSearchOptions,bool bSrchForward);
     266             :             sal_uInt16 FinishSearchReplace(const ::com::sun::star::util::SearchOptions& rSearchOptions,bool bSrchForward);
     267             : 
     268             :             // get the PostIt window by index
     269             :             sal_Int32 GetPostItCount() const {return mvPostItFlds.size();}
     270             :             void AssureStdModeAtShell();
     271             : 
     272             :             void ConnectSidebarWinToFrm( const SwFrm& rFrm,
     273             :                                          const SwFmtFld& rFmtFld,
     274             :                                          sw::sidebarwindows::SwSidebarWin& rSidebarWin );
     275             :             void DisconnectSidebarWinFromFrm( const SwFrm& rFrm,
     276             :                                               sw::sidebarwindows::SwSidebarWin& rSidebarWin );
     277             :             bool HasFrmConnectedSidebarWins( const SwFrm& rFrm );
     278             :             Window* GetSidebarWinForFrmByIndex( const SwFrm& rFrm,
     279             :                                                 const sal_Int32 nIndex );
     280             :             void GetAllSidebarWinForFrm( const SwFrm& rFrm,
     281             :                                          std::vector< Window* >* pChildren );
     282             : };
     283             : 
     284             : #endif
     285             : 
     286             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10