LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/sw/inc - PostItMgr.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 28 34 82.4 %
Date: 2013-07-09 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 _POSTITMGR_HXX
      21             : #define _POSTITMGR_HXX
      22             : 
      23             : #include <list>
      24             : #include <vector>
      25             : #include <editeng/outlobj.hxx>
      26             : #include <tools/string.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             : 
      70             : struct SwPostItPageItem
      71             : {
      72             :     bool bScrollbar;
      73             :     sw::sidebarwindows::SidebarPosition eSidebarPosition;
      74             :     long lOffset;
      75             :     SwRect mPageRect;
      76             :     SwSidebarItem_list* mList;
      77         905 :     SwPostItPageItem(): bScrollbar(false), eSidebarPosition( sw::sidebarwindows::SIDEBAR_LEFT ), lOffset(0)
      78             :     {
      79         905 :         mList = new SwSidebarItem_list;
      80         905 :     }
      81         905 :     ~SwPostItPageItem()
      82             :     {
      83         905 :         mList->clear();
      84         905 :         delete mList;
      85         905 :     }
      86             : 
      87             : };
      88             : 
      89             : struct FieldShadowState
      90             : {
      91             :     const SwPostItField* mpShadowFld;
      92             :     bool bCursor;
      93             :     bool bMouse;
      94         793 :     FieldShadowState(): mpShadowFld(0),bCursor(false),bMouse(false)
      95             :     {
      96         793 :     }
      97             : };
      98             : 
      99         793 : class SwNoteProps: public utl::ConfigItem
     100             : {
     101             :     private:
     102             :         bool bIsShowAnchor;
     103             :     public:
     104         793 :         SwNoteProps()
     105             :             : ConfigItem(OUString("Office.Writer/Notes"))
     106         793 :             , bIsShowAnchor(false)
     107             :         {
     108         793 :             const ::com::sun::star::uno::Sequence< OUString >& rNames = GetPropertyNames();
     109         793 :                 ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > aValues = GetProperties(rNames);
     110         793 :                 const ::com::sun::star::uno::Any* pValues = aValues.getConstArray();
     111             :                OSL_ENSURE(aValues.getLength() == rNames.getLength(), "GetProperties failed");
     112         793 :                 if (aValues.getLength())
     113         793 :                 pValues[0]>>=bIsShowAnchor;
     114         793 :         }
     115             : 
     116         793 :         bool IsShowAnchor()
     117             :         {
     118         793 :             return bIsShowAnchor;
     119             :         }
     120         793 :         ::com::sun::star::uno::Sequence< OUString >& GetPropertyNames()
     121             :         {
     122         793 :             static ::com::sun::star::uno::Sequence< OUString > aNames;
     123         793 :             if(!aNames.getLength())
     124             :             {
     125          31 :                 aNames.realloc(1);
     126          31 :                 OUString* pNames = aNames.getArray();
     127          31 :                 pNames[0] = OUString("ShowAnkor");
     128             :             }
     129         793 :             return aNames;
     130             :         }
     131             : 
     132             :     virtual void Commit();
     133             :     virtual void Notify( const ::com::sun::star::uno::Sequence< OUString >& aPropertyNames );
     134             : };
     135             : 
     136             : class SwPostItMgr: public SfxListener
     137             : {
     138             :     private:
     139             :         SwView*                         mpView;
     140             :         SwWrtShell*                     mpWrtShell;
     141             :         SwEditWin*                      mpEditWin;
     142             :         std::list< SwSidebarItem*>      mvPostItFlds;
     143             :         std::vector<SwPostItPageItem*>  mPages;
     144             :         sal_uLong                           mnEventId;
     145             :         bool                            mbWaitingForCalcRects;
     146             :         sw::sidebarwindows::SwSidebarWin* mpActivePostIt;
     147             :         bool                            mbLayout;
     148             :         long                            mbLayoutHeight;
     149             :         long                            mbLayouting;
     150             :         bool                            mbReadOnly;
     151             :         bool                            mbDeleteNote;
     152             :         FieldShadowState                mShadowState;
     153             :         OutlinerParaObject*             mpAnswer;
     154             :         bool                            mbIsShowAnchor;
     155             : 
     156             :         // data structure to collect the <SwSidebarWin> instances for certain <SwFrm> instances.
     157             :         sw::sidebarwindows::SwFrmSidebarWinContainer* mpFrmSidebarWinContainer;
     158             : 
     159             :         typedef std::list<sw::sidebarwindows::SwSidebarWin*>::iterator  SwSidebarWin_iterator;
     160             : 
     161             :         void            AddPostIts(bool bCheckExistance = true,bool bFocus = true);
     162             :         void            RemoveSidebarWin();
     163             :         void            PreparePageContainer();
     164             :         void            Scroll(const long lScroll,const unsigned long aPage );
     165             :         void            AutoScroll(const sw::sidebarwindows::SwSidebarWin* pPostIt,const unsigned long aPage );
     166             :         bool            ScrollbarHit(const unsigned long aPage,const Point &aPoint);
     167             :         bool            LayoutByPage( std::list<sw::sidebarwindows::SwSidebarWin*> &aVisiblePostItList,
     168             :                                       const Rectangle aBorder,
     169             :                                       long lNeededHeight);
     170             :         void            CheckForRemovedPostIts();
     171             :             bool                ArrowEnabled(sal_uInt16 aDirection,unsigned long aPage) const;
     172             :             bool                BorderOverPageBorder(unsigned long aPage) const;
     173             :             bool                HasScrollbars() const;
     174             :         void            Focus(SfxBroadcaster& rBC);
     175             : 
     176             :             sal_Int32           GetInitialAnchorDistance() const;
     177             :             sal_Int32           GetScrollSize() const;
     178             :             sal_Int32           GetSpaceBetween() const;
     179             :         void            SetReadOnlyState();
     180             :                     DECL_LINK( CalcHdl, void*);
     181             : 
     182             :         sw::sidebarwindows::SwSidebarWin* GetSidebarWin(const SfxBroadcaster* pBroadcaster) const;
     183             : 
     184             :         void InsertItem( SfxBroadcaster* pItem, bool bCheckExistance, bool bFocus);
     185             :         void RemoveItem( SfxBroadcaster* pBroadcast );
     186             : 
     187             :         void Sort(const short aType);
     188             : 
     189             :     public:
     190             :             SwPostItMgr(SwView* aDoc);
     191             :             ~SwPostItMgr();
     192             : 
     193             :             typedef std::list< SwSidebarItem* >::const_iterator const_iterator;
     194           0 :             const_iterator begin()  const { return mvPostItFlds.begin(); }
     195           0 :             const_iterator end()    const { return mvPostItFlds.end();  }
     196             : 
     197             :             void Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
     198             : 
     199             :             void LayoutPostIts();
     200             :             bool CalcRects();
     201             : 
     202             :             void MakeVisible( const sw::sidebarwindows::SwSidebarWin* pPostIt,
     203             :                               long aPage = -1);
     204             : 
     205             :             bool ShowScrollbar(const unsigned long aPage) const;
     206             :             bool HasNotes() const ;
     207             :             bool ShowNotes() const;
     208           0 :             bool IsShowAnchor() { return mbIsShowAnchor;}
     209             :             unsigned long GetSidebarWidth(bool bPx = false) const;
     210             :             unsigned long GetSidebarBorderWidth(bool bPx = false) const;
     211             :             unsigned long GetNoteWidth();
     212             : 
     213             :             void PrepareView(bool bIgnoreCount = false);
     214             : 
     215             :             void CorrectPositions();
     216             : 
     217           0 :             void SetLayout() { mbLayout = true; };
     218             :             void Delete(String aAuthor);
     219             :             void Delete();
     220             : 
     221             :             void Hide( const String& rAuthor );
     222             :             void Hide();
     223             :             void Show();
     224             : 
     225             :             void Rescale();
     226             : 
     227             :             Rectangle GetBottomScrollRect(const unsigned long aPage) const;
     228             :             Rectangle GetTopScrollRect(const unsigned long aPage) const;
     229             : 
     230             :             bool IsHit(const Point &aPointPixel);
     231             :             Color GetArrowColor(sal_uInt16 aDirection,unsigned long aPage) const;
     232             : 
     233             :             sw::annotation::SwAnnotationWin* GetAnnotationWin(const SwPostItField* pFld) const;
     234             : 
     235             :             sw::sidebarwindows::SwSidebarWin* GetNextPostIt( sal_uInt16 aDirection,
     236             :                                                              sw::sidebarwindows::SwSidebarWin* aPostIt);
     237             :             long GetNextBorder();
     238             : 
     239           5 :             sw::sidebarwindows::SwSidebarWin* GetActiveSidebarWin() { return mpActivePostIt; }
     240             :             void SetActiveSidebarWin( sw::sidebarwindows::SwSidebarWin* p);
     241             :             bool HasActiveSidebarWin() const;
     242             :             bool HasActiveAnnotationWin() const;
     243             :             void GrabFocusOnActiveSidebarWin();
     244             :             void UpdateDataOnActiveSidebarWin();
     245             :             void DeleteActiveSidebarWin();
     246             :             void HideActiveSidebarWin();
     247             :             void ToggleInsModeOnActiveSidebarWin();
     248             : 
     249             :             sal_Int32 GetMinimumSizeWithMeta() const;
     250             :             sal_Int32 GetSidebarScrollerHeight() const;
     251             : 
     252             :             void SetShadowState(const SwPostItField* pFld,bool bCursor = true);
     253             : 
     254             :             void SetSpellChecking();
     255             : 
     256             :             static Color           GetColorDark(sal_uInt16 aAuthorIndex);
     257             :             static Color           GetColorLight(sal_uInt16 aAuthorIndex);
     258             :             static Color           GetColorAnchor(sal_uInt16 aAuthorIndex);
     259             : 
     260             : 
     261           0 :             void                RegisterAnswer(OutlinerParaObject* pAnswer) { mpAnswer = pAnswer;}
     262           0 :             OutlinerParaObject* IsAnswer() {return mpAnswer;}
     263             :             void CheckMetaText();
     264             :             void StartSpelling();
     265             : 
     266             :             sal_uInt16 Replace(SvxSearchItem* pItem);
     267             :             sal_uInt16 SearchReplace(const SwFmtFld &pFld, const ::com::sun::star::util::SearchOptions& rSearchOptions,bool bSrchForward);
     268             :             sal_uInt16 FinishSearchReplace(const ::com::sun::star::util::SearchOptions& rSearchOptions,bool bSrchForward);
     269             : 
     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             : 
     287             : 
     288             : 
     289             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10