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

Generated by: LCOV version 1.11